1
0
Fork 0

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

pull/4838/head
Niels Keurentjes 2016-01-27 10:04:45 +01:00
parent 7b6ccde97a
commit e5fe3d8a3b
1 changed files with 97 additions and 84 deletions

View File

@ -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()
{