Skip to content

Commit

Permalink
MNT Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 21, 2024
1 parent 89213c9 commit 63770ec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/php/Dev/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function testNoticeNoReplacement()
'Will be removed without equivalent functionality to replace it.',
'Called from SilverStripe\Dev\Tests\DeprecationTest->testNoticeNoReplacement.'
]);
$this->expectDeprecation();
$this->expectException(DeprecationTestException::class);
$this->expectDeprecationMessage($message);
$this->enableDeprecationNotices(true);
$ret = $this->myDeprecatedMethodNoReplacement();
Expand Down
39 changes: 31 additions & 8 deletions tests/php/ORM/Search/SearchContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,42 @@ public function testUserDefinedFiltersAppearInSearchContext()
);
}

public static $debug = false;

public function testUserDefinedFieldsAppearInSearchContext()
{
$company = SearchContextTest\Company::singleton();
self::$debug = true;
$searchName = $company->getGeneralSearchFieldName();
$expected = new FieldList(
new HiddenField($searchName, 'General Search'),
(new TextField("Name", 'Name'))
->setMaxLength(255),
new TextareaField("Industry", 'Industry'),
new NumericField("AnnualProfit", 'The Almighty Annual Profit')
);
$context = $company->getDefaultSearchContext();
$actual = $context->getFields();
$this->assertSame($expected->count(), $actual->count());
$this->assertEquals(
$expected->fieldByName($searchName)->Title,
$actual->fieldByName($searchName)->Title
);
$this->assertEquals(
$expected->fieldByName('Name')->Title,
$actual->fieldByName('Name')->Title
);
$this->assertEquals(
$expected->fieldByName('Name')->getMaxLength(),
$actual->fieldByName('Name')->getMaxLength()
);
$this->assertEquals(
$expected->fieldByName('Industry')->Title,
$actual->fieldByName('Industry')->Title
);
$this->assertEquals(
new FieldList(
new HiddenField($company->getGeneralSearchFieldName(), 'General Search'),
(new TextField("Name", 'Name'))
->setMaxLength(255),
new TextareaField("Industry", 'Industry'),
new NumericField("AnnualProfit", 'The Almighty Annual Profit')
),
$context->getFields()
$expected->fieldByName('AnnualProfit')->Title,
$actual->fieldByName('AnnualProfit')->Title
);
}

Expand Down

0 comments on commit 63770ec

Please sign in to comment.