Skip to content

Commit

Permalink
DEP PHP Support in CMS5
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Jan 11, 2023
1 parent 08e663d commit 9cadfaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
25 changes: 15 additions & 10 deletions tests/Util/ApiLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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())
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand All @@ -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;
}
}

0 comments on commit 9cadfaf

Please sign in to comment.