1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File ProcessFactoryTest.php |
4
|
|
|
* |
5
|
|
|
* @author Edward Pfremmer <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
namespace Epfremme\ProcessQueue\Tests\Process; |
8
|
|
|
|
9
|
|
|
use Epfremme\ProcessQueue\Process\ProcessFactory; |
10
|
|
|
use Symfony\Component\Process\Process; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class ProcessFactoryTest |
14
|
|
|
* |
15
|
|
|
* @package Epfremme\ProcessQueue\Tests\Process |
16
|
|
|
*/ |
17
|
|
|
class ProcessFactoryTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
public function testConstruct() |
20
|
|
|
{ |
21
|
|
|
$factory = new ProcessFactory('pwd'); |
22
|
|
|
|
23
|
|
|
$this->assertAttributeEquals('pwd', 'cmd', $factory); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testMake() |
27
|
|
|
{ |
28
|
|
|
$factory = new ProcessFactory('pwd'); |
29
|
|
|
|
30
|
|
|
/** @var \SplFileInfo|\Mockery\MockInterface $fileinfo */ |
31
|
|
|
$fileinfo = \Mockery::mock(\SplFileInfo::class); |
32
|
|
|
$fileinfo->shouldReceive('__toString')->andReturn('/tmp'); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$process = $factory->make($fileinfo); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$this->assertInstanceOf(Process::class, $process); |
37
|
|
|
$this->assertEquals('pwd', $process->getCommandLine()); |
38
|
|
|
$this->assertSame($fileinfo, $process->getWorkingDirectory()); |
39
|
|
|
$this->assertFalse($process->isStarted()); |
40
|
|
|
$this->assertFalse($process->isRunning()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** @expectedException \Epfremme\ProcessQueue\Process\Exception\InvalidWorkingDirectoryException */ |
44
|
|
|
public function testMakeException() |
45
|
|
|
{ |
46
|
|
|
$factory = new ProcessFactory('pwd'); |
47
|
|
|
|
48
|
|
|
$factory->make('/invalid/directory'); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: