diff --git a/src/Control/Director.php b/src/Control/Director.php index 91023b7a76f..8805612531a 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -228,7 +228,7 @@ public static function mockRequest( ? $cookies : Injector::inst()->createWithArgs(Cookie_Backend::class, [$cookies ?: []]); $newVars['_COOKIE'] = $cookieJar->getAll(false); - Cookie::config()->update('report_errors', false); + Cookie::config()->set('report_errors', false); Injector::inst()->registerService($cookieJar, Cookie_Backend::class); // Backup requirements diff --git a/src/Control/Middleware/FlushMiddleware.php b/src/Control/Middleware/FlushMiddleware.php index e3bd61fbebb..98b49423b12 100644 --- a/src/Control/Middleware/FlushMiddleware.php +++ b/src/Control/Middleware/FlushMiddleware.php @@ -2,10 +2,12 @@ namespace SilverStripe\Control\Middleware; -use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; +use SilverStripe\Core\BaseKernel; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Flushable; +use SilverStripe\Core\Injector\Injector; +use SilverStripe\Core\Kernel; /** * Triggers a call to flush() on all implementors of Flushable. @@ -14,7 +16,9 @@ class FlushMiddleware implements HTTPMiddleware { public function process(HTTPRequest $request, callable $delegate) { - if (Director::isManifestFlushed()) { + /** @var BaseKernel $kernel */ + $kernel = Injector::inst()->get(Kernel::class); + if ((method_exists($kernel, 'isFlushed') && $kernel->isFlushed())) { // Disable cache when flushing HTTPCacheControlMiddleware::singleton()->disableCache(true); diff --git a/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php b/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php index 6f189286edc..f2b62d0c267 100644 --- a/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php +++ b/src/Control/Middleware/URLSpecialsMiddleware/FlushScheduler.php @@ -2,10 +2,10 @@ namespace SilverStripe\Control\Middleware\URLSpecialsMiddleware; +use SilverStripe\Core\BaseKernel; use SilverStripe\Core\Kernel; use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Startup\ScheduledFlushDiscoverer; -use SilverStripe\Control\Director; use SilverStripe\Control\HTTPRequest; /** @@ -30,11 +30,12 @@ public function scheduleFlush(HTTPRequest $request) { $flush = array_key_exists('flush', $request->getVars() ?? []) || ($request->getURL() === 'dev/build'); - if (!$flush || Director::isManifestFlushed()) { + /** @var BaseKernel $kernel */ + $kernel = Injector::inst()->get(Kernel::class); + if (!$flush || (method_exists($kernel, 'isFlushed') && $kernel->isFlushed())) { return false; } - $kernel = Injector::inst()->get(Kernel::class); ScheduledFlushDiscoverer::scheduleFlush($kernel); return true; diff --git a/src/Control/RSS/RSSFeed.php b/src/Control/RSS/RSSFeed.php index fd35b617ed5..5ab5eae9b74 100644 --- a/src/Control/RSS/RSSFeed.php +++ b/src/Control/RSS/RSSFeed.php @@ -222,7 +222,7 @@ public function Description() public function outputToBrowser() { $prevState = SSViewer::config()->uninherited('source_file_comments'); - SSViewer::config()->update('source_file_comments', false); + SSViewer::config()->set('source_file_comments', false); $response = Controller::curr()->getResponse(); @@ -236,7 +236,7 @@ public function outputToBrowser() $response->addHeader("Content-Type", "application/rss+xml; charset=utf-8"); - SSViewer::config()->update('source_file_comments', $prevState); + SSViewer::config()->set('source_file_comments', $prevState); return $this->renderWith($this->getTemplates()); } diff --git a/src/Core/BaseKernel.php b/src/Core/BaseKernel.php index ee3370d54ad..41ace97c5b6 100644 --- a/src/Core/BaseKernel.php +++ b/src/Core/BaseKernel.php @@ -259,12 +259,9 @@ protected function bootErrorHandling() * Get the environment type * * @return string - * - * @deprecated 4.12.0 Use Director::get_environment_type() instead */ public function getEnvironment() { - Deprecation::notice('4.12.0', 'Use Director::get_environment_type() instead'); // Check set if ($this->enviroment) { return $this->enviroment; @@ -288,12 +285,9 @@ public function getEnvironment() * Check or update any temporary environment specified in the session. * * @return null|string - * - * @deprecated 4.12.0 Use Director::get_session_environment_type() instead */ protected function sessionEnvironment() { - Deprecation::notice('4.12.0', 'Use Director::get_session_environment_type() instead'); if (!$this->booted) { // session is not initialyzed yet, neither is manifest return null; diff --git a/src/Dev/Deprecation.php b/src/Dev/Deprecation.php index 5bd17cda6d0..29afa9038b9 100644 --- a/src/Dev/Deprecation.php +++ b/src/Dev/Deprecation.php @@ -179,7 +179,7 @@ public static function get_enabled() // noop } - private static function get_is_enabled(): bool + public static function get_is_enabled(): bool { if (!Director::isDev()) { return false; diff --git a/src/Dev/FunctionalTest.php b/src/Dev/FunctionalTest.php index c0329c355bb..dc1d16778b0 100644 --- a/src/Dev/FunctionalTest.php +++ b/src/Dev/FunctionalTest.php @@ -115,7 +115,7 @@ protected function setUp(): void // Disable theme, if necessary if (static::get_disable_themes()) { - SSViewer::config()->update('theme_enabled', false); + SSViewer::config()->set('theme_enabled', false); } // Flush user @@ -560,7 +560,7 @@ protected function setUp() // Disable theme, if necessary if (static::get_disable_themes()) { - SSViewer::config()->update('theme_enabled', false); + SSViewer::config()->set('theme_enabled', false); } // Flush user diff --git a/src/Dev/SapphireTest.php b/src/Dev/SapphireTest.php index d7b08afc984..2c9f40f3927 100644 --- a/src/Dev/SapphireTest.php +++ b/src/Dev/SapphireTest.php @@ -329,7 +329,7 @@ protected function setUp(): void } if (class_exists(Cookie::class)) { - Cookie::config()->update('report_errors', false); + Cookie::config()->set('report_errors', false); } if (class_exists(RootURLController::class)) { @@ -356,7 +356,7 @@ protected function setUp(): void // turn off template debugging if (class_exists(SSViewer::class)) { - SSViewer::config()->update('source_file_comments', false); + SSViewer::config()->set('source_file_comments', false); } // Set up the test mailer @@ -1206,7 +1206,7 @@ protected function useTestTheme($themeBaseDir, $theme, $callback) if (strpos($themeBaseDir ?? '', BASE_PATH) === 0) { $themeBaseDir = substr($themeBaseDir ?? '', strlen(BASE_PATH)); } - SSViewer::config()->update('theme_enabled', true); + SSViewer::config()->set('theme_enabled', true); SSViewer::set_themes([$themeBaseDir . '/themes/' . $theme, '$default']); try { @@ -1649,7 +1649,7 @@ protected function setUp() } if (class_exists(Cookie::class)) { - Cookie::config()->update('report_errors', false); + Cookie::config()->set('report_errors', false); } if (class_exists(RootURLController::class)) { @@ -1676,7 +1676,7 @@ protected function setUp() // turn off template debugging if (class_exists(SSViewer::class)) { - SSViewer::config()->update('source_file_comments', false); + SSViewer::config()->set('source_file_comments', false); } // Set up the test mailer @@ -2556,7 +2556,7 @@ protected function useTestTheme($themeBaseDir, $theme, $callback) if (strpos($themeBaseDir ?? '', BASE_PATH) === 0) { $themeBaseDir = substr($themeBaseDir ?? '', strlen(BASE_PATH)); } - SSViewer::config()->update('theme_enabled', true); + SSViewer::config()->set('theme_enabled', true); SSViewer::set_themes([$themeBaseDir . '/themes/' . $theme, '$default']); try { diff --git a/src/Forms/GridField/GridFieldAddExistingAutocompleter.php b/src/Forms/GridField/GridFieldAddExistingAutocompleter.php index d8efa590341..ff6176d9276 100644 --- a/src/Forms/GridField/GridFieldAddExistingAutocompleter.php +++ b/src/Forms/GridField/GridFieldAddExistingAutocompleter.php @@ -262,7 +262,7 @@ public function doSearch($gridField, $request) $json = []; Config::nest(); - SSViewer::config()->update('source_file_comments', false); + SSViewer::config()->set('source_file_comments', false); $viewer = SSViewer::fromString($this->resultsFormat); foreach ($results as $result) { $title = Convert::html2raw($viewer->process($result)); diff --git a/src/ORM/Connect/DBSchemaManager.php b/src/ORM/Connect/DBSchemaManager.php index 698f17cd52c..6bfee6b03b7 100644 --- a/src/ORM/Connect/DBSchemaManager.php +++ b/src/ORM/Connect/DBSchemaManager.php @@ -60,12 +60,9 @@ abstract class DBSchemaManager /** * @param string $table * @param string $class - * - * @deprecated 4.0.1 Will be removed without equivalent functionality */ public static function showTableNameWarning($table, $class) { - Deprecation::notice('4.0.1', 'Will be removed without equivalent functionality'); static::$table_name_warnings[$table] = $class; } diff --git a/tests/php/Control/ControllerTest.php b/tests/php/Control/ControllerTest.php index def255c6bf6..34559386e9b 100644 --- a/tests/php/Control/ControllerTest.php +++ b/tests/php/Control/ControllerTest.php @@ -45,7 +45,7 @@ class ControllerTest extends FunctionalTest protected function setUp(): void { parent::setUp(); - Director::config()->update('alternate_base_url', '/'); + Director::config()->set('alternate_base_url', '/'); // Add test theme $themeDir = substr(__DIR__, strlen(FRAMEWORK_DIR)) . '/ControllerTest/'; diff --git a/tests/php/Control/DirectorTest.php b/tests/php/Control/DirectorTest.php index 05e24046bd9..bb797f7d4bf 100644 --- a/tests/php/Control/DirectorTest.php +++ b/tests/php/Control/DirectorTest.php @@ -16,6 +16,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Environment; use SilverStripe\Core\Kernel; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; /** @@ -856,6 +857,9 @@ public function testTestIgnoresHashes() public function testRequestFilterInDirectorTest() { + if (Deprecation::get_is_enabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $filter = new DirectorTest\TestRequestFilter; $processor = new RequestProcessor([$filter]); diff --git a/tests/php/Control/Email/EmailTest.php b/tests/php/Control/Email/EmailTest.php index daa69ae41fb..462d51f1b82 100644 --- a/tests/php/Control/Email/EmailTest.php +++ b/tests/php/Control/Email/EmailTest.php @@ -271,7 +271,7 @@ public function testGetSwiftMessage() public function testSetSwiftMessage() { - Email::config()->update('admin_email', 'admin@example.com'); + Email::config()->set('admin_email', 'admin@example.com'); DBDatetime::set_mock_now('2017-01-01 07:00:00'); $email = new Email(); $swiftMessage = new Swift_Message(); @@ -294,7 +294,7 @@ public function testSetSwiftMessage() public function testAdminEmailApplied() { - Email::config()->update('admin_email', 'admin@example.com'); + Email::config()->set('admin_email', 'admin@example.com'); $email = new Email(); $this->assertCount(1, $email->getFrom()); diff --git a/tests/php/Control/Email/SwiftMailerTest.php b/tests/php/Control/Email/SwiftMailerTest.php index 43a7f98d141..51161a52bdd 100644 --- a/tests/php/Control/Email/SwiftMailerTest.php +++ b/tests/php/Control/Email/SwiftMailerTest.php @@ -21,7 +21,7 @@ public function testSwiftMailer() $this->assertEquals($swift, $mailer->getSwiftMailer()); SwiftMailer::config()->remove('swift_plugins'); - SwiftMailer::config()->update('swift_plugins', [Swift_Plugins_AntiFloodPlugin::class]); + SwiftMailer::config()->merge('swift_plugins', [Swift_Plugins_AntiFloodPlugin::class]); /** @var Swift_MailTransport $transport */ $transport = $this->getMockBuilder(Swift_MailTransport::class)->getMock(); diff --git a/tests/php/Control/Email/SwiftPluginTest.php b/tests/php/Control/Email/SwiftPluginTest.php index 5ca702d8efd..231e6a5235c 100644 --- a/tests/php/Control/Email/SwiftPluginTest.php +++ b/tests/php/Control/Email/SwiftPluginTest.php @@ -39,7 +39,7 @@ protected function getMailer() public function testSendAllEmailsTo() { - Email::config()->update('send_all_emails_to', 'to@example.com'); + Email::config()->set('send_all_emails_to', 'to@example.com'); $email = $this->getEmail(); $this->getMailer()->send($email->getSwiftMessage()); $headers = $email->getSwiftMessage()->getHeaders(); @@ -68,7 +68,7 @@ public function testSendAllEmailsTo() public function testSendAllEmailsFrom() { - Email::config()->update('send_all_emails_from', 'from@example.com'); + Email::config()->set('send_all_emails_from', 'from@example.com'); $email = $this->getEmail(); $this->getMailer()->send($email->getSwiftMessage()); @@ -88,7 +88,7 @@ public function testSendAllEmailsFrom() public function testCCAllEmailsTo() { - Email::config()->update('cc_all_emails_to', 'cc@example.com'); + Email::config()->set('cc_all_emails_to', 'cc@example.com'); $email = $this->getEmail(); $this->getMailer()->send($email->getSwiftMessage()); @@ -99,7 +99,7 @@ public function testCCAllEmailsTo() public function testBCCAllEmailsTo() { - Email::config()->update('bcc_all_emails_to', 'bcc@example.com'); + Email::config()->set('bcc_all_emails_to', 'bcc@example.com'); $email = $this->getEmail(); $this->getMailer()->send($email->getSwiftMessage()); diff --git a/tests/php/Control/HTTPRequestTest.php b/tests/php/Control/HTTPRequestTest.php index cf0acc0ca32..15d750775d2 100644 --- a/tests/php/Control/HTTPRequestTest.php +++ b/tests/php/Control/HTTPRequestTest.php @@ -6,6 +6,7 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\Middleware\TrustedProxyMiddleware; use SilverStripe\Control\Session; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; class HTTPRequestTest extends SapphireTest @@ -155,12 +156,18 @@ public function detectMethodDataProvider() */ public function testDetectMethod($realMethod, $post, $expected) { + if (Deprecation::get_is_enabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $actual = HTTPRequest::detect_method($realMethod, $post); $this->assertEquals($expected, $actual); } public function testBadDetectMethod() { + if (Deprecation::get_is_enabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } $this->expectException(\InvalidArgumentException::class); HTTPRequest::detect_method('POST', ['_method' => 'Boom']); } diff --git a/tests/php/Control/SessionTest.php b/tests/php/Control/SessionTest.php index e3739644853..e0b4d4c4943 100644 --- a/tests/php/Control/SessionTest.php +++ b/tests/php/Control/SessionTest.php @@ -107,7 +107,7 @@ public function testStartUsesSecureCookieNameWithHttpsAndCookieSecureOn() ->setScheme('https'); Cookie::set(session_name(), '1234'); $session = new Session(null); // unstarted session - $session->config()->update('cookie_secure', true); + $session->config()->set('cookie_secure', true); $session->start($req); $this->assertEquals(session_name(), $session->config()->get('cookie_name_secure')); } @@ -270,7 +270,7 @@ public function testRequestContainsSessionIdRespectsCookieNameSecure() ->setScheme('https'); $session = new Session(null); // unstarted session Cookie::set($session->config()->get('cookie_name_secure'), '1234'); - $session->config()->update('cookie_secure', true); + $session->config()->set('cookie_secure', true); $this->assertTrue($session->requestContainsSessionId($req)); } diff --git a/tests/php/Core/ConvertTest.php b/tests/php/Core/ConvertTest.php index 6522fb39e61..b6a198ba1df 100644 --- a/tests/php/Core/ConvertTest.php +++ b/tests/php/Core/ConvertTest.php @@ -264,7 +264,7 @@ public function testJSON2Obj() */ public function testRaw2URL() { - URLSegmentFilter::config()->update('default_allow_multibyte', false); + URLSegmentFilter::config()->set('default_allow_multibyte', false); $this->assertEquals('foo', Convert::raw2url('foo')); $this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar')); $this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar!')); diff --git a/tests/php/Dev/BacktraceTest.php b/tests/php/Dev/BacktraceTest.php index de44410d1ae..d1f5fe98d24 100644 --- a/tests/php/Dev/BacktraceTest.php +++ b/tests/php/Dev/BacktraceTest.php @@ -59,7 +59,7 @@ public function testIgnoredFunctionArgs() 'args' => ['myarg' => 'myval'] ] ]; - Backtrace::config()->update( + Backtrace::config()->merge( 'ignore_function_args', [ ['MyClass', 'myIgnoredClassFunction'], @@ -101,7 +101,7 @@ public function testFilteredWildCard() 'args' => ['myarg' => 'myval'] ] ]; - Backtrace::config()->update( + Backtrace::config()->merge( 'ignore_function_args', [ ['*', 'myIgnoredClassFunction'], diff --git a/tests/php/Dev/DeprecationTest.php b/tests/php/Dev/DeprecationTest.php index ed601871404..016862d3ae3 100644 --- a/tests/php/Dev/DeprecationTest.php +++ b/tests/php/Dev/DeprecationTest.php @@ -16,6 +16,8 @@ class DeprecationTest extends SapphireTest private $oldHandler = null; + private bool $noticesWereEnabled = false; + protected function setup(): void { // Use custom error handler for two reasons: @@ -23,6 +25,7 @@ protected function setup(): void // - Allow the use of expectDeprecation(), which doesn't work with E_USER_DEPRECATION by default // https://github.com/laminas/laminas-di/pull/30#issuecomment-927585210 parent::setup(); + $this->noticesWereEnabled = Deprecation::get_is_enabled(); $this->oldHandler = set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { if ($errno === E_USER_DEPRECATED) { if (str_contains($errstr, 'SilverStripe\\Dev\\Tests\\DeprecationTest')) { @@ -42,7 +45,9 @@ protected function setup(): void protected function tearDown(): void { - Deprecation::disable(); + if (!$this->noticesWereEnabled) { + Deprecation::disable(); + } set_error_handler($this->oldHandler); $this->oldHandler = null; parent::tearDown(); diff --git a/tests/php/Dev/DevAdminControllerTest.php b/tests/php/Dev/DevAdminControllerTest.php index 8a64b3f71ad..60e93fed0a5 100644 --- a/tests/php/Dev/DevAdminControllerTest.php +++ b/tests/php/Dev/DevAdminControllerTest.php @@ -18,7 +18,7 @@ protected function setUp(): void { parent::setUp(); - DevelopmentAdmin::config()->update( + DevelopmentAdmin::config()->merge( 'registered_controllers', [ 'x1' => [ diff --git a/tests/php/Forms/CurrencyFieldDisabledTest.php b/tests/php/Forms/CurrencyFieldDisabledTest.php index 6f1cc0c70c2..d02e1375aa0 100644 --- a/tests/php/Forms/CurrencyFieldDisabledTest.php +++ b/tests/php/Forms/CurrencyFieldDisabledTest.php @@ -23,7 +23,7 @@ public function testFieldWithValue() */ public function testFieldWithCustomisedCurrencySymbol() { - DBCurrency::config()->update('currency_symbol', '€'); + DBCurrency::config()->set('currency_symbol', '€'); $field = new CurrencyField_Disabled('Test', '', '€5.00'); $result = $field->Field(); diff --git a/tests/php/Forms/CurrencyFieldReadonlyTest.php b/tests/php/Forms/CurrencyFieldReadonlyTest.php index 0c998a8ef68..352b97f82c7 100644 --- a/tests/php/Forms/CurrencyFieldReadonlyTest.php +++ b/tests/php/Forms/CurrencyFieldReadonlyTest.php @@ -28,7 +28,7 @@ public function testFieldWithValue() public function testFieldWithOutValue() { - DBCurrency::config()->update('currency_symbol', 'AUD'); + DBCurrency::config()->set('currency_symbol', 'AUD'); $field = new CurrencyField_Readonly('Test', '', null); $result = $field->Field(); @@ -42,7 +42,7 @@ public function testFieldWithOutValue() */ public function testFieldWithCustomisedCurrencySymbol() { - DBCurrency::config()->update('currency_symbol', '€'); + DBCurrency::config()->set('currency_symbol', '€'); $field = new CurrencyField_Readonly('Test', '', '€5.00'); $result = $field->Field(); diff --git a/tests/php/Forms/CurrencyFieldTest.php b/tests/php/Forms/CurrencyFieldTest.php index 02c4114e4d1..050f89f70a8 100644 --- a/tests/php/Forms/CurrencyFieldTest.php +++ b/tests/php/Forms/CurrencyFieldTest.php @@ -67,7 +67,7 @@ public function testValidate() ); //tests with updated currency symbol setting - DBCurrency::config()->update('currency_symbol', '€'); + DBCurrency::config()->set('currency_symbol', '€'); $f->setValue('123.45'); $this->assertTrue( @@ -180,7 +180,7 @@ public function testSetValue() ); //update currency symbol via config - DBCurrency::config()->update('currency_symbol', '€'); + DBCurrency::config()->set('currency_symbol', '€'); $f->setValue('123.45'); $this->assertEquals( @@ -263,7 +263,7 @@ public function testDataValue() ); //tests with updated currency symbol setting - DBCurrency::config()->update('currency_symbol', '€'); + DBCurrency::config()->set('currency_symbol', '€'); $f->setValue('€123.45'); $this->assertEquals( @@ -302,7 +302,7 @@ public function testInvalidCurrencySymbol() $field = new CurrencyField('Test', '', '$5.00'); $validator = new RequiredFields(); - DBCurrency::config()->update('currency_symbol', '€'); + DBCurrency::config()->set('currency_symbol', '€'); $result = $field->validate($validator); $this->assertFalse($result, 'Validation should fail since wrong currency was used'); diff --git a/tests/php/Forms/FormFieldTest.php b/tests/php/Forms/FormFieldTest.php index f633e6792e8..47a3ff94614 100644 --- a/tests/php/Forms/FormFieldTest.php +++ b/tests/php/Forms/FormFieldTest.php @@ -31,7 +31,7 @@ public function testDefaultClasses() { Config::nest(); - FormField::config()->update( + FormField::config()->merge( 'default_classes', [ 'class1', @@ -42,7 +42,7 @@ public function testDefaultClasses() $this->assertStringContainsString('class1', $field->extraClass(), 'Class list does not contain expected class'); - FormField::config()->update( + FormField::config()->merge( 'default_classes', [ 'class1', @@ -54,7 +54,7 @@ public function testDefaultClasses() $this->assertStringContainsString('class1 class2', $field->extraClass(), 'Class list does not contain expected class'); - FormField::config()->update( + FormField::config()->merge( 'default_classes', [ 'class3', @@ -69,7 +69,7 @@ public function testDefaultClasses() $this->assertStringNotContainsString('class3', $field->extraClass(), 'Class list contains unexpected class'); - TextField::config()->update( + TextField::config()->merge( 'default_classes', [ 'textfield-class', diff --git a/tests/php/Forms/FormTest.php b/tests/php/Forms/FormTest.php index 140db87fb59..34689f4877c 100644 --- a/tests/php/Forms/FormTest.php +++ b/tests/php/Forms/FormTest.php @@ -792,7 +792,7 @@ public function testRemoveManyExtraClasses() public function testDefaultClasses() { - Form::config()->update( + Form::config()->merge( 'default_classes', [ 'class1', @@ -803,7 +803,7 @@ public function testDefaultClasses() $this->assertStringContainsString('class1', $form->extraClass(), 'Class list does not contain expected class'); - Form::config()->update( + Form::config()->merge( 'default_classes', [ 'class1', @@ -815,7 +815,7 @@ public function testDefaultClasses() $this->assertStringContainsString('class1 class2', $form->extraClass(), 'Class list does not contain expected class'); - Form::config()->update( + Form::config()->merge( 'default_classes', [ 'class3', diff --git a/tests/php/ORM/DataObjectSchemaGenerationTest.php b/tests/php/ORM/DataObjectSchemaGenerationTest.php index 95e0aa98a97..b8a3d30bc81 100644 --- a/tests/php/ORM/DataObjectSchemaGenerationTest.php +++ b/tests/php/ORM/DataObjectSchemaGenerationTest.php @@ -101,7 +101,7 @@ public function testFieldsRequestChanges() // Table will have been initially created by the $extraDataObjects setting // Let's insert a new field here - TestObject::config()->update( + TestObject::config()->merge( 'db', [ 'SecretField' => 'Varchar(100)' @@ -170,7 +170,7 @@ public function testIndexesRerequestChanges() // Table will have been initially created by the $extraDataObjects setting // Update the SearchFields index here - TestIndexObject::config()->update( + TestIndexObject::config()->merge( 'indexes', [ 'SearchFields' => [ @@ -265,35 +265,35 @@ public function testSortFieldBecomeIndexes() 'columns' => ['Sort'], ], $indexes); DataObject::getSchema()->reset(); - Config::inst()->update(SortedObject::class, 'default_sort', 'Sort ASC'); + Config::inst()->set(SortedObject::class, 'default_sort', 'Sort ASC'); $indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class); $this->assertContains([ 'type' => 'index', 'columns' => ['Sort'], ], $indexes); DataObject::getSchema()->reset(); - Config::inst()->update(SortedObject::class, 'default_sort', 'Sort DESC'); + Config::inst()->set(SortedObject::class, 'default_sort', 'Sort DESC'); $indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class); $this->assertContains([ 'type' => 'index', 'columns' => ['Sort'], ], $indexes); DataObject::getSchema()->reset(); - Config::inst()->update(SortedObject::class, 'default_sort', '"Sort" DESC'); + Config::inst()->set(SortedObject::class, 'default_sort', '"Sort" DESC'); $indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class); $this->assertContains([ 'type' => 'index', 'columns' => ['Sort'], ], $indexes); DataObject::getSchema()->reset(); - Config::inst()->update(SortedObject::class, 'default_sort', '"DataObjectSchemaGenerationTest_SortedObject"."Sort" ASC'); + Config::inst()->set(SortedObject::class, 'default_sort', '"DataObjectSchemaGenerationTest_SortedObject"."Sort" ASC'); $indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class); $this->assertContains([ 'type' => 'index', 'columns' => ['Sort'], ], $indexes); DataObject::getSchema()->reset(); - Config::inst()->update(SortedObject::class, 'default_sort', '"Sort" DESC, "Title" ASC'); + Config::inst()->set(SortedObject::class, 'default_sort', '"Sort" DESC, "Title" ASC'); $indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class); $this->assertContains([ 'type' => 'index', @@ -305,7 +305,7 @@ public function testSortFieldBecomeIndexes() ], $indexes); DataObject::getSchema()->reset(); // make sure that specific indexes aren't overwritten - Config::inst()->update(SortedObject::class, 'indexes', [ + Config::inst()->merge(SortedObject::class, 'indexes', [ 'Sort' => [ 'type' => 'unique', 'columns' => ['Sort'], diff --git a/tests/php/ORM/HierarchyCachingTest.php b/tests/php/ORM/HierarchyCachingTest.php index afbd488c27e..8070fbe26d7 100644 --- a/tests/php/ORM/HierarchyCachingTest.php +++ b/tests/php/ORM/HierarchyCachingTest.php @@ -37,7 +37,7 @@ protected function setUp(): void public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - HideTestObject::config()->update( + HideTestObject::config()->merge( 'hide_from_hierarchy', [ HideTestSubObject::class ] ); diff --git a/tests/php/ORM/HierarchyTest.php b/tests/php/ORM/HierarchyTest.php index 697fc7c2ffa..c3d2e0b1258 100644 --- a/tests/php/ORM/HierarchyTest.php +++ b/tests/php/ORM/HierarchyTest.php @@ -273,7 +273,7 @@ public function testNoHideFromHierarchy() public function testHideFromHierarchy() { - HierarchyTest\HideTestObject::config()->update( + HierarchyTest\HideTestObject::config()->merge( 'hide_from_hierarchy', [ HierarchyTest\HideTestSubObject::class ] ); diff --git a/tests/php/ORM/ManyManyListTest.php b/tests/php/ORM/ManyManyListTest.php index f7b4dd5b518..2dd852b62a8 100644 --- a/tests/php/ORM/ManyManyListTest.php +++ b/tests/php/ORM/ManyManyListTest.php @@ -423,7 +423,7 @@ public function testSortByExtraFieldsDefaultSort() $obj->Clients()->add($obj2, ['Worth' => $money, 'Reference' => 'B']); // Set the default sort for this relation - Config::inst()->update('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference ASC'); + Config::inst()->set('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference ASC'); $clients = $obj->Clients(); $this->assertCount(2, $clients); @@ -432,7 +432,7 @@ public function testSortByExtraFieldsDefaultSort() $this->assertEquals('B', $second->Reference); // Now we ensure the default sort is being respected by reversing its order - Config::inst()->update('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference DESC'); + Config::inst()->set('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference DESC'); $reverseClients = $obj->Clients(); $this->assertCount(2, $reverseClients); diff --git a/tests/php/ORM/ManyManyThroughListTest.php b/tests/php/ORM/ManyManyThroughListTest.php index 2d9cb890803..26211d7c207 100644 --- a/tests/php/ORM/ManyManyThroughListTest.php +++ b/tests/php/ORM/ManyManyThroughListTest.php @@ -268,7 +268,7 @@ public function testValidateModelValidatesJoinType() { $this->expectException(\InvalidArgumentException::class); DataObject::reset(); - ManyManyThroughListTest\Item::config()->update( + ManyManyThroughListTest\Item::config()->merge( 'db', [ ManyManyThroughListTest\JoinObject::class => 'Text' @@ -416,7 +416,7 @@ public function testDefaultSortOnJoinAndMain() $this->assertSame('International', $second->Title); // Ensure that we're respecting the default sort by reversing it - Config::inst()->update(FallbackLocale::class, 'default_sort', '"ManyManyThroughTest_FallbackLocale"."Sort" DESC'); + Config::inst()->set(FallbackLocale::class, 'default_sort', '"ManyManyThroughTest_FallbackLocale"."Sort" DESC'); $reverse = $mexico->Fallbacks(); list($firstReverse, $secondReverse) = $reverse; diff --git a/tests/php/ORM/SQLSelectTest.php b/tests/php/ORM/SQLSelectTest.php index f3618ebe09a..f58d538e2e3 100755 --- a/tests/php/ORM/SQLSelectTest.php +++ b/tests/php/ORM/SQLSelectTest.php @@ -24,18 +24,6 @@ class SQLSelectTest extends SapphireTest protected $oldDeprecation = null; - protected function setUp(): void - { - parent::setUp(); - $this->oldDeprecation = Deprecation::dump_settings(); - } - - protected function tearDown(): void - { - Deprecation::restore_settings($this->oldDeprecation); - parent::tearDown(); - } - public function testCount() { diff --git a/tests/php/ORM/TransactionTest.php b/tests/php/ORM/TransactionTest.php index 8c524e78c6d..8ac60e5b510 100644 --- a/tests/php/ORM/TransactionTest.php +++ b/tests/php/ORM/TransactionTest.php @@ -20,18 +20,6 @@ class TransactionTest extends SapphireTest private static $originalVersionInfo; - protected function setUp(): void - { - parent::setUp(); - self::$originalVersionInfo = Deprecation::dump_settings(); - } - - protected function tearDown(): void - { - Deprecation::restore_settings(self::$originalVersionInfo); - parent::tearDown(); - } - public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/php/Security/MemberTest.php b/tests/php/Security/MemberTest.php index 62454b56d79..53e1875b4c9 100644 --- a/tests/php/Security/MemberTest.php +++ b/tests/php/Security/MemberTest.php @@ -219,7 +219,7 @@ public function testPasswordChangeLogging() */ public function testChangedPasswordEmaling() { - Member::config()->update('notify_password_change', true); + Member::config()->set('notify_password_change', true); $this->clearEmails(); @@ -1187,7 +1187,7 @@ public function testRememberMeMultipleDevices() $this->assertStringContainsString($message, $response->getBody()); // Logging out from the second device - only one device being logged out - RememberLoginHash::config()->update('logout_across_devices', false); + RememberLoginHash::config()->set('logout_across_devices', false); $this->get( 'Security/logout', $this->session(), @@ -1205,7 +1205,7 @@ public function testRememberMeMultipleDevices() // If session-manager module is installed then logout_across_devices is modified so skip if (!class_exists(LoginSession::class)) { // Logging out from any device when all login hashes should be removed - RememberLoginHash::config()->update('logout_across_devices', true); + RememberLoginHash::config()->set('logout_across_devices', true); Injector::inst()->get(IdentityStore::class)->logIn($m1, true); $this->get('Security/logout', $this->session()); $this->assertEquals( @@ -1248,7 +1248,7 @@ public function testFailedLoginCount() { $maxFailedLoginsAllowed = 3; //set up the config variables to enable login lockouts - Member::config()->update('lock_out_after_incorrect_logins', $maxFailedLoginsAllowed); + Member::config()->set('lock_out_after_incorrect_logins', $maxFailedLoginsAllowed); /** @var Member $member */ $member = $this->objFromFixture(Member::class, 'test'); @@ -1282,7 +1282,7 @@ public function testFailedLoginCountNegative() public function testMemberValidator() { // clear custom requirements for this test - Member_Validator::config()->update('customRequired', null); + Member_Validator::config()->set('customRequired', null); /** @var Member $memberA */ $memberA = $this->objFromFixture(Member::class, 'admin'); /** @var Member $memberB */ @@ -1358,7 +1358,7 @@ public function testMemberValidator() public function testMemberValidatorWithExtensions() { // clear custom requirements for this test - Member_Validator::config()->update('customRequired', null); + Member_Validator::config()->set('customRequired', null); // create a blank form $form = new MemberTest\ValidatorForm(); @@ -1422,7 +1422,7 @@ public function testMemberValidatorWithExtensions() public function testCustomMemberValidator() { // clear custom requirements for this test - Member_Validator::config()->update('customRequired', null); + Member_Validator::config()->set('customRequired', null); $member = $this->objFromFixture(Member::class, 'admin'); diff --git a/tests/php/View/ArrayDataTest.php b/tests/php/View/ArrayDataTest.php index b90258f7947..c7c7599b6b9 100644 --- a/tests/php/View/ArrayDataTest.php +++ b/tests/php/View/ArrayDataTest.php @@ -67,9 +67,6 @@ public function testSetField() public function testGetArray() { - $originalDeprecation = Deprecation::dump_settings(); - Deprecation::notification_version('2.4'); - $array = [ 'Foo' => 'Foo', 'Bar' => 'Bar', @@ -79,8 +76,6 @@ public function testGetArray() $arrayData = new ArrayData($array); $this->assertEquals($arrayData->toMap(), $array); - - Deprecation::restore_settings($originalDeprecation); } public function testArrayToObject() diff --git a/tests/php/View/SSViewerTest.php b/tests/php/View/SSViewerTest.php index cd1fe076cb7..1e460704455 100644 --- a/tests/php/View/SSViewerTest.php +++ b/tests/php/View/SSViewerTest.php @@ -53,8 +53,8 @@ class SSViewerTest extends SapphireTest protected function setUp(): void { parent::setUp(); - SSViewer::config()->update('source_file_comments', false); - SSViewer_FromString::config()->update('cache_template', false); + SSViewer::config()->set('source_file_comments', false); + SSViewer_FromString::config()->set('cache_template', false); TestAssetStore::activate('SSViewerTest'); $this->oldServer = $_SERVER; } @@ -73,7 +73,7 @@ protected function tearDown(): void */ public function testCurrentTheme() { - SSViewer::config()->update('theme', 'mytheme'); + SSViewer::config()->set('theme', 'mytheme'); $this->assertEquals( 'mytheme', SSViewer::config()->uninherited('theme'), @@ -1819,7 +1819,7 @@ public function testRewriteHashlinksInPhpMode() public function testRenderWithSourceFileComments() { - SSViewer::config()->update('source_file_comments', true); + SSViewer::config()->set('source_file_comments', true); $i = __DIR__ . '/SSViewerTest/templates/Includes'; $f = __DIR__ . '/SSViewerTest/templates/SSViewerTestComments'; $templates = [ @@ -2099,7 +2099,7 @@ public function testFromStringCaching() $this->render($content, null, null); $this->assertFalse(file_exists($cacheFile ?? ''), 'Cache file was created when caching was off'); - SSViewer_FromString::config()->update('cache_template', true); + SSViewer_FromString::config()->set('cache_template', true); $this->render($content, null, null); $this->assertTrue(file_exists($cacheFile ?? ''), 'Cache file wasn\'t created when it was meant to'); unlink($cacheFile ?? ''); diff --git a/tests/php/i18n/i18nTest.php b/tests/php/i18n/i18nTest.php index 08065a54342..79882c9407f 100644 --- a/tests/php/i18n/i18nTest.php +++ b/tests/php/i18n/i18nTest.php @@ -149,7 +149,7 @@ public function testProvideI18nEntities() public function testTemplateTranslation() { $oldLocale = i18n::get_locale(); - i18n::config()->update('missing_default_warning', false); + i18n::config()->set('missing_default_warning', false); /** @var SymfonyMessageProvider $provider */ $provider = Injector::inst()->get(MessageProvider::class); @@ -311,7 +311,7 @@ public function testNewTMethodSignature() * */ public function testNewTemplateTranslation() { - i18n::config()->update('missing_default_warning', false); + i18n::config()->set('missing_default_warning', false); /** @var SymfonyMessageProvider $provider */ $provider = Injector::inst()->get(MessageProvider::class); @@ -468,7 +468,7 @@ public function testPluralisation($locale, $count, $expected) public function testGetLanguageName() { - i18n::config()->update( + i18n::config()->merge( 'common_languages', ['de_CGN' => ['name' => 'German (Cologne)', 'native' => 'Kölsch']] ); diff --git a/tests/php/i18n/i18nTestManifest.php b/tests/php/i18n/i18nTestManifest.php index 3a06f06cedb..b08c91a548b 100644 --- a/tests/php/i18n/i18nTestManifest.php +++ b/tests/php/i18n/i18nTestManifest.php @@ -82,7 +82,7 @@ public function setupManifest() // Switch to test manifest $s = DIRECTORY_SEPARATOR; $this->alternateBasePath = __DIR__ . $s . 'i18nTest' . $s . "_fakewebroot"; - Director::config()->update('alternate_base_folder', $this->alternateBasePath); + Director::config()->set('alternate_base_folder', $this->alternateBasePath); // New module manifest $moduleManifest = new ModuleManifest($this->alternateBasePath); diff --git a/tests/php/i18n/i18nTextCollectorTest.php b/tests/php/i18n/i18nTextCollectorTest.php index 6812c9cc6fe..c79bdddaa3a 100644 --- a/tests/php/i18n/i18nTextCollectorTest.php +++ b/tests/php/i18n/i18nTextCollectorTest.php @@ -533,8 +533,8 @@ public function testCollectMergesWithExisting() public function testCollectFromFilesystemAndWriteMasterTables() { i18n::set_locale('en_US'); //set the locale to the US locale expected in the asserts - i18n::config()->update('default_locale', 'en_US'); - i18n::config()->update('missing_default_warning', false); + i18n::config()->set('default_locale', 'en_US'); + i18n::config()->set('missing_default_warning', false); $c = i18nTextCollector::create(); $c->setWarnOnEmptyDefault(false);