1
2use strict;
3use warnings;
4use RT;
5use RT::Test tests => undef;
6use Test::Warn;
7
8use_ok('RT::CustomField');
9
10my $queue = RT::Queue->new( RT->SystemUser );
11$queue->Load( "General" );
12ok( $queue->id, "found the General queue" );
13
14my $cf = RT::CustomField->new(RT->SystemUser);
15ok($cf, "Have a CustomField object");
16
17# Use the old Queue field to set up a ticket CF
18my ($ok, $msg) =  $cf->Create(
19    Name        => 'TestingCF',
20    Queue       => '0',
21    Description => 'A Testing custom field',
22    Type        => 'SelectSingle'
23);
24ok($ok, 'Global custom field correctly created');
25is($cf->Type, 'Select', "Is a select CF");
26ok($cf->SingleValue, "Also a single-value CF");
27is($cf->MaxValues, 1, "...meaning only one value, max");
28
29($ok, $msg) = $cf->SetMaxValues('0');
30ok($ok, "Set to infinite values: $msg");
31is($cf->Type, 'Select', "Still a select CF");
32ok( ! $cf->SingleValue, "No longer single-value" );
33is($cf->MaxValues, 0, "...meaning no maximum values");
34
35# Test our sanity checking of CF types
36($ok, $msg) = $cf->SetType('BogusType');
37ok( ! $ok, "Unable to set a custom field's type to a bogus type: $msg");
38
39$cf = RT::CustomField->new(RT->SystemUser);
40($ok, $msg) = $cf->Create(
41    Name => 'TestingCF-bad',
42    Queue => '0',
43    SortOrder => '1',
44    Description => 'A Testing custom field with a bogus Type',
45    Type=> 'SelectSingleton'
46);
47ok( ! $ok, "Correctly could not create with bogus type: $msg");
48
49# Test adding and removing CFVs
50$cf->Load(2);
51($ok, $msg) = $cf->AddValue(Name => 'foo' , Description => 'TestCFValue', SortOrder => '6');
52ok($ok, "Added a new value to the select options");
53($ok, $msg) = $cf->DeleteValue($ok);
54ok($ok, "Deleting it again");
55
56
57# Loading, and context objects
58$cf = RT::CustomField->new( RT->SystemUser );
59$cf->LoadByName( Name => "TestingCF" );
60ok($cf->id, "Load finds it, given just a name" );
61ok( ! $cf->ContextObject, "Did not get a context object");
62
63# Old Queue => form should find the global, gain no context object
64$cf = RT::CustomField->new( RT->SystemUser );
65$cf->LoadByName(Name => 'TestingCF', Queue => 0);
66ok($cf->id, "Load finds it, given a Name and Queue => 0" );
67ok( ! $cf->ContextObject, 'Context object not set when queue is 0');
68
69# We don't default to also searching global -- but do pick up a contextobject
70$cf = RT::CustomField->new( RT->SystemUser );
71$cf->LoadByName(Name => 'TestingCF', Queue => 1);
72ok( ! $cf->id, "Load does not finds it, given a Name and Queue => 1" );
73ok($cf->ContextObject->id, 'Context object is now set');
74
75# If we IncludeGlobal, we find it
76$cf = RT::CustomField->new( RT->SystemUser );
77$cf->LoadByName(Name => 'TestingCF', Queue => 1, IncludeGlobal => 1 );
78ok($cf->id, "Load now finds it, given a Name and Queue => 1 and IncludeGlobal" );
79ok($cf->ContextObject->id, 'Context object is also set');
80
81# The explicit LookupType works
82$cf = RT::CustomField->new( RT->SystemUser );
83$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Ticket->CustomFieldLookupType );
84ok($cf->id, "Load now finds it, given a Name and LookupType" );
85ok( ! $cf->ContextObject, 'No context object gained');
86
87# The explicit LookupType, ObjectId, and IncludeGlobal -- what most folks want
88$cf = RT::CustomField->new( RT->SystemUser );
89$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Ticket->CustomFieldLookupType,
90                ObjectId => 1, IncludeGlobal => 1 );
91ok($cf->id, "Load now finds it, given a Name, LookupType, ObjectId, IncludeGlobal" );
92ok($cf->ContextObject->id, 'And gains a context obj');
93
94# Look for a queue by name
95$cf = RT::CustomField->new( RT->SystemUser );
96$cf->LoadByName(Name => 'TestingCF', Queue => "General" );
97ok( ! $cf->id, "No IncludeGlobal, so queue by name fails" );
98ok($cf->ContextObject->id, 'But gains a context object');
99
100# Look for a queue by name, include global
101$cf = RT::CustomField->new( RT->SystemUser );
102$cf->LoadByName(Name => 'TestingCF', Queue => "General", IncludeGlobal => 1 );
103ok($cf->id, "By name, and queue name works with IncludeGlobal" );
104ok($cf->ContextObject->id, 'And gains a context object');
105
106
107
108# A bogus Queue gets you no results, but a warning
109$cf = RT::CustomField->new( RT->SystemUser );
110warning_like {
111    $cf->LoadByName(Name => 'TestingCF', Queue => "Bogus" );
112    ok( ! $cf->id, "With a bogus queue name gets no results" );
113    ok( ! $cf->ContextObject, 'And also no context object');
114} qr/Failed to load RT::Queue 'Bogus'/, "Generates a warning";
115
116# Ditto by number which is bogus
117$cf = RT::CustomField->new( RT->SystemUser );
118warning_like {
119    $cf->LoadByName(Name => 'TestingCF', Queue => "9000" );
120    ok( ! $cf->id, "With a bogus queue number gets no results" );
121    ok( ! $cf->ContextObject, 'And also no context object');
122} qr/Failed to load RT::Queue '9000'/, "Generates a warning";
123
124# But if they also wanted global results, we might have an answer
125$cf = RT::CustomField->new( RT->SystemUser );
126warning_like {
127    $cf->LoadByName(Name => 'TestingCF', Queue => "9000", IncludeGlobal => 1 );
128    ok($cf->id, "Bogus queue but IncludeGlobal founds it" );
129    ok( ! $cf->ContextObject, 'But no context object');
130} qr/Failed to load RT::Queue '9000'/, "And generates a warning";
131
132
133# Make it only apply to one queue
134$cf->Load(2);
135my $ocf = RT::ObjectCustomField->new( RT->SystemUser );
136( $ok, $msg ) = $ocf->LoadByCols( CustomField => $cf->id, ObjectId => 0 );
137ok( $ok, "Found global application of CF" );
138( $ok, $msg ) = $ocf->Delete;
139ok( $ok, "...and deleted it");
140( $ok, $msg ) = $ocf->Add( CustomField => $cf->id, ObjectId => 1 );
141ok($ok, "Applied to just queue 1" );
142
143# Looking for it globally with Queue => 0 should fail, gain no context object
144$cf = RT::CustomField->new( RT->SystemUser );
145$cf->LoadByName(Name => 'TestingCF', Queue => 0);
146ok( ! $cf->id, "Load fails to find, given a Name and Queue => 0" );
147ok( ! $cf->ContextObject, 'Context object not set when queue is 0');
148
149# Looking it up by Queue => 1 works fine, and gets context object
150$cf = RT::CustomField->new( RT->SystemUser );
151$cf->LoadByName(Name => 'TestingCF', Queue => 1);
152ok($cf->id, "Load does finds it, given a Name and Queue => 1" );
153ok($cf->ContextObject->id, 'Context object is now set');
154
155# Also find it with IncludeGlobal
156$cf = RT::CustomField->new( RT->SystemUser );
157$cf->LoadByName(Name => 'TestingCF', Queue => 1, IncludeGlobal => 1 );
158ok($cf->id, "Load also finds it, given a Name and Queue => 1 and IncludeGlobal" );
159ok($cf->ContextObject->id, 'Context object is also set');
160
161# The explicit LookupType works
162$cf = RT::CustomField->new( RT->SystemUser );
163$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Ticket->CustomFieldLookupType );
164ok($cf->id, "Load also finds it, given a Name and LookupType" );
165ok( ! $cf->ContextObject, 'But no context object gained');
166
167# Explicit LookupType, ObjectId works
168$cf = RT::CustomField->new( RT->SystemUser );
169$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Ticket->CustomFieldLookupType,
170                ObjectId => 1 );
171ok($cf->id, "Load still finds it, given a Name, LookupType, ObjectId" );
172ok($cf->ContextObject->id, 'And gains a context obj');
173
174# Explicit LookupType, ObjectId works
175$cf = RT::CustomField->new( RT->SystemUser );
176$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Ticket->CustomFieldLookupType,
177                ObjectId => 1, IncludeGlobal => 1 );
178ok($cf->id, "Load also finds it, given a Name, LookupType, ObjectId, and IncludeGlobal" );
179ok($cf->ContextObject->id, 'And gains a context obj');
180
181# Look for a queue by name
182$cf = RT::CustomField->new( RT->SystemUser );
183$cf->LoadByName(Name => 'TestingCF', Queue => "General" );
184ok($cf->id, "Finds it by queue name" );
185ok($cf->ContextObject->id, 'But gains a context object');
186
187# Look for a queue by name, include global
188$cf = RT::CustomField->new( RT->SystemUser );
189$cf->LoadByName(Name => 'TestingCF', Queue => "General", IncludeGlobal => 1 );
190ok($cf->id, "By name, and queue name works with IncludeGlobal" );
191ok($cf->ContextObject->id, 'And gains a context object');
192
193
194
195
196# Change the lookup type to be a _queue_ CF
197($ok, $msg) = $cf->SetLookupType( RT::Queue->CustomFieldLookupType );
198ok($ok, "Changed CF type to be a CF on queues" );
199$ocf = RT::ObjectCustomField->new( RT->SystemUser );
200( $ok, $msg ) = $ocf->Add( CustomField => $cf->id, ObjectId => 0 );
201ok($ok, "Applied globally" );
202
203# Just looking by name gets you CFs of any type
204$cf = RT::CustomField->new( RT->SystemUser );
205$cf->LoadByName(Name => 'TestingCF');
206ok($cf->id, "Find the CF by name, with no queue" );
207
208# Queue => 0 means "ticket CF", so doesn't find it
209$cf = RT::CustomField->new( RT->SystemUser );
210$cf->LoadByName(Name => 'TestingCF', Queue => 0);
211ok( ! $cf->id, "Wrong lookup type to find with Queue => 0" );
212
213# Queue => 1 and IncludeGlobal also doesn't find it
214$cf = RT::CustomField->new( RT->SystemUser );
215$cf->LoadByName(Name => 'TestingCF', Queue => 0, IncludeGlobal => 1);
216ok( ! $cf->id, "Also doesn't find with Queue => 0 and IncludeGlobal" );
217
218# Find it with the right LookupType
219$cf = RT::CustomField->new( RT->SystemUser );
220$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Queue->CustomFieldLookupType );
221ok($cf->id, "Found for the right lookup type" );
222
223# Found globally
224$cf = RT::CustomField->new( RT->SystemUser );
225$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Queue->CustomFieldLookupType, ObjectId => 0 );
226ok($cf->id, "Found for the right lookup type and ObjectId 0" );
227
228# Also works with Queue instead of ObjectId
229$cf = RT::CustomField->new( RT->SystemUser );
230$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Queue->CustomFieldLookupType, Queue => 0 );
231ok($cf->id, "Found for the right lookup type and Queue 0" );
232
233# Not found without IncludeGlobal
234$cf = RT::CustomField->new( RT->SystemUser );
235$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Queue->CustomFieldLookupType, ObjectId => 1 );
236ok( ! $cf->id, "Not found for ObjectId 1 and no IncludeGlobal" );
237
238# Found with IncludeGlobal
239$cf = RT::CustomField->new( RT->SystemUser );
240$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Queue->CustomFieldLookupType,
241                ObjectId => 1, IncludeGlobal => 1 );
242ok($cf->id, "Found for ObjectId 1 and IncludeGlobal" );
243
244# Found with IncludeGlobal and Queue instead of ObjectId
245$cf = RT::CustomField->new( RT->SystemUser );
246$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Queue->CustomFieldLookupType,
247                ObjectId => 1, IncludeGlobal => 1 );
248ok($cf->id, "Found for Queue 1 and IncludeGlobal" );
249
250
251
252# Change the lookup type to be a _transaction_ CF
253($ok, $msg) = $cf->SetLookupType( RT::Transaction->CustomFieldLookupType );
254ok($ok, "Changed CF type to be a CF on transactions" );
255$ocf = RT::ObjectCustomField->new( RT->SystemUser );
256( $ok, $msg ) = $ocf->Add( CustomField => $cf->id, ObjectId => 0 );
257ok($ok, "Applied globally" );
258
259# Just looking by name gets you CFs of any type
260$cf = RT::CustomField->new( RT->SystemUser );
261$cf->LoadByName(Name => 'TestingCF');
262ok($cf->id, "Find the CF by name, with no queue" );
263
264# Queue => 0 means "ticket CF", so doesn't find it
265$cf = RT::CustomField->new( RT->SystemUser );
266$cf->LoadByName(Name => 'TestingCF', Queue => 0);
267ok( ! $cf->id, "Wrong lookup type to find with Queue => 0" );
268
269# Queue => 1 and IncludeGlobal also doesn't find it
270$cf = RT::CustomField->new( RT->SystemUser );
271$cf->LoadByName(Name => 'TestingCF', Queue => 0, IncludeGlobal => 1);
272ok( ! $cf->id, "Also doesn't find with Queue => 0 and IncludeGlobal" );
273
274
275# Change the lookup type to be a _user_ CF
276$cf->Load(2);
277($ok, $msg) = $cf->SetLookupType( RT::User->CustomFieldLookupType );
278ok($ok, "Changed CF type to be a CF on users" );
279$ocf = RT::ObjectCustomField->new( RT->SystemUser );
280( $ok, $msg ) = $ocf->Add( CustomField => $cf->id, ObjectId => 0 );
281ok($ok, "Applied globally" );
282
283# Just looking by name gets you CFs of any type
284$cf = RT::CustomField->new( RT->SystemUser );
285$cf->LoadByName(Name => 'TestingCF');
286ok($cf->id, "Find the CF by name, with no queue" );
287
288# Queue => 0 means "ticket CF", so doesn't find it
289$cf = RT::CustomField->new( RT->SystemUser );
290$cf->LoadByName(Name => 'TestingCF', Queue => 0);
291ok( ! $cf->id, "Wrong lookup type to find with Queue => 0" );
292
293# Queue => 1 and IncludeGlobal also doesn't find it
294$cf = RT::CustomField->new( RT->SystemUser );
295$cf->LoadByName(Name => 'TestingCF', Queue => 0, IncludeGlobal => 1);
296ok( ! $cf->id, "Also doesn't find with Queue => 0 and IncludeGlobal" );
297
298# But RT::User->CustomFieldLookupType does
299$cf = RT::CustomField->new( RT->SystemUser );
300$cf->LoadByName(Name => 'TestingCF', LookupType => RT::User->CustomFieldLookupType );
301ok($cf->id, "User lookuptype does" );
302
303# Also with an explicit global
304$cf = RT::CustomField->new( RT->SystemUser );
305$cf->LoadByName(Name => 'TestingCF', LookupType => RT::User->CustomFieldLookupType, ObjectId => 0 );
306ok($cf->id, "Also with user CF and explicit global" );
307
308
309
310# Add a second, queue-specific CF to test load order
311$cf->Load(2);
312($ok, $msg) = $cf->SetLookupType( RT::Ticket->CustomFieldLookupType );
313ok($ok, "Changed CF type back to be a CF on tickets" );
314$ocf = RT::ObjectCustomField->new( RT->SystemUser );
315( $ok, $msg ) = $ocf->Add( CustomField => $cf->id, ObjectId => 0 );
316ok($ok, "Applied globally" );
317($ok, $msg) = $cf->SetDescription( "Global CF" );
318ok($ok, "Changed CF type back to be a CF on tickets" );
319
320($ok, $msg) = $cf->Create(
321    Name        => 'TestingCF',
322    Queue       => '1',
323    Description => 'Queue-specific CF',
324    Type        => 'SelectSingle'
325);
326ok($ok, "Created second CF successfully");
327
328# If passed just a name, you get the first by id
329$cf = RT::CustomField->new( RT->SystemUser );
330$cf->LoadByName(Name => 'TestingCF' );
331like($cf->Description, qr/Global/, "Gets the first (global) one if just loading by name" );
332
333# Ditto if also limited to lookuptype
334$cf = RT::CustomField->new( RT->SystemUser );
335$cf->LoadByName(Name => 'TestingCF', LookupType => RT::Ticket->CustomFieldLookupType );
336like($cf->Description, qr/Global/, "Same, if one adds a LookupType" );
337
338# Gets the global with Queue => 0
339$cf = RT::CustomField->new( RT->SystemUser );
340$cf->LoadByName(Name => 'TestingCF', Queue => 0 );
341like($cf->Description, qr/Global/, "Specify Queue => 0 and get global" );
342
343# Gets the queue with Queue => 1
344$cf = RT::CustomField->new( RT->SystemUser );
345$cf->LoadByName(Name => 'TestingCF', Queue => 1 );
346like($cf->Description, qr/Queue/, "Specify Queue => 1 and get the queue" );
347
348# Gets the queue with Queue => 1 and IncludeGlobal
349$cf = RT::CustomField->new( RT->SystemUser );
350$cf->LoadByName(Name => 'TestingCF', Queue => 1, IncludeGlobal => 1 );
351like($cf->Description, qr/Queue/, "Specify Queue => 1 and IncludeGlobal and get the queue" );
352
353
354# Disable one of them
355($ok, $msg) = $cf->SetDisabled(1);
356is($msg, "Disabled", "Disabling custom field gives correct message");
357ok($ok, "Disabled the Queue-specific one");
358($ok, $msg) = $cf->SetDisabled(0);
359is($msg, "Enabled", "Enabling custom field gives correct message");
360ok($ok, "Enabled the Queue-specific one");
361($ok, $msg) = $cf->SetDisabled(1);
362is($msg, "Disabled", "Disabling custom field again gives correct message");
363ok($ok, "Disabled the Queue-specific one again");
364
365# With just a name, prefers the non-disabled
366$cf = RT::CustomField->new( RT->SystemUser );
367$cf->LoadByName(Name => 'TestingCF' );
368like($cf->Description, qr/Global/, "Prefers non-disabled CFs" );
369
370# Still finds the queue one, if asked
371$cf = RT::CustomField->new( RT->SystemUser );
372$cf->LoadByName(Name => 'TestingCF', Queue => 1 );
373like($cf->Description, qr/Queue/, "Still loads the disabled queue CF" );
374
375# Prefers the global one if IncludeGlobal
376$cf = RT::CustomField->new( RT->SystemUser );
377$cf->LoadByName(Name => 'TestingCF', Queue => 1, IncludeGlobal => 1 );
378like($cf->Description, qr/Global/, "Prefers the global one with IncludeGlobal" );
379
380# IncludeDisabled allows filtering out the disabled one
381$cf = RT::CustomField->new( RT->SystemUser );
382$cf->LoadByName(Name => 'TestingCF', Queue => 1, IncludeDisabled => 0 );
383ok( ! $cf->id, "Doesn't find it if IncludeDisabled => 0" );
384
385$cf->LoadByName( Name => 'TestingCF', Queue => 0, IncludeGlobal => 1 );
386is( $cf->MaxValues, 0, 'Max value is 0' );
387my $ticket = RT::Test->create_ticket( Queue => 1, Subject => 'test cf values' );
388ok( $ticket->AddCustomFieldValue( Field => $cf, Value => 'first value' ) );
389ok( $ticket->AddCustomFieldValue( Field => $cf, Value => 'second value' ) );
390
391my $cf_values = $cf->ValuesForObject($ticket);
392is( $cf_values->Count, 2, 'Found 2 values' );
393is( $ticket->CustomFieldValuesAsString( $cf, Separator => ', ' ), 'first value, second value', 'Current cf contents' );
394
395($ok, $msg) = $cf->SetMaxValues(1);
396is( $cf->MaxValues, 1, 'Max value is 1' );
397ok( $ticket->AddCustomFieldValue( Field => $cf, Value => 'third value' ) );
398
399$cf_values = $cf->ValuesForObject($ticket);
400is( $cf_values->Count, 1, 'Found 1 value' );
401is( $ticket->CustomFieldValuesAsString( $cf, Separator => ', ' ), 'third value', 'Current cf contents' );
402
403($ok, $msg) = $cf->SetMaxValues(2);
404is( $cf->MaxValues, 2, 'Max value is 2' );
405ok( $ticket->AddCustomFieldValue( Field => $cf, Value => 'forth value' ) );
406
407$cf_values = $cf->ValuesForObject($ticket);
408is( $cf_values->Count, 2, 'Found 2 values' );
409is( $ticket->CustomFieldValuesAsString( $cf, Separator => ', ' ), 'third value, forth value', 'Current cf contents' );
410
411ok( $ticket->AddCustomFieldValue( Field => $cf, Value => 'fifth value' ) );
412$cf_values = $cf->ValuesForObject($ticket);
413is( $cf_values->Count, 2, 'Found 2 values' );
414is( $ticket->CustomFieldValuesAsString( $cf, Separator => ', ' ), 'forth value, fifth value', 'Current cf contents' );
415
416$cf = RT::CustomField->new( RT->SystemUser );
417$cf->LoadByName(Name => 'TestingCF', Queue => 1, IncludeDisabled => 1 );
418($ok, $msg) = $cf->SetDisabled(0);
419ok($ok, "Re-enabled CF " . $cf->Name);
420
421diag 'Test sort ordering when disabling and re-enabling CFs';
422
423# Create more CFs
424foreach my $i (2..5) {
425    ($ok, $msg) = $cf->Create(
426        Name        => "TestingCF$i",
427        Queue       => '0',
428        Description => 'Global CF',
429        Type        => 'SelectSingle'
430    );
431    ok($ok, "Created " . $cf->Name . " successfully");
432
433    $ocf = RT::ObjectCustomField->new( RT->SystemUser );
434    ( $ok, $msg ) = $ocf->LoadByCols( CustomField => $cf->id, ObjectId => 0 );
435    ok( $ok, "Found OCF " . $ocf->Id);
436    is( $ocf->SortOrder, $i, "Sort order is $i for OCF " . $ocf->Id);
437}
438
439diag 'Disable TestingCF4';
440$cf = RT::CustomField->new( RT->SystemUser );
441$cf->LoadByName(Name => 'TestingCF4', Queue => 0 );
442($ok, $msg) = $cf->SetDisabled(1);
443ok($ok, "Disabled " . $cf->Name);
444
445diag 'MoveUp TestingCF5';
446$cf = RT::CustomField->new( RT->SystemUser );
447$cf->LoadByName(Name => 'TestingCF5', Queue => 0 );
448$ocf = RT::ObjectCustomField->new( RT->SystemUser );
449( $ok, $msg ) = $ocf->LoadByCols( CustomField => $cf->id, ObjectId => 0 );
450ok( $ok, "Found OCF " . $ocf->Id . " for " . $cf->Name );
451is( $ocf->SortOrder, 5, 'Sort order before MoveUp');
452$ocf->MoveUp;
453is( $ocf->SortOrder, 3, 'Sort order after MoveUp');
454
455$cf = RT::CustomField->new( RT->SystemUser );
456$cf->LoadByName(Name => 'TestingCF3', Queue => 0 );
457$ocf = RT::ObjectCustomField->new( RT->SystemUser );
458( $ok, $msg ) = $ocf->LoadByCols( CustomField => $cf->id, ObjectId => 0 );
459ok( $ok, "Found OCF " . $ocf->Id . " for " . $cf->Name );
460is( $ocf->SortOrder, 4, 'Sort order is 4 for OCF ' . $ocf->Id);
461
462
463# Sort order should become 5 when re-enabled and not stay at 4
464$cf = RT::CustomField->new( RT->SystemUser );
465$cf->LoadByName(Name => 'TestingCF4', Queue => 0 );
466($ok, $msg) = $cf->SetDisabled(0);
467ok($ok, "Re-enabled " . $cf->Name);
468$ocf = RT::ObjectCustomField->new( RT->SystemUser );
469( $ok, $msg ) = $ocf->LoadByCols( CustomField => $cf->id, ObjectId => 0 );
470ok( $ok, "Found OCF for " . $cf->Name );
471is( $ocf->SortOrder, 5, 'Sort order is 5, CF moved to bottom of list on re-enable');
472
473done_testing;
474