1
0

提交代码

This commit is contained in:
2020-08-06 14:50:07 +08:00
parent 9d0d5f4be9
commit d7a848c824
11299 changed files with 1321854 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\CacheClearer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer;
class ChainCacheClearerTest extends TestCase
{
protected static $cacheDir;
public static function setUpBeforeClass(): void
{
self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf_cache_clearer_dir');
}
public static function tearDownAfterClass(): void
{
@unlink(self::$cacheDir);
}
public function testInjectClearersInConstructor()
{
$clearer = $this->getMockClearer();
$clearer
->expects($this->once())
->method('clear');
$chainClearer = new ChainCacheClearer([$clearer]);
$chainClearer->clear(self::$cacheDir);
}
protected function getMockClearer()
{
return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\CacheClearer;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
class Psr6CacheClearerTest extends TestCase
{
public function testClearPoolsInjectedInConstructor()
{
$pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
$pool
->expects($this->once())
->method('clear');
(new Psr6CacheClearer(['pool' => $pool]))->clear('');
}
public function testClearPool()
{
$pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
$pool
->expects($this->once())
->method('clear');
(new Psr6CacheClearer(['pool' => $pool]))->clearPool('pool');
}
public function testClearPoolThrowsExceptionOnUnreferencedPool()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Cache pool not found: unknown');
(new Psr6CacheClearer())->clearPool('unknown');
}
}