1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DoctrineModuleTest\Controller; |
6
|
|
|
|
7
|
|
|
use DoctrineModuleTest\Controller\Mock\FailingCommand; |
8
|
|
|
use DoctrineModuleTest\ServiceManagerFactory; |
9
|
|
|
use Laminas\Console\Request; |
10
|
|
|
use Laminas\Test\PHPUnit\Controller\AbstractConsoleControllerTestCase; |
11
|
|
|
use Symfony\Component\Console\Output\BufferedOutput; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Tests for {@see \DoctrineModule\Controller\CliController} |
15
|
|
|
* |
16
|
|
|
* @covers \DoctrineModule\Controller\CliController |
17
|
|
|
*/ |
18
|
|
|
class CliControllerTest extends AbstractConsoleControllerTestCase |
19
|
|
|
{ |
20
|
|
|
protected function setUp() : void |
21
|
|
|
{ |
22
|
|
|
$this->setApplicationConfig(ServiceManagerFactory::getConfiguration()); |
23
|
|
|
parent::setUp(); |
24
|
|
|
|
25
|
|
|
$this->output = new BufferedOutput(); |
|
|
|
|
26
|
|
|
$controller = $this->getApplicationServiceLocator() |
27
|
|
|
->get('ControllerManager') |
28
|
|
|
->get('DoctrineModule\Controller\Cli'); |
29
|
|
|
$controller->setOutput($this->output); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$this->getApplicationServiceLocator()->get('doctrine.cli') |
32
|
|
|
->add(new FailingCommand()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Verifies that the controller handling the DoctrineModule CLI functionality can be reached |
37
|
|
|
*/ |
38
|
|
|
public function testIndexActionCanBeAccessed() : void |
39
|
|
|
{ |
40
|
|
|
$this->dispatch(new Request(['scriptname.php', 'list'])); |
41
|
|
|
|
42
|
|
|
$this->assertResponseStatusCode(0); |
43
|
|
|
$this->assertModuleName('doctrinemodule'); |
44
|
|
|
$this->assertControllerName('doctrinemodule\controller\cli'); |
45
|
|
|
$this->assertControllerClass('clicontroller'); |
46
|
|
|
$this->assertActionName('cli'); |
47
|
|
|
$this->assertMatchedRouteName('doctrine_cli'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testNonZeroExitCode() : void |
51
|
|
|
{ |
52
|
|
|
$this->dispatch(new Request(['scriptname.php', 'fail'])); |
53
|
|
|
|
54
|
|
|
$this->assertNotResponseStatusCode(0); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testException() : void |
58
|
|
|
{ |
59
|
|
|
$this->dispatch(new Request(['scriptname.php', '-q', 'fail', '--exception'])); |
60
|
|
|
|
61
|
|
|
$this->assertNotResponseStatusCode(0); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.