1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Paraunit\Tests\Unit\Process; |
4
|
|
|
|
5
|
|
|
use Paraunit\Process\ProcessFactory; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class ProcessFactoryTest |
9
|
|
|
* @package Paraunit\Tests\Unit\Process |
10
|
|
|
*/ |
11
|
|
|
class ProcessFactoryTest extends \PHPUnit_Framework_TestCase |
12
|
|
|
{ |
13
|
|
|
public function testCreateProcess() |
14
|
|
|
{ |
15
|
|
|
$phpUnitBin = $this->prophesize('Paraunit\Configuration\PHPUnitBinFile'); |
16
|
|
|
$phpUnitBin->getPhpUnitBin()->shouldBeCalled()->willReturn('phpunit'); |
17
|
|
|
|
18
|
|
|
$phpUnitConfigFile = $this->prophesize('Paraunit\Configuration\PHPUnitConfigFile'); |
19
|
|
|
$phpUnitConfigFile->getFileFullPath()->shouldBeCalled()->willReturn('configFile.xml'); |
20
|
|
|
|
21
|
|
|
$fileName = $this->prophesize('Paraunit\Configuration\JSONLogFilename'); |
22
|
|
|
$fileName->generateFromUniqueId(md5('TestTest.php'))->willReturn('log.json'); |
23
|
|
|
|
24
|
|
|
$factory = new ProcessFactory($phpUnitBin->reveal(), $fileName->reveal()); |
25
|
|
|
$factory->setConfigFile($phpUnitConfigFile->reveal()); |
26
|
|
|
|
27
|
|
|
$process = $factory->createProcess('TestTest.php'); |
28
|
|
|
|
29
|
|
|
$this->assertInstanceOf('Paraunit\Process\ParaunitProcessAbstract', $process); |
30
|
|
|
$expectedCmdLine = 'phpunit ' |
31
|
|
|
. '-c configFile.xml ' |
32
|
|
|
. '--colors=never ' |
33
|
|
|
. '--log-json=log.json ' |
34
|
|
|
. 'TestTest.php ' |
35
|
|
|
. '2>&1'; |
36
|
|
|
$this->assertEquals($expectedCmdLine, $process->getCommandLine()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testCreateProcessThrowsExceptionIfConfigIsMissing() |
40
|
|
|
{ |
41
|
|
|
$phpUnitBin = $this->prophesize('Paraunit\Configuration\PHPUnitBinFile'); |
42
|
|
|
$fileName = $this->prophesize('Paraunit\Configuration\JSONLogFileName'); |
43
|
|
|
|
44
|
|
|
$factory = new ProcessFactory($phpUnitBin->reveal(), $fileName->reveal()); |
45
|
|
|
|
46
|
|
|
$this->setExpectedException('\Exception', 'config missing'); |
47
|
|
|
$factory->createProcess('test'); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|