Expanded InstallerTest to support expecting Exceptions by supplying "EXCEPTION" as "--EXPECT--"

main
Niels Keurentjes 9 years ago
parent 7b6ccde97a
commit e5fe3d8a3b

@ -158,6 +158,8 @@ class InstallerTest extends TestCase
->method('writeError')
->will($this->returnCallback($callback));
// Prepare for exceptions
try {
$composer = FactoryMock::create($io, $composerConfig);
$jsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock();
@ -249,6 +251,17 @@ class InstallerTest extends TestCase
$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()
{

Loading…
Cancel
Save