1 | <?php |
||
23 | class CKEditorInstallerCommandTest extends AbstractTestCase |
||
24 | { |
||
25 | /** |
||
26 | * @var Application |
||
27 | */ |
||
28 | private $application; |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | protected function setUp() |
||
34 | { |
||
35 | $this->application = new Application(); |
||
36 | $this->application->addCommands([new CKEditorInstallerCommand()]); |
||
37 | |||
38 | $this->tearDown(); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | protected function tearDown() |
||
45 | { |
||
46 | if (file_exists($path = __DIR__.'/../../Resources/public')) { |
||
47 | exec('rm -rf '.$path); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @group installation |
||
53 | */ |
||
54 | public function testInstall() |
||
55 | { |
||
56 | $command = $this->application->find('ckeditor:install'); |
||
57 | |||
58 | $tester = new CommandTester($command); |
||
59 | $tester->execute(['command' => $command->getName()]); |
||
60 | |||
61 | $this->assertInstall($tester); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @group installation |
||
66 | */ |
||
67 | public function testReinstall() |
||
68 | { |
||
69 | if (!method_exists(CommandTester::class, 'setInputs')) { |
||
70 | $this->markTestSkipped(); |
||
71 | } |
||
72 | |||
73 | $command = $this->application->find('ckeditor:install'); |
||
74 | |||
75 | $tester1 = new CommandTester($command); |
||
76 | $tester1->execute($input = ['command' => $command->getName()]); |
||
77 | |||
78 | $tester2 = new CommandTester($command); |
||
79 | $tester2->setInputs([CKEditorInstaller::CLEAR_DROP]); |
||
80 | $tester2->execute($input); |
||
81 | |||
82 | $this->assertInstall($tester1); |
||
83 | $this->assertInstall($tester2); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param CommandTester $tester |
||
88 | */ |
||
89 | private function assertInstall(CommandTester $tester) |
||
90 | { |
||
91 | $this->assertContains('[OK] - CKEditor has been successfully installed...', $tester->getDisplay()); |
||
92 | } |
||
93 | } |
||
94 |