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

ProcessFactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
c 4
b 0
f 0
lcom 1
cbo 4
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testCreateProcess() 0 25 1
A testCreateProcessThrowsExceptionIfConfigIsMissing() 0 10 1
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