Browse Source

Fix tests to use ICacheFactory

Signed-off-by: Julius Härtl <jus@bitgrid.net>
tags/v14.0.0beta1
Julius Härtl 6 years ago
parent
commit
95366bbd1f
No account linked to committer's email address

+ 2
- 2
apps/theming/lib/ThemingDefaults.php View File

@@ -298,7 +298,7 @@ class ThemingDefaults extends \OC_Defaults {
* @return bool
*/
public function shouldReplaceIcons() {
$cache = $this->cacheFactory->createDistributed('theming');
$cache = $this->cacheFactory->createDistributed('theming-');
if($value = $cache->get('shouldReplaceIcons')) {
return (bool)$value;
}
@@ -320,7 +320,7 @@ class ThemingDefaults extends \OC_Defaults {
private function increaseCacheBuster() {
$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
$this->cacheFactory->createDistributed('theming')->clear('getScssVariables');
$this->cacheFactory->createDistributed('theming-')->clear('getScssVariables');
}

/**

+ 1
- 1
apps/theming/tests/ThemingDefaultsTest.php View File

@@ -79,7 +79,7 @@ class ThemingDefaultsTest extends TestCase {
$this->cacheFactory
->expects($this->any())
->method('createDistributed')
->with('theming')
->with('theming-')
->willReturn($this->cache);
$this->template = new ThemingDefaults(
$this->config,

+ 5
- 5
tests/lib/Template/CSSResourceLocatorTest.php View File

@@ -25,11 +25,11 @@ 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;

@@ -42,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;

@@ -54,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);
}

@@ -69,7 +69,7 @@ class CSSResourceLocatorTest extends \Test\TestCase {
$this->config,
$this->themingDefaults,
\OC::$SERVERROOT,
$this->depsCache
$this->cacheFactory
);
return new CSSResourceLocator(
$this->logger,

+ 14
- 2
tests/lib/Template/JSCombinerTest.php View File

@@ -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() {
@@ -539,7 +547,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())

+ 5
- 5
tests/lib/Template/JSResourceLocatorTest.php View File

@@ -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
);

+ 13
- 2
tests/lib/Template/SCSSCacherTest.php View File

@@ -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())

Loading…
Cancel
Save