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 22, 2024
1 parent ba97de9 commit f5bc934
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Core/Extensible.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public function getExtensionInstances()
// Setup all extension instances for this instance
$this->extension_instances = [];
foreach (ClassInfo::ancestry(static::class) as $class) {
if (in_array($class, self::$unextendable_classes)) {
if (in_array($class, self::class::$unextendable_classes)) {
continue;
}
$extensions = Config::inst()->get($class, 'extensions', Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES);
Expand Down
2 changes: 1 addition & 1 deletion src/Dev/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC
}

// Getting a backtrace is slow, so we only do it if we need it
$backtrace = null;
$backtrace = [];

// Get the calling scope
if ($scope == Deprecation::SCOPE_METHOD) {
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Dev/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function testNoticeNoReplacement()
'Will be removed without equivalent functionality to replace it.',
'Called from SilverStripe\Dev\Tests\DeprecationTest->testNoticeNoReplacement.'
]);
$this->expectDeprecation();
$this->expectDeprecationMessage($message);
$this->expectException(DeprecationTestException::class);
$this->expectExceptionMessage($message);
$this->enableDeprecationNotices(true);
$ret = $this->myDeprecatedMethodNoReplacement();
$this->assertSame('abc', $ret);
Expand Down
20 changes: 11 additions & 9 deletions tests/php/ORM/Search/SearchContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,18 @@ public function testUserDefinedFieldsAppearInSearchContext()
{
$company = SearchContextTest\Company::singleton();
$context = $company->getDefaultSearchContext();
$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 = new FieldList(
new HiddenField($company->getGeneralSearchFieldName(), 'General Search'),
$fieldA = (new TextField("Name", 'Name'))->setMaxLength(255),
$fieldB = new TextareaField("Industry", 'Industry'),
$fieldC = new NumericField("AnnualProfit", 'The Almighty Annual Profit')
);
foreach ([$fieldA, $fieldB, $fieldC] as $field) {
// Call getExtensionInstances() so that extension_instances is not null
// so that it is equivalent to $context-getFields() below
$field->getExtensionInstances();
}
$this->assertEquals($expected, $context->getFields());
}

public function testRelationshipObjectsLinkedInSearch()
Expand Down

0 comments on commit f5bc934

Please sign in to comment.