From d4d3cecbf8e5cd8ac04d1b451af17eb6b5682534 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Wed, 7 Mar 2018 14:51:43 +0100 Subject: Fix tests to use ICacheFactory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/lib/Template/CSSResourceLocatorTest.php | 11 ++++++----- tests/lib/Template/JSCombinerTest.php | 16 ++++++++++++++-- tests/lib/Template/JSResourceLocatorTest.php | 10 +++++----- tests/lib/Template/SCSSCacherTest.php | 15 +++++++++++++-- 4 files changed, 38 insertions(+), 14 deletions(-) (limited to 'tests/lib') diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php index a16cc18cb0a..22843d7f935 100644 --- a/tests/lib/Template/CSSResourceLocatorTest.php +++ b/tests/lib/Template/CSSResourceLocatorTest.php @@ -24,11 +24,12 @@ namespace Test\Template; use OC\Files\AppData\Factory; +use OCP\Files\IAppData; +use OCP\ICacheFactory; use OCP\ILogger; use OCP\IURLGenerator; use OCP\IConfig; use OCA\Theming\ThemingDefaults; -use OCP\ICache; use OC\Template\SCSSCacher; use OC\Template\CSSResourceLocator; @@ -41,8 +42,8 @@ class CSSResourceLocatorTest extends \Test\TestCase { protected $config; /** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */ protected $themingDefaults; - /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */ - protected $depsCache; + /** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $cacheFactory; /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ protected $logger; @@ -53,7 +54,7 @@ class CSSResourceLocatorTest extends \Test\TestCase { $this->appData = $this->createMock(IAppData::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(IConfig::class); - $this->depsCache = $this->createMock(ICache::class); + $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->themingDefaults = $this->createMock(ThemingDefaults::class); } @@ -68,7 +69,7 @@ class CSSResourceLocatorTest extends \Test\TestCase { $this->config, $this->themingDefaults, \OC::$SERVERROOT, - $this->depsCache + $this->cacheFactory ); return new CSSResourceLocator( $this->logger, diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php index d5f7000e0a5..e10e44aa358 100644 --- a/tests/lib/Template/JSCombinerTest.php +++ b/tests/lib/Template/JSCombinerTest.php @@ -31,6 +31,7 @@ use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; +use OCP\ICacheFactory; use OCP\ILogger; use OCP\IURLGenerator; @@ -47,6 +48,8 @@ class JSCombinerTest extends \Test\TestCase { protected $jsCombiner; /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ protected $logger; + /** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $cacheFactory; protected function setUp() { parent::setUp(); @@ -54,15 +57,20 @@ class JSCombinerTest extends \Test\TestCase { $this->appData = $this->createMock(IAppData::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(SystemConfig::class); + $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->depsCache = $this->createMock(ICache::class); + $this->cacheFactory->expects($this->at(0)) + ->method('createDistributed') + ->willReturn($this->depsCache); $this->logger = $this->createMock(ILogger::class); $this->jsCombiner = new JSCombiner( $this->appData, $this->urlGenerator, - $this->depsCache, + $this->cacheFactory, $this->config, $this->logger ); + } public function testProcessDebugMode() { @@ -522,7 +530,11 @@ var b = \'world\'; ->method('getDirectoryListing') ->willReturn([$file]); - $this->depsCache->expects($this->once()) + $cache = $this->createMock(ICache::class); + $this->cacheFactory->expects($this->once()) + ->method('createDistributed') + ->willReturn($cache); + $cache->expects($this->once()) ->method('clear') ->with(''); $this->appData->expects($this->once()) diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php index 6841ee2fee3..f5dff62729f 100644 --- a/tests/lib/Template/JSResourceLocatorTest.php +++ b/tests/lib/Template/JSResourceLocatorTest.php @@ -25,8 +25,8 @@ namespace Test\Template; use OC\Template\JSCombiner; use OCP\Files\IAppData; +use OCP\ICacheFactory; use OCP\IURLGenerator; -use OCP\ICache; use OC\SystemConfig; use OCP\ILogger; use OC\Template\JSResourceLocator; @@ -38,8 +38,8 @@ class JSResourceLocatorTest extends \Test\TestCase { protected $urlGenerator; /** @var SystemConfig|\PHPUnit_Framework_MockObject_MockObject */ protected $config; - /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */ - protected $depsCache; + /** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $cacheFactory; /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ protected $logger; @@ -49,7 +49,7 @@ class JSResourceLocatorTest extends \Test\TestCase { $this->appData = $this->createMock(IAppData::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(SystemConfig::class); - $this->depsCache = $this->createMock(ICache::class); + $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->logger = $this->createMock(ILogger::class); } @@ -57,7 +57,7 @@ class JSResourceLocatorTest extends \Test\TestCase { $jsCombiner = new JSCombiner( $this->appData, $this->urlGenerator, - $this->depsCache, + $this->cacheFactory, $this->config, $this->logger ); diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index dfaeb803578..169ee26802a 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -31,6 +31,7 @@ use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\ILogger; use OCP\IURLGenerator; @@ -50,6 +51,8 @@ class SCSSCacherTest extends \Test\TestCase { protected $scssCacher; /** @var ICache|\PHPUnit_Framework_MockObject_MockObject */ protected $depsCache; + /** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $cacheFactory; protected function setUp() { parent::setUp(); @@ -60,7 +63,11 @@ class SCSSCacherTest extends \Test\TestCase { $factory->method('get')->with('css')->willReturn($this->appData); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(IConfig::class); + $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->depsCache = $this->createMock(ICache::class); + $this->cacheFactory->expects($this->at(0)) + ->method('createDistributed') + ->willReturn($this->depsCache); $this->themingDefaults = $this->createMock(ThemingDefaults::class); $this->scssCacher = new SCSSCacher( $this->logger, @@ -69,7 +76,7 @@ class SCSSCacherTest extends \Test\TestCase { $this->config, $this->themingDefaults, \OC::$SERVERROOT, - $this->depsCache + $this->cacheFactory ); $this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]); @@ -459,7 +466,11 @@ class SCSSCacherTest extends \Test\TestCase { ->method('getDirectoryListing') ->willReturn([$file]); - $this->depsCache->expects($this->once()) + $cache = $this->createMock(ICache::class); + $this->cacheFactory->expects($this->once()) + ->method('createDistributed') + ->willReturn($cache); + $cache->expects($this->once()) ->method('clear') ->with(''); $this->appData->expects($this->once()) -- cgit v1.2.3 From 43243380f1b29e7a927b5e589c052e4b64b22b5d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 9 Mar 2018 14:43:54 +0100 Subject: Always return the depscache Signed-off-by: Roeland Jago Douma --- tests/lib/Template/SCSSCacherTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/lib') diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 169ee26802a..9eb6c5a5200 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -65,7 +65,7 @@ class SCSSCacherTest extends \Test\TestCase { $this->config = $this->createMock(IConfig::class); $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->depsCache = $this->createMock(ICache::class); - $this->cacheFactory->expects($this->at(0)) + $this->cacheFactory ->method('createDistributed') ->willReturn($this->depsCache); $this->themingDefaults = $this->createMock(ThemingDefaults::class); -- cgit v1.2.3 From 17f75d67975025f4d0660eb2ba78305a7839ec68 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 9 Mar 2018 15:36:53 +0100 Subject: Mock method of actual cache Signed-off-by: Morris Jobke --- tests/lib/Template/SCSSCacherTest.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tests/lib') diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 9eb6c5a5200..adf49eec796 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -466,11 +466,7 @@ class SCSSCacherTest extends \Test\TestCase { ->method('getDirectoryListing') ->willReturn([$file]); - $cache = $this->createMock(ICache::class); - $this->cacheFactory->expects($this->once()) - ->method('createDistributed') - ->willReturn($cache); - $cache->expects($this->once()) + $this->depsCache->expects($this->once()) ->method('clear') ->with(''); $this->appData->expects($this->once()) -- cgit v1.2.3