1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Tools\Console\Command; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand; |
8
|
|
|
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; |
9
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
10
|
|
|
use Symfony\Component\Console\Application; |
11
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
12
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
13
|
|
|
|
14
|
|
|
class ClearCacheQueryCommandTest extends OrmFunctionalTestCase |
15
|
|
|
{ |
16
|
|
|
/** |
|
|
|
|
17
|
|
|
* @var \Symfony\Component\Console\Application |
|
|
|
|
18
|
|
|
*/ |
19
|
|
|
private $application; |
20
|
|
|
|
21
|
|
|
/** |
|
|
|
|
22
|
|
|
* @var \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand |
|
|
|
|
23
|
|
|
*/ |
24
|
|
|
private $command; |
25
|
|
|
|
26
|
|
|
protected function setUp(): void |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
parent::setUp(); |
29
|
|
|
|
30
|
|
|
$this->command = new QueryCommand(); |
31
|
|
|
|
32
|
|
|
$this->application = new Application(); |
33
|
|
|
$this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->em)])); |
34
|
|
|
$this->application->add($this->command); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function dataInvalidCacheDrivers(): array |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
return [ |
40
|
|
|
'apc' => ['Doctrine\Common\Cache\ApcCache', 'APC Cache'], |
41
|
|
|
'apcu' => ['Doctrine\Common\Cache\ApcuCache', 'APCu Cache'], |
42
|
|
|
'xcache' => ['Doctrine\Common\Cache\XcacheCache', 'XCache Cache'], |
43
|
|
|
]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @dataProvider dataInvalidCacheDrivers |
48
|
|
|
*/ |
49
|
|
|
public function testCannotClearCacheWithInvalidDriver($driver, $name): void |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
$this->em->getConfiguration()->setQueryCacheImpl(new $driver()); |
52
|
|
|
|
53
|
|
|
$command = $this->application->find('orm:clear-cache:query'); |
54
|
|
|
$tester = new CommandTester($command); |
|
|
|
|
55
|
|
|
|
56
|
|
|
$this->expectException(\LogicException::class); |
|
|
|
|
57
|
|
|
$this->expectExceptionMessage("Cannot clear $name from Console"); |
|
|
|
|
58
|
|
|
|
59
|
|
|
$tester->execute( |
60
|
|
|
[ |
61
|
|
|
'command' => $command->getName(), |
62
|
|
|
], |
63
|
|
|
['decorated' => false] |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|