Expanded InstallerTest to support expecting Exceptions by supplying "EXCEPTION" as "--EXPECT--"
parent
7b6ccde97a
commit
e5fe3d8a3b
|
@ -158,6 +158,8 @@ class InstallerTest extends TestCase
|
||||||
->method('writeError')
|
->method('writeError')
|
||||||
->will($this->returnCallback($callback));
|
->will($this->returnCallback($callback));
|
||||||
|
|
||||||
|
// Prepare for exceptions
|
||||||
|
try {
|
||||||
$composer = FactoryMock::create($io, $composerConfig);
|
$composer = FactoryMock::create($io, $composerConfig);
|
||||||
|
|
||||||
$jsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock();
|
$jsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock();
|
||||||
|
@ -249,6 +251,17 @@ class InstallerTest extends TestCase
|
||||||
$this->assertEquals(rtrim($expectOutput), rtrim($output));
|
$this->assertEquals(rtrim($expectOutput), rtrim($output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
// Exception was thrown during execution
|
||||||
|
if (!$expect || !$expectOutput) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
$this->assertEquals('EXCEPTION', rtrim($expect));
|
||||||
|
$normalizedOutput = rtrim(str_replace("\n", PHP_EOL, $expectOutput));
|
||||||
|
$this->assertEquals($normalizedOutput, rtrim($e->getMessage()));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public function getIntegrationTests()
|
public function getIntegrationTests()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue