|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Tools\Console\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Cache\MemcachedCache; |
|
6
|
|
|
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; |
|
7
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
8
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
|
9
|
|
|
use Symfony\Component\Console\Application; |
|
10
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
|
11
|
|
|
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand; |
|
12
|
|
|
|
|
13
|
|
|
class EnsureProductionSettingsCommandTest extends OrmFunctionalTestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var \Symfony\Component\Console\Application |
|
17
|
|
|
*/ |
|
18
|
|
|
private $application; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand |
|
22
|
|
|
*/ |
|
23
|
|
|
private $command; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var \Symfony\Component\Console\Tester\CommandTester |
|
27
|
|
|
*/ |
|
28
|
|
|
private $tester; |
|
29
|
|
|
|
|
30
|
|
|
protected function setUp() |
|
31
|
|
|
{ |
|
32
|
|
|
parent::setUp(); |
|
33
|
|
|
|
|
34
|
|
|
$this->application = new Application(); |
|
35
|
|
|
$command = new EnsureProductionSettingsCommand(); |
|
36
|
|
|
|
|
37
|
|
|
$this->application->setHelperSet(new HelperSet(array( |
|
38
|
|
|
'em' => new EntityManagerHelper($this->_em) |
|
39
|
|
|
))); |
|
40
|
|
|
|
|
41
|
|
|
$this->application->add($command); |
|
42
|
|
|
|
|
43
|
|
|
$this->command = $this->application->find('orm:ensure-production-settings'); |
|
44
|
|
|
$this->tester = new CommandTester($command); |
|
45
|
|
|
$this->enableProductionSettings(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testWillNotCheckConnection() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->tester->execute(array( |
|
51
|
|
|
'command' => $this->command->getName(), |
|
52
|
|
|
'--complete' => false |
|
53
|
|
|
)); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertContains('Environment is correctly configured for production.', $this->tester->getDisplay()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testWillCheckConnection() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->tester->execute(array( |
|
61
|
|
|
'command' => $this->command->getName(), |
|
62
|
|
|
'--complete' => true |
|
63
|
|
|
)); |
|
64
|
|
|
|
|
65
|
|
|
$this->assertContains('Environment is correctly configured for production.', $this->tester->getDisplay()); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
private function enableProductionSettings() |
|
69
|
|
|
{ |
|
70
|
|
|
$config = $this->_em->getConfiguration(); |
|
71
|
|
|
$config->setMetadataCacheImpl(new MemcachedCache); |
|
72
|
|
|
$config->setQueryCacheImpl(new MemcachedCache); |
|
73
|
|
|
$config->setResultCacheImpl(new MemcachedCache); |
|
74
|
|
|
$config->setAutoGenerateProxyClasses(false); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|