Skip to content

Commit 23d6238

Browse files
author
steve.brazier
committed
add tests for plugin executor logging
1 parent bad0737 commit 23d6238

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Tests/PHPCI/Plugin/Util/ExecutorTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,35 @@ public function testExecutePlugin_ReturnsPluginSuccess()
8686
$this->assertEquals($expectedReturnValue, $returnValue);
8787
}
8888

89+
public function testExecutePlugin_LogsFailureForNonExistentClasses()
90+
{
91+
$options = array();
92+
$pluginName = 'DOESNTEXIST';
93+
$pluginNamespace = 'PHPCI\\Plugin\\';
94+
95+
$this->mockBuildLogger->logFailure('Plugin does not exist: ' . $pluginName)->shouldBeCalledTimes(1);
96+
97+
$this->testedExecutor->executePlugin($pluginName, $options);
98+
}
99+
100+
public function testExecutePlugin_LogsFailureWhenExceptionsAreThrownByPlugin()
101+
{
102+
$options = array();
103+
$pluginName = 'PhpUnit';
104+
$pluginNamespace = 'PHPCI\\Plugin\\';
105+
106+
$expectedException = new \RuntimeException("Generic Error");
107+
108+
$mockPlugin = $this->prophesize('PHPCI\Plugin');
109+
$mockPlugin->execute()->willThrow($expectedException);
110+
111+
$this->mockFactory->buildPlugin($pluginNamespace . $pluginName, $options)->willReturn($mockPlugin->reveal());
112+
113+
$this->mockBuildLogger->logFailure('EXCEPTION: ' . $expectedException->getMessage(), $expectedException)
114+
->shouldBeCalledTimes(1);
115+
116+
$this->testedExecutor->executePlugin($pluginName, $options);
117+
}
118+
89119
}
90120

0 commit comments

Comments
 (0)