getAssetHandler()
->getContentURL(
$combinedFileID,
- function () use ($fileList, $minify, $type) {
+ function () use ($fileList, $type) {
// Physically combine all file content
$combinedData = '';
foreach ($fileList as $file) {
@@ -1415,11 +1329,6 @@ MESSAGE
// resolve relative paths for css files
$fileContent = $this->resolveCSSReferences($fileContent, $file);
}
- // Use configured minifier
- if ($minify) {
- $fileContent = $this->minifier->minify($fileContent, $type, $file);
- }
-
if ($this->writeHeaderComment) {
// Write a header comment for each file for easier identification and debugging.
$combinedData .= "/****** FILE: $file *****/\n";
diff --git a/src/View/Requirements_Minifier.php b/src/View/Requirements_Minifier.php
deleted file mode 100644
index cf93df033..000000000
--- a/src/View/Requirements_Minifier.php
+++ /dev/null
@@ -1,22 +0,0 @@
-uninherited('theme');
- });
- if ($theme) {
- return [self::PUBLIC_THEME, $theme, self::DEFAULT_THEME];
- }
-
return $default;
}
- /**
- * @param string $theme The "base theme" name (without underscores).
- * @deprecated 4.0.1 Use SSViewer::set_themes() instead
- */
- public static function set_theme($theme)
- {
- Deprecation::notice('4.0.1', 'Use SSViewer::set_themes() instead');
- self::set_themes([$theme, self::DEFAULT_THEME]);
- }
-
/**
* Traverses the given the given class context looking for candidate template names
* which match each item in the class hierarchy. The resulting list of template candidates
diff --git a/src/View/SSViewer_BasicIteratorSupport.php b/src/View/SSViewer_BasicIteratorSupport.php
index 34b09b8bd..04dcaa8e8 100644
--- a/src/View/SSViewer_BasicIteratorSupport.php
+++ b/src/View/SSViewer_BasicIteratorSupport.php
@@ -2,8 +2,6 @@
namespace SilverStripe\View;
-use SilverStripe\Dev\Deprecation;
-
/**
* Defines an extra set of basic methods that can be used in templates
* that are not defined on sub-classes of {@link ViewableData}.
@@ -66,16 +64,6 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
return $this->iteratorPos == 0;
}
- /**
- * @deprecated 4.12.0 Use IsFirst() instead
- * @return bool
- */
- public function First()
- {
- Deprecation::notice('4.12.0', 'Use IsFirst() instead');
- return $this->IsFirst();
- }
-
/**
* Returns true if this object is the last in a set.
*
@@ -86,16 +74,6 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
return $this->iteratorPos == $this->iteratorTotalItems - 1;
}
- /**
- * @deprecated 4.12.0 Use IsLast() instead
- * @return bool
- */
- public function Last()
- {
- Deprecation::notice('4.12.0', 'Use IsLast() instead');
- return $this->IsLast();
- }
-
/**
* Returns 'first' or 'last' if this is the first or last object in the set.
*
diff --git a/src/View/Shortcodes/EmbedShortcodeProvider.php b/src/View/Shortcodes/EmbedShortcodeProvider.php
index 7b844ba60..73f074297 100644
--- a/src/View/Shortcodes/EmbedShortcodeProvider.php
+++ b/src/View/Shortcodes/EmbedShortcodeProvider.php
@@ -16,7 +16,6 @@ use SilverStripe\View\HTML;
use SilverStripe\View\Parsers\ShortcodeHandler;
use SilverStripe\View\Parsers\ShortcodeParser;
use SilverStripe\Control\Director;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\View\Embed\EmbedContainer;
/**
@@ -156,32 +155,6 @@ class EmbedShortcodeProvider implements ShortcodeHandler
return '';
}
- /**
- * @param Adapter $embed
- * @param array $arguments Additional shortcode params
- * @return string
- * @deprecated 4.11.0 Use embeddableToHtml() instead
- */
- public static function embedForTemplate($embed, $arguments)
- {
- Deprecation::notice('4.11.0', 'Use embeddableToHtml() instead');
- switch ($embed->getType()) {
- case 'video':
- case 'rich':
- // Attempt to inherit width (but leave height auto)
- if (empty($arguments['width']) && $embed->getWidth()) {
- $arguments['width'] = $embed->getWidth();
- }
- return static::videoEmbed($arguments, $embed->getCode());
- case 'link':
- return static::linkEmbed($arguments, $embed->getUrl(), $embed->getTitle());
- case 'photo':
- return static::photoEmbed($arguments, $embed->getUrl());
- default:
- return null;
- }
- }
-
/**
* Build video embed tag
*
diff --git a/src/View/ViewableData.php b/src/View/ViewableData.php
index 19e27fa67..2440a5cac 100644
--- a/src/View/ViewableData.php
+++ b/src/View/ViewableData.php
@@ -14,9 +14,7 @@ use SilverStripe\Core\Convert;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
-use SilverStripe\Core\Manifest\ModuleResourceLoader;
use SilverStripe\Dev\Debug;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\ArrayLib;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
@@ -609,35 +607,6 @@ class ViewableData implements IteratorAggregate
return $this;
}
- /**
- * Return the directory if the current active theme (relative to the site root).
- *
- * This method is useful for things such as accessing theme images from your template without hardcoding the theme
- * page - e.g. .
- *
- * This method should only be used when a theme is currently active. However, it will fall over to the current
- * project directory.
- *
- * @return string URL to the current theme
- * @deprecated 4.0.1 Use ModuleResourceLoader::resourcePath() or ModuleResourceLoader::resourceURL() instead
- */
- public function ThemeDir()
- {
- Deprecation::notice('4.0.1', 'Use ModuleResourceLoader::resourcePath() or ModuleResourceLoader::resourceURL() instead');
- $themes = SSViewer::get_themes();
- foreach ($themes as $theme) {
- // Skip theme sets
- if (strpos($theme ?? '', '$') === 0) {
- continue;
- }
- // Map theme path to url
- $themePath = ThemeResourceLoader::inst()->getPath($theme);
- return ModuleResourceLoader::resourceURL($themePath);
- }
-
- return project();
- }
-
/**
* Get part of the current classes ancestry to be used as a CSS class.
*
diff --git a/src/conf/ConfigureFromEnv.php b/src/conf/ConfigureFromEnv.php
deleted file mode 100644
index 6258c4e9b..000000000
--- a/src/conf/ConfigureFromEnv.php
+++ /dev/null
@@ -1,10 +0,0 @@
-uninherited('module_priority');
$sortedModules = [];
- if ($i18nOrder) {
- Deprecation::notice('5.0', sprintf(
- '%s.module_priority is deprecated. Use %s.module_priority instead.',
- __CLASS__,
- ModuleManifest::class
- ));
- }
-
+
foreach (ModuleLoader::inst()->getManifest()->getModules() as $module) {
$sortedModules[$module->getName()] = $module->getPath();
};
diff --git a/src/i18n/Messages/Symfony/FlushInvalidatedResource.php b/src/i18n/Messages/Symfony/FlushInvalidatedResource.php
index ebeeadf01..8ffa478f4 100644
--- a/src/i18n/Messages/Symfony/FlushInvalidatedResource.php
+++ b/src/i18n/Messages/Symfony/FlushInvalidatedResource.php
@@ -2,9 +2,7 @@
namespace SilverStripe\i18n\Messages\Symfony;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\Core\Flushable;
-use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
/**
@@ -14,7 +12,7 @@ use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
* @link https://media.giphy.com/media/fRRD3T37DeY6Y/giphy.gif for use case
* @see DirectoryResource
*/
-class FlushInvalidatedResource implements SelfCheckingResourceInterface, \Serializable, Flushable
+class FlushInvalidatedResource implements SelfCheckingResourceInterface, Flushable
{
public function __toString()
@@ -51,32 +49,6 @@ class FlushInvalidatedResource implements SelfCheckingResourceInterface, \Serial
// no-op
}
- /**
- * The __serialize() magic method will be automatically used instead of this
- *
- * @return string
- * @deprecated 4.12.0 Use __serialize() instead
- */
- public function serialize()
- {
- Deprecation::notice('4.12.0', 'Use __serialize() instead');
- return '';
- }
-
- /**
- * The __unserialize() magic method will be automatically used instead of this almost all the time
- * This method will be automatically used if existing serialized data was not saved as an associative array
- * and the PHP version used in less than PHP 9.0
- *
- * @param string $serialized
- * @deprecated 4.12.0 Use __unserialize() instead
- */
- public function unserialize($serialized)
- {
- Deprecation::notice('4.12.0', 'Use __unserialize() instead');
- // no-op
- }
-
public static function flush()
{
// Mark canary as dirty
diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php
index e7d5e95fb..34965546a 100644
--- a/src/i18n/TextCollection/i18nTextCollector.php
+++ b/src/i18n/TextCollection/i18nTextCollector.php
@@ -2,6 +2,7 @@
namespace SilverStripe\i18n\TextCollection;
+use Exception;
use LogicException;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injectable;
@@ -11,7 +12,6 @@ use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Dev\Debug;
use SilverStripe\Control\Director;
use ReflectionClass;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\i18n\i18n;
use SilverStripe\i18n\i18nEntityProvider;
use SilverStripe\i18n\Messages\Reader;
@@ -828,23 +828,10 @@ class i18nTextCollector
/** @var i18nEntityProvider $obj */
$obj = singleton($class);
$provided = $obj->provideI18nEntities();
- // Handle deprecated return syntax
foreach ($provided as $key => $value) {
// Detect non-associative result for any key
- if (is_array($value) && $value === array_values($value ?? [])) {
- Deprecation::notice('5.0', 'Non-associative translations from providei18nEntities is deprecated');
- $entity = array_filter([
- 'default' => $value[0],
- 'comment' => isset($value[1]) ? $value[1] : null,
- 'module' => isset($value[2]) ? $value[2] : null,
- ]);
- if (count($entity ?? []) === 1) {
- $provided[$key] = $value[0];
- } elseif ($entity) {
- $provided[$key] = $entity;
- } else {
- unset($provided[$key]);
- }
+ if (is_array($value) && $value === array_values($value)) {
+ throw new Exception('Translations from provideI18nEntities() must be an associative array for key $key');
}
}
$entities = array_merge($entities, $provided);
diff --git a/src/i18n/i18n.php b/src/i18n/i18n.php
index b7357b802..8413abce2 100644
--- a/src/i18n/i18n.php
+++ b/src/i18n/i18n.php
@@ -2,9 +2,9 @@
namespace SilverStripe\i18n;
+use Exception;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injector;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\i18n\Data\Locales;
use SilverStripe\i18n\Data\Sources;
use SilverStripe\i18n\Messages\MessageProvider;
@@ -205,23 +205,16 @@ class i18n implements TemplateGlobalProvider
$result = static::getMessageProvider()->translate($entity, $default, $injection);
}
- // Sometimes default is omitted, so we don't know we have %s injection format until after translation
if (!$default && !preg_match('/\{[\w\d]*\}/i', $result ?? '') && preg_match('/%[s,d]/', $result ?? '')) {
- Deprecation::notice('5.0', 'sprintf style localisation is deprecated');
- if ($injection) {
- $sprintfArgs = array_values($injection ?? []);
- }
- } elseif ($failUnlessSprintf) {
+ throw new Exception('sprintf style localisation cannot be used in translations - detected in $result');
+ }
+
+ if ($failUnlessSprintf) {
// Note: After removing deprecated code, you can move this error up into the is-associative check
// Neither default nor translated strings were %s substituted, and our array isn't associative
throw new InvalidArgumentException('Injection must be an associative array');
}
- // @deprecated (see above)
- if ($sprintfArgs) {
- return vsprintf($result ?? '', $sprintfArgs ?? []);
- }
-
return $result;
}
diff --git a/tests/behat/src/CmsUiContext.php b/tests/behat/src/CmsUiContext.php
index 62504e63b..beea59cdd 100644
--- a/tests/behat/src/CmsUiContext.php
+++ b/tests/behat/src/CmsUiContext.php
@@ -76,15 +76,6 @@ class CmsUiContext implements Context
Assert::assertNotNull($cms_element, 'CMS not found');
}
- /**
- * @Then /^I should see a "([^"]*)" notice$/
- * @deprecated 4.7.0 Use `iShouldSeeAToast` instead
- */
- public function iShouldSeeANotice($notice)
- {
- $this->getMainContext()->assertElementContains('.toast, .notice-wrap', $notice);
- }
-
/**
* @Then /^I should see a "(.+)" (\w+) toast$/
*/
diff --git a/tests/php/Control/DirectorTest.php b/tests/php/Control/DirectorTest.php
index 44c9e1980..85a0979b1 100644
--- a/tests/php/Control/DirectorTest.php
+++ b/tests/php/Control/DirectorTest.php
@@ -10,13 +10,11 @@ use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Control\Middleware\CanonicalURLMiddleware;
use SilverStripe\Control\Middleware\RequestHandlerMiddlewareAdapter;
use SilverStripe\Control\Middleware\TrustedProxyMiddleware;
-use SilverStripe\Control\RequestProcessor;
use SilverStripe\Control\Tests\DirectorTest\TestController;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Kernel;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;
/**
@@ -855,46 +853,6 @@ class DirectorTest extends SapphireTest
$this->assertEquals($request->getURL(true), $url);
}
- public function testRequestFilterInDirectorTest()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $filter = new DirectorTest\TestRequestFilter;
-
- $processor = new RequestProcessor([$filter]);
-
- $middlewares = Director::singleton()->getMiddlewares();
- $middlewares['RequestProcessorMiddleware'] = $processor;
- Director::singleton()->setMiddlewares($middlewares);
-
- $response = Director::test('some-dummy-url');
- $this->assertEquals(404, $response->getStatusCode());
-
- $this->assertEquals(1, $filter->preCalls);
- $this->assertEquals(1, $filter->postCalls);
-
- $filter->failPost = true;
-
- $response = Director::test('some-dummy-url');
- $this->assertEquals(500, $response->getStatusCode());
- $this->assertEquals(_t(Director::class . '.REQUEST_ABORTED', 'Request aborted'), $response->getBody());
-
- $this->assertEquals(2, $filter->preCalls);
- $this->assertEquals(2, $filter->postCalls);
-
- $filter->failPre = true;
-
- $response = Director::test('some-dummy-url');
- $this->assertEquals(400, $response->getStatusCode());
- $this->assertEquals(_t(Director::class . '.INVALID_REQUEST', 'Invalid request'), $response->getBody());
-
- $this->assertEquals(3, $filter->preCalls);
-
- // preCall 'true' will trigger an exception and prevent post call execution
- $this->assertEquals(2, $filter->postCalls);
- }
-
public function testGlobalMiddleware()
{
$middleware = new DirectorTest\TestMiddleware;
diff --git a/tests/php/Control/DirectorTest/TestRequestFilter.php b/tests/php/Control/DirectorTest/TestRequestFilter.php
index 01bff2e52..47e9115d2 100644
--- a/tests/php/Control/DirectorTest/TestRequestFilter.php
+++ b/tests/php/Control/DirectorTest/TestRequestFilter.php
@@ -4,10 +4,9 @@ namespace SilverStripe\Control\Tests\DirectorTest;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
-use SilverStripe\Control\RequestFilter;
use SilverStripe\Dev\TestOnly;
-class TestRequestFilter implements RequestFilter, TestOnly
+class TestRequestFilter implements TestOnly
{
public $preCalls = 0;
public $postCalls = 0;
diff --git a/tests/php/Control/Email/MailerSubscriberTest.php b/tests/php/Control/Email/MailerSubscriberTest.php
index a3960a2a6..16c576700 100644
--- a/tests/php/Control/Email/MailerSubscriberTest.php
+++ b/tests/php/Control/Email/MailerSubscriberTest.php
@@ -44,7 +44,7 @@ class MailerSubscriberTest extends SapphireTest
public function testSendAllEmailsTo(): void
{
- Email::config()->update('send_all_emails_to', 'to@example.com');
+ Email::config()->merge('send_all_emails_to', ['to@example.com']);
$email = $this->getEmail();
$email->send();
@@ -61,7 +61,7 @@ class MailerSubscriberTest extends SapphireTest
public function testSendAllEmailsFrom(): void
{
- Email::config()->update('send_all_emails_from', 'from@example.com');
+ Email::config()->merge('send_all_emails_from', ['from@example.com']);
$email = $this->getEmail();
$email->send();
@@ -78,7 +78,7 @@ class MailerSubscriberTest extends SapphireTest
public function testCCAllEmailsTo(): void
{
- Email::config()->update('cc_all_emails_to', 'cc@example.com');
+ Email::config()->merge('cc_all_emails_to', ['cc@example.com']);
$email = $this->getEmail();
$email->send();
@@ -89,7 +89,7 @@ class MailerSubscriberTest extends SapphireTest
public function testBCCAllEmailsTo(): void
{
- Email::config()->update('bcc_all_emails_to', 'bcc@example.com');
+ Email::config()->merge('bcc_all_emails_to', ['bcc@example.com']);
$email = $this->getEmail();
$email->send();
diff --git a/tests/php/Control/HTTPRequestTest.php b/tests/php/Control/HTTPRequestTest.php
index 8f39efbc2..93391c12c 100644
--- a/tests/php/Control/HTTPRequestTest.php
+++ b/tests/php/Control/HTTPRequestTest.php
@@ -6,7 +6,6 @@ use ReflectionMethod;
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
@@ -151,27 +150,6 @@ class HTTPRequestTest extends SapphireTest
];
}
- /**
- * @dataProvider detectMethodDataProvider
- */
- public function testDetectMethod($realMethod, $post, $expected)
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $actual = HTTPRequest::detect_method($realMethod, $post);
- $this->assertEquals($expected, $actual);
- }
-
- public function testBadDetectMethod()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $this->expectException(\InvalidArgumentException::class);
- HTTPRequest::detect_method('POST', ['_method' => 'Boom']);
- }
-
public function setHttpMethodDataProvider()
{
return [
diff --git a/tests/php/Control/HTTPTest.php b/tests/php/Control/HTTPTest.php
index b7ea02e9d..5f748771c 100644
--- a/tests/php/Control/HTTPTest.php
+++ b/tests/php/Control/HTTPTest.php
@@ -11,7 +11,6 @@ use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
use SilverStripe\Control\Session;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\FunctionalTest;
-use SilverStripe\Dev\Deprecation;
/**
* Tests the {@link HTTP} class
@@ -114,89 +113,6 @@ class HTTPTest extends FunctionalTest
$this->assertEmpty($v);
}
- public function testDeprecatedVaryHandling()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- /** @var Config */
- Config::modify()->set(
- HTTP::class,
- 'vary',
- 'X-Foo'
- );
- $response = new HTTPResponse('', 200);
- $this->addCacheHeaders($response);
- $header = $response->getHeader('Vary');
- $this->assertStringContainsString('X-Foo', $header);
- }
-
- public function testDeprecatedCacheControlHandling()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- HTTPCacheControlMiddleware::singleton()->publicCache();
-
- /** @var Config */
- Config::modify()->set(
- HTTP::class,
- 'cache_control',
- [
- 'no-store' => true,
- 'no-cache' => true,
- ]
- );
- $response = new HTTPResponse('', 200);
- $this->addCacheHeaders($response);
- $header = $response->getHeader('Cache-Control');
- $this->assertStringContainsString('no-store', $header);
- $this->assertStringContainsString('no-cache', $header);
- }
-
- public function testDeprecatedCacheControlHandlingOnMaxAge()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- HTTPCacheControlMiddleware::singleton()->publicCache();
-
- /** @var Config */
- Config::modify()->set(
- HTTP::class,
- 'cache_control',
- [
- // Needs to be separate from no-cache and no-store,
- // since that would unset max-age
- 'max-age' => 99,
- ]
- );
- $response = new HTTPResponse('', 200);
- $this->addCacheHeaders($response);
- $header = $response->getHeader('Cache-Control');
- $this->assertStringContainsString('max-age=99', $header);
- }
-
- public function testDeprecatedCacheControlHandlingThrowsWithUnknownDirectives()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $this->expectException(\LogicException::class);
- $this->expectExceptionMessageMatches('/Found unsupported legacy directives in HTTP\.cache_control: unknown/');
- /** @var Config */
- Config::modify()->set(
- HTTP::class,
- 'cache_control',
- [
- 'no-store' => true,
- 'unknown' => true,
- ]
- );
- $response = new HTTPResponse('', 200);
- $this->addCacheHeaders($response);
- }
-
/**
* Tests {@link HTTP::getLinksIn()}
*/
diff --git a/tests/php/Core/Config/ConfigTest.php b/tests/php/Core/Config/ConfigTest.php
index d55d7fd8e..8731fcae9 100644
--- a/tests/php/Core/Config/ConfigTest.php
+++ b/tests/php/Core/Config/ConfigTest.php
@@ -22,8 +22,8 @@ class ConfigTest extends SapphireTest
$this->assertEquals(5, Config::inst()->get(ConfigTest\TestNest::class, 'bar'));
// Test nested data can be updated
- Config::modify()->merge(ConfigTest\TestNest::class, 'foo', 4);
- $this->assertEquals(4, Config::inst()->get(ConfigTest\TestNest::class, 'foo'));
+ Config::modify()->merge(ConfigTest\TestNest::class, 'foo', [4]);
+ $this->assertEquals(4, Config::inst()->get(ConfigTest\TestNest::class, 'foo')[0]);
$this->assertEquals(5, Config::inst()->get(ConfigTest\TestNest::class, 'bar'));
// Test unnest restores data
@@ -171,31 +171,31 @@ class ConfigTest extends SapphireTest
{
// Booleans
$this->assertTrue(Config::inst()->get(ConfigTest\First::class, 'bool'));
- Config::modify()->merge(ConfigTest\First::class, 'bool', false);
- $this->assertFalse(Config::inst()->get(ConfigTest\First::class, 'bool'));
- Config::modify()->merge(ConfigTest\First::class, 'bool', true);
- $this->assertTrue(Config::inst()->get(ConfigTest\First::class, 'bool'));
+ Config::modify()->merge(ConfigTest\First::class, 'bool', [false]);
+ $this->assertFalse(Config::inst()->get(ConfigTest\First::class, 'bool')[0]);
+ Config::modify()->merge(ConfigTest\First::class, 'bool', [true]);
+ $this->assertTrue(Config::inst()->get(ConfigTest\First::class, 'bool')[1]);
// Integers
$this->assertEquals(42, Config::inst()->get(ConfigTest\First::class, 'int'));
- Config::modify()->merge(ConfigTest\First::class, 'int', 0);
- $this->assertEquals(0, Config::inst()->get(ConfigTest\First::class, 'int'));
- Config::modify()->merge(ConfigTest\First::class, 'int', 42);
- $this->assertEquals(42, Config::inst()->get(ConfigTest\First::class, 'int'));
+ Config::modify()->merge(ConfigTest\First::class, 'int', [0]);
+ $this->assertEquals(0, Config::inst()->get(ConfigTest\First::class, 'int')[0]);
+ Config::modify()->merge(ConfigTest\First::class, 'int', [42]);
+ $this->assertEquals(42, Config::inst()->get(ConfigTest\First::class, 'int')[1]);
// Strings
$this->assertEquals('value', Config::inst()->get(ConfigTest\First::class, 'string'));
- Config::modify()->merge(ConfigTest\First::class, 'string', '');
- $this->assertEquals('', Config::inst()->get(ConfigTest\First::class, 'string'));
- Config::modify()->merge(ConfigTest\First::class, 'string', 'value');
- $this->assertEquals('value', Config::inst()->get(ConfigTest\First::class, 'string'));
+ Config::modify()->merge(ConfigTest\First::class, 'string', ['']);
+ $this->assertEquals('', Config::inst()->get(ConfigTest\First::class, 'string')[0]);
+ Config::modify()->merge(ConfigTest\First::class, 'string', ['value']);
+ $this->assertEquals('value', Config::inst()->get(ConfigTest\First::class, 'string')[1]);
// Nulls
$this->assertEquals('value', Config::inst()->get(ConfigTest\First::class, 'nullable'));
- Config::modify()->merge(ConfigTest\First::class, 'nullable', null);
- $this->assertNull(Config::inst()->get(ConfigTest\First::class, 'nullable'));
- Config::modify()->merge(ConfigTest\First::class, 'nullable', 'value');
- $this->assertEquals('value', Config::inst()->get(ConfigTest\First::class, 'nullable'));
+ Config::modify()->merge(ConfigTest\First::class, 'nullable', [null]);
+ $this->assertNull(Config::inst()->get(ConfigTest\First::class, 'nullable')[0]);
+ Config::modify()->merge(ConfigTest\First::class, 'nullable', ['value']);
+ $this->assertEquals('value', Config::inst()->get(ConfigTest\First::class, 'nullable')[1]);
}
public function testSetsFalsyDefaults()
diff --git a/tests/php/Core/ConvertTest.php b/tests/php/Core/ConvertTest.php
index 1c846f974..243694bee 100644
--- a/tests/php/Core/ConvertTest.php
+++ b/tests/php/Core/ConvertTest.php
@@ -5,7 +5,6 @@ namespace SilverStripe\Core\Tests;
use Exception;
use InvalidArgumentException;
use SilverStripe\Core\Convert;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\View\Parsers\URLSegmentFilter;
use stdClass;
@@ -213,60 +212,6 @@ PHP
$this->assertEquals('This is some normal text.', Convert::xml2raw($val2), 'Normal text is not escaped');
}
- /**
- * Tests {@link Convert::xml2raw()}
- */
- public function testArray2JSON()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $val = [
- 'Joe' => 'Bloggs',
- 'Tom' => 'Jones',
- 'My' => [
- 'Complicated' => 'Structure'
- ]
- ];
- $encoded = Convert::array2json($val);
- $this->assertEquals(
- '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}',
- $encoded,
- 'Array is encoded in JSON'
- );
- }
-
- /**
- * Tests {@link Convert::json2array()}
- */
- public function testJSON2Array()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $val = '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}';
- $decoded = Convert::json2array($val);
- $this->assertEquals(3, count($decoded ?? []), '3 items in the decoded array');
- $this->assertContains('Bloggs', $decoded, 'Contains "Bloggs" value in decoded array');
- $this->assertContains('Jones', $decoded, 'Contains "Jones" value in decoded array');
- $this->assertStringContainsString('Structure', $decoded['My']['Complicated']);
- }
-
- /**
- * Tests {@link Convert::testJSON2Obj()}
- */
- public function testJSON2Obj()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $val = '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}';
- $obj = Convert::json2obj($val);
- $this->assertEquals('Bloggs', $obj->Joe);
- $this->assertEquals('Jones', $obj->Tom);
- $this->assertEquals('Structure', $obj->My->Complicated);
- }
-
/**
* Tests {@link Convert::testRaw2URL()}
*
@@ -364,143 +309,6 @@ PHP
);
}
- /**
- * Tests {@link Convert::raw2json()}
- */
- public function testRaw2JSON()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
-
- // Test object
- $input = new stdClass();
- $input->Title = 'My Object';
- $input->Content = 'Data
';
- $this->assertEquals(
- '{"Title":"My Object","Content":"Data<\/p>"}',
- Convert::raw2json($input)
- );
-
- // Array
- $array = ['One' => 'Apple', 'Two' => 'Banana'];
- $this->assertEquals(
- '{"One":"Apple","Two":"Banana"}',
- Convert::raw2json($array)
- );
-
- // String value with already encoded data. Result should be quoted.
- $value = '{"Left": "Value"}';
- $this->assertEquals(
- '"{\\"Left\\": \\"Value\\"}"',
- Convert::raw2json($value)
- );
- }
-
- /**
- * Test that a context bitmask can be passed through to the json_encode method in {@link Convert::raw2json()}
- * and in {@link Convert::array2json()}
- */
- public function testRaw2JsonWithContext()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $data = ['foo' => 'b"ar'];
- $expected = '{"foo":"b\u0022ar"}';
- $result = Convert::raw2json($data, JSON_HEX_QUOT);
- $this->assertSame($expected, $result);
- $wrapperResult = Convert::array2json($data, JSON_HEX_QUOT);
- $this->assertSame($expected, $wrapperResult);
- }
-
- /**
- * Tests {@link Convert::xml2array()}
- */
- public function testXML2Array()
- {
-
- $inputXML = <<
-
-]>
-
- My para
- Ampersand & is retained and not double encoded
-
-XML
- ;
- $expected = [
- 'result' => [
- 'My para',
- 'Ampersand & is retained and not double encoded'
- ]
- ];
- $actual = Convert::xml2array($inputXML, false);
- $this->assertEquals($expected, $actual);
- $this->expectException(InvalidArgumentException::class);
- $this->expectExceptionMessage('XML Doctype parsing disabled');
- Convert::xml2array($inputXML, true);
- }
-
- /**
- * Tests {@link Convert::xml2array()} if an exception the contains a reference to a removed
- */
- public function testXML2ArrayEntityException()
- {
- $inputXML = <<
-
- ]>
-
- Now include &long; lots of times to expand the in-memory size of this XML structure
- &long;&long;&long;
-
- XML;
- $this->expectException(Exception::class);
- $this->expectExceptionMessage('String could not be parsed as XML');
- Convert::xml2array($inputXML);
- }
-
- /**
- * Tests {@link Convert::xml2array()} if an exception the contains a reference to a multiple removed
- */
- public function testXML2ArrayMultipleEntitiesException()
- {
- $inputXML = <<
- ]>
-
- Now include &long; and &short; lots of times
- &long;&long;&long;&short;&short;&short;
-
- XML;
- $this->expectException(Exception::class);
- $this->expectExceptionMessage('String could not be parsed as XML');
- Convert::xml2array($inputXML);
- }
-
- /**
- * Tests {@link Convert::xml2array()} if there is a malicious present
- */
- public function testXML2ArrayMaliciousEntityException()
- {
- $inputXML = <<
- ENTITY ext SYSTEM "http://evil.com">
- ]>
-
- Evil document
-
- XML;
- $this->expectException(InvalidArgumentException::class);
- $this->expectExceptionMessage('Malicious XML entity detected');
- Convert::xml2array($inputXML);
- }
-
/**
* Tests {@link Convert::base64url_encode()} and {@link Convert::base64url_decode()}
*/
diff --git a/tests/php/Core/Injector/InjectorTest.php b/tests/php/Core/Injector/InjectorTest.php
index 85aa7a3ff..00ef77333 100644
--- a/tests/php/Core/Injector/InjectorTest.php
+++ b/tests/php/Core/Injector/InjectorTest.php
@@ -759,7 +759,7 @@ class InjectorTest extends SapphireTest
'locator' => SilverStripeServiceConfigurationLocator::class
]
);
- Config::modify()->merge(
+ Config::modify()->set(
Injector::class,
MyChildClass::class,
'%$' . MyParentClass::class
diff --git a/tests/php/Core/ObjectTest.php b/tests/php/Core/ObjectTest.php
index 66562315a..5882eb0c1 100644
--- a/tests/php/Core/ObjectTest.php
+++ b/tests/php/Core/ObjectTest.php
@@ -19,7 +19,6 @@ use SilverStripe\Core\Tests\ObjectTest\ExtensionTest3;
use SilverStripe\Core\Tests\ObjectTest\MyObject;
use SilverStripe\Core\Tests\ObjectTest\MySubObject;
use SilverStripe\Core\Tests\ObjectTest\TestExtension;
-use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Versioned\Versioned;
@@ -109,62 +108,6 @@ class ObjectTest extends SapphireTest
);
}
- public function testStaticGetterMethod()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $obj = singleton(MyObject::class);
- $this->assertEquals(
- 'MyObject',
- $obj->stat('mystaticProperty'),
- 'Uninherited statics through stat() on a singleton behave the same as built-in PHP statics'
- );
- }
-
- public function testStaticInheritanceGetters()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $subObj = singleton(MyObject::class);
- $this->assertEquals(
- $subObj->stat('mystaticProperty'),
- 'MyObject',
- 'Statics defined on a parent class are available through stat() on a subclass'
- );
- }
-
- public function testStaticSettingOnSingletons()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $singleton1 = singleton(MyObject::class);
- $singleton2 = singleton(MyObject::class);
- $singleton1->set_stat('mystaticProperty', 'changed');
- $this->assertEquals(
- $singleton2->stat('mystaticProperty'),
- 'changed',
- 'Statics setting is populated throughout singletons without explicitly clearing cache'
- );
- }
-
- public function testStaticSettingOnInstances()
- {
- if (Deprecation::isEnabled()) {
- $this->markTestSkipped('Test calls deprecated code');
- }
- $instance1 = new ObjectTest\MyObject();
- $instance2 = new ObjectTest\MyObject();
- $instance1->set_stat('mystaticProperty', 'changed');
- $this->assertEquals(
- $instance2->stat('mystaticProperty'),
- 'changed',
- 'Statics setting through set_stat() is populated throughout instances without explicitly clearing cache'
- );
- }
-
/**
* Tests that {@link Object::create()} correctly passes all arguments to the new object
*/
diff --git a/tests/php/Dev/CSVParserTest.php b/tests/php/Dev/CSVParserTest.php
deleted file mode 100644
index 1ff17fe16..000000000
--- a/tests/php/Dev/CSVParserTest.php
+++ /dev/null
@@ -1,159 +0,0 @@
-csvPath = __DIR__ . '/CsvBulkLoaderTest/csv/';
- }
-
- public function testParsingWithHeaders()
- {
- /* By default, a CSV file will be interpreted as having headers */
- $csv = new CSVParser($this->csvPath . 'PlayersWithHeader.csv');
-
- $firstNames = $birthdays = $biographies = $registered = [];
- foreach ($csv as $record) {
- /* Each row in the CSV file will be keyed with the header row */
- $this->assertEquals(
- ['FirstName','Biography','Birthday','IsRegistered'],
- array_keys($record ?? [])
- );
- $firstNames[] = $record['FirstName'];
- $biographies[] = $record['Biography'];
- $birthdays[] = $record['Birthday'];
- $registered[] = $record['IsRegistered'];
- }
-
- $this->assertEquals(
- ['John','Jane','Jamie','Järg','Jacob'],
- $firstNames
- );
-
- $this->assertEquals(
- [
- "He's a good guy",
- "She is awesome."
- . PHP_EOL
- . "So awesome that she gets multiple rows and \"escaped\" strings in her biography",
- "Pretty old, with an escaped comma",
- "Unicode FTW",
- "Likes leading tabs in his biography",
- ],
- $biographies
- );
- $this->assertEquals([
- "1988-01-31",
- "1982-01-31",
- "1882-01-31",
- "1982-06-30",
- "2000-04-30",
- ], $birthdays);
- $this->assertEquals(
- ['1', '0', '1', '1', '0'],
- $registered
- );
- }
-
- public function testParsingWithHeadersAndColumnMap()
- {
- /* By default, a CSV file will be interpreted as having headers */
- $csv = new CSVParser($this->csvPath . 'PlayersWithHeader.csv');
-
- /* We can set up column remapping. The keys are case-insensitive. */
- $csv->mapColumns([
- 'FirstName' => '__fn',
- 'bIoGrApHy' => '__BG',
- ]);
-
- $firstNames = $birthdays = $biographies = $registered = [];
- foreach ($csv as $record) {
- /* Each row in the CSV file will be keyed with the renamed columns. Any unmapped column names will be
- * left as-is. */
- $this->assertEquals(['__fn','__BG','Birthday','IsRegistered'], array_keys($record ?? []));
- $firstNames[] = $record['__fn'];
- $biographies[] = $record['__BG'];
- $birthdays[] = $record['Birthday'];
- $registered[] = $record['IsRegistered'];
- }
-
- $this->assertEquals(['John','Jane','Jamie','Järg','Jacob'], $firstNames);
- $this->assertEquals(
- [
- "He's a good guy",
- "She is awesome."
- . PHP_EOL
- . "So awesome that she gets multiple rows and \"escaped\" strings in her biography",
- "Pretty old, with an escaped comma",
- "Unicode FTW",
- "Likes leading tabs in his biography",
- ],
- $biographies
- );
- $this->assertEquals([
- "1988-01-31",
- "1982-01-31",
- "1882-01-31",
- "1982-06-30",
- "2000-04-30",
- ], $birthdays);
- $this->assertEquals(['1', '0', '1', '1', '0'], $registered);
- }
-
- public function testParsingWithExplicitHeaderRow()
- {
- /* If your CSV file doesn't have a header row */
- $csv = new CSVParser($this->csvPath . 'PlayersWithHeader.csv');
-
- $csv->provideHeaderRow(['__fn','__bio','__bd','__reg']);
-
- $firstNames = $birthdays = $biographies = $registered = [];
- foreach ($csv as $record) {
- /* Each row in the CSV file will be keyed with the header row that you gave */
- $this->assertEquals(['__fn','__bio','__bd','__reg'], array_keys($record ?? []));
- $firstNames[] = $record['__fn'];
- $biographies[] = $record['__bio'];
- $birthdays[] = $record['__bd'];
- $registered[] = $record['__reg'];
- }
-
- /* And the first row will be returned in the data */
- $this->assertEquals(['FirstName','John','Jane','Jamie','Järg','Jacob'], $firstNames);
- $this->assertEquals(
- [
- 'Biography',
- "He's a good guy",
- "She is awesome."
- . PHP_EOL
- . "So awesome that she gets multiple rows and \"escaped\" strings in her biography",
- "Pretty old, with an escaped comma",
- "Unicode FTW",
- "Likes leading tabs in his biography"
- ],
- $biographies
- );
- $this->assertEquals([
- "Birthday",
- "1988-01-31",
- "1982-01-31",
- "1882-01-31",
- "1982-06-30",
- "2000-04-30",
- ], $birthdays);
- $this->assertEquals(['IsRegistered', '1', '0', '1', '1', '0'], $registered);
- }
-}
diff --git a/tests/php/Forms/GridField/GridFieldFilterHeaderTest.php b/tests/php/Forms/GridField/GridFieldFilterHeaderTest.php
index db70ddddb..357c9d765 100644
--- a/tests/php/Forms/GridField/GridFieldFilterHeaderTest.php
+++ b/tests/php/Forms/GridField/GridFieldFilterHeaderTest.php
@@ -73,18 +73,6 @@ class GridFieldFilterHeaderTest extends SapphireTest
// Check that the output is the new search field
$this->assertStringContainsString('assertStringContainsString('Open search and filter', $htmlFragment['buttons-before-right']);
-
- $this->gridField->getConfig()->removeComponentsByType(GridFieldFilterHeader::class);
- $this->gridField->getConfig()->addComponent(new GridFieldFilterHeader(true));
- $this->component = $this->gridField->getConfig()->getComponentByType(GridFieldFilterHeader::class);
- $htmlFragment = $this->component->getHTMLFragments($this->gridField);
-
- // Check that the output is the legacy filter header
- $this->assertStringContainsString(
- '