diff --git a/src/Dev/Deprecation.php b/src/Dev/Deprecation.php index e8d1111a431..05050c4f193 100644 --- a/src/Dev/Deprecation.php +++ b/src/Dev/Deprecation.php @@ -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) { diff --git a/tests/php/Dev/DeprecationTest.php b/tests/php/Dev/DeprecationTest.php index 03f0154fd48..811e2ca70b6 100644 --- a/tests/php/Dev/DeprecationTest.php +++ b/tests/php/Dev/DeprecationTest.php @@ -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); diff --git a/tests/php/ORM/Search/SearchContextTest.php b/tests/php/ORM/Search/SearchContextTest.php index ec475c3c299..a3c245d0cc4 100644 --- a/tests/php/ORM/Search/SearchContextTest.php +++ b/tests/php/ORM/Search/SearchContextTest.php @@ -138,16 +138,36 @@ public function testUserDefinedFiltersAppearInSearchContext() public function testUserDefinedFieldsAppearInSearchContext() { $company = SearchContextTest\Company::singleton(); + $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 ); }