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