From 9cadfaf7448cbea8b2c6a66dff55b1146f5ed47b Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Thu, 8 Dec 2022 16:05:23 +1300 Subject: [PATCH] DEP PHP Support in CMS5 --- composer.json | 12 ++++++------ tests/Util/ApiLoaderTest.php | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index bc2d47b..70c1742 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,16 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "silverstripe/framework": "^4.10", - "silverstripe/reports": "^4.4", - "symbiote/silverstripe-queuedjobs": "^4.1", - "guzzlehttp/guzzle": "^6.3 || ^7.0" + "php": "^8.1", + "silverstripe/framework": "^5", + "silverstripe/reports": "^5", + "symbiote/silverstripe-queuedjobs": "^5", + "guzzlehttp/guzzle": "^7.5" }, "require-dev": { "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3", - "symfony/thanks": "^1.0" + "symfony/thanks": "^1.2" }, "autoload": { "psr-4": { diff --git a/tests/Util/ApiLoaderTest.php b/tests/Util/ApiLoaderTest.php index 023ff2d..c6d25df 100644 --- a/tests/Util/ApiLoaderTest.php +++ b/tests/Util/ApiLoaderTest.php @@ -9,7 +9,7 @@ use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Response; use SilverStripe\Dev\SapphireTest; -use Symfony\Component\Cache\Simple\NullCache; +use Psr\SimpleCache\CacheInterface; class ApiLoaderTest extends SapphireTest { @@ -88,9 +88,7 @@ public function testCacheControlSettingsAreRespected() { $fakeAddons = ['foo/bar', 'bin/baz']; - $cacheMock = $this->getMockBuilder(NullCache::class) - ->setMethods(['get', 'set']) - ->getMock(); + $cacheMock = $this->getMockCacheInterface(); $cacheMock->expects($this->once())->method('get')->will($this->returnValue(false)); $cacheMock->expects($this->once()) @@ -114,9 +112,7 @@ public function testCachedAddonsAreUsedWhenAvailable() { $fakeAddons = ['foo/bar', 'bin/baz']; - $cacheMock = $this->getMockBuilder(NullCache::class) - ->setMethods(['get', 'set']) - ->getMock(); + $cacheMock = $this->getMockCacheInterface(); $cacheMock->expects($this->once())->method('get')->will($this->returnValue(json_encode($fakeAddons))); $loader = $this->getLoader($cacheMock); @@ -153,9 +149,7 @@ protected function getMockClient(Response $withResponse) protected function getLoader($cacheMock = false) { if (!$cacheMock) { - $cacheMock = $this->getMockBuilder(NullCache::class) - ->setMethods(['get', 'set']) - ->getMock(); + $cacheMock = $this->getMockCacheInterface(); $cacheMock->expects($this->any())->method('get')->will($this->returnValue(false)); $cacheMock->expects($this->any())->method('set')->will($this->returnValue(true)); @@ -165,7 +159,18 @@ protected function getLoader($cacheMock = false) ->getMockForAbstractClass(); $loader->setCache($cacheMock); + $loader->expects($this->any())->method('getCacheKey')->will($this->returnValue('cachKey')); return $loader; } + + protected function getMockCacheInterface() + { + $methods = ['get', 'set', 'has', 'delete', 'getMultiple', 'setMultiple', 'clear', 'deleteMultiple']; + $mock = $this->getMockBuilder(CacheInterface::class) + ->onlyMethods($methods) + ->getMock(); + + return $mock; + } }