Completed
Push — output_parsers_refactor ( 710907...9ffc6c )
by Alessandro
02:42
created

testCreateProcessThrowsExceptionIfConfigIsMissing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
47
        $factory->createProcess('test');
48
    }
49
}
50