@@ 35-59 (lines=25) @@ | ||
32 | )); |
|
33 | } |
|
34 | ||
35 | public function testExecute() |
|
36 | { |
|
37 | $application = new \Phinx\Console\PhinxApplication('testing'); |
|
38 | $application->add(new Status()); |
|
39 | ||
40 | // setup dependencies |
|
41 | $output = new StreamOutput(fopen('php://memory', 'a', false)); |
|
42 | ||
43 | $command = $application->find('status'); |
|
44 | ||
45 | // mock the manager class |
|
46 | $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $output)); |
|
47 | $managerStub->expects($this->once()) |
|
48 | ->method('printStatus') |
|
49 | ->will($this->returnValue(0)); |
|
50 | ||
51 | $command->setConfig($this->config); |
|
52 | $command->setManager($managerStub); |
|
53 | ||
54 | $commandTester = new CommandTester($command); |
|
55 | $return = $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); |
|
56 | ||
57 | $this->assertEquals(0, $return); |
|
58 | $this->assertRegExp('/no environment specified/', $commandTester->getDisplay()); |
|
59 | } |
|
60 | ||
61 | public function testExecuteWithEnvironmentOption() |
|
62 | { |
|
@@ 61-84 (lines=24) @@ | ||
58 | $this->assertRegExp('/no environment specified/', $commandTester->getDisplay()); |
|
59 | } |
|
60 | ||
61 | public function testExecuteWithEnvironmentOption() |
|
62 | { |
|
63 | $application = new \Phinx\Console\PhinxApplication('testing'); |
|
64 | $application->add(new Status()); |
|
65 | ||
66 | // setup dependencies |
|
67 | $output = new StreamOutput(fopen('php://memory', 'a', false)); |
|
68 | ||
69 | $command = $application->find('status'); |
|
70 | ||
71 | // mock the manager class |
|
72 | $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $output)); |
|
73 | $managerStub->expects($this->once()) |
|
74 | ->method('printStatus') |
|
75 | ->will($this->returnValue(0)); |
|
76 | ||
77 | $command->setConfig($this->config); |
|
78 | $command->setManager($managerStub); |
|
79 | ||
80 | $commandTester = new CommandTester($command); |
|
81 | $return = $commandTester->execute(array('command' => $command->getName(), '--environment' => 'fakeenv'), array('decorated' => false)); |
|
82 | $this->assertEquals(0, $return); |
|
83 | $this->assertRegExp('/using environment fakeenv/', $commandTester->getDisplay()); |
|
84 | } |
|
85 | ||
86 | public function testFormatSpecified() |
|
87 | { |
|
@@ 86-109 (lines=24) @@ | ||
83 | $this->assertRegExp('/using environment fakeenv/', $commandTester->getDisplay()); |
|
84 | } |
|
85 | ||
86 | public function testFormatSpecified() |
|
87 | { |
|
88 | $application = new \Phinx\Console\PhinxApplication('testing'); |
|
89 | $application->add(new Status()); |
|
90 | ||
91 | // setup dependencies |
|
92 | $output = new StreamOutput(fopen('php://memory', 'a', false)); |
|
93 | ||
94 | $command = $application->find('status'); |
|
95 | ||
96 | // mock the manager class |
|
97 | $managerStub = $this->getMock('\Phinx\Migration\Manager', array(), array($this->config, $output)); |
|
98 | $managerStub->expects($this->once()) |
|
99 | ->method('printStatus') |
|
100 | ->will($this->returnValue(0)); |
|
101 | ||
102 | $command->setConfig($this->config); |
|
103 | $command->setManager($managerStub); |
|
104 | ||
105 | $commandTester = new CommandTester($command); |
|
106 | $return = $commandTester->execute(array('command' => $command->getName(), '--format' => 'json'), array('decorated' => false)); |
|
107 | $this->assertEquals(0, $return); |
|
108 | $this->assertRegExp('/using format json/', $commandTester->getDisplay()); |
|
109 | } |
|
110 | } |
|
111 |