Skip to content

Commit 795fab5

Browse files
author
Tom Van Herreweghe
committed
Corrected stubbing of root function
Signed-off-by: Tom Van Herreweghe <[email protected]>
1 parent a862bea commit 795fab5

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

Diff for: tests/PHPExif/Adapter/ExiftoolProcOpenTest.php

+28-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
<?php
2+
// disable the mock by default
3+
namespace
4+
{
5+
$mockProcOpen = false;
6+
}
27

3-
namespace PHPExif\Tests\Adapter {
8+
// same namespace as SUT
9+
namespace PHPExif\Adapter
10+
{
411

5-
function proc_open()
12+
// stub the function
13+
function proc_open($cmd, array $descriptorspec , &$pipes = array())
614
{
15+
global $mockProcOpen;
16+
if (isset($mockProcOpen) && !$mockProcOpen) {
17+
return \proc_open(
18+
$cmd,
19+
$descriptorspec,
20+
$pipes
21+
);
22+
}
723
return false;
824
}
925

10-
include __DIR__ . '/../../../lib/PHPExif/Adapter/Exiftool.php';
11-
1226
/**
1327
* @covers \PHPExif\Adapter\Exiftool::<!public>
1428
*/
@@ -21,11 +35,21 @@ class ExiftoolProcOpenTest extends \PHPUnit_Framework_TestCase
2135

2236
public function setUp()
2337
{
38+
global $mockProcOpen;
39+
$mockProcOpen = true;
2440
$this->adapter = new \PHPExif\Adapter\Exiftool();
2541
}
42+
43+
public function tearDown()
44+
{
45+
global $mockProcOpen;
46+
$mockProcOpen = false;
47+
}
48+
2649
/**
2750
* @group exiftool
2851
* @covers \PHPExif\Adapter\Exiftool::getCliOutput
52+
* @expectedException RuntimeException
2953
*/
3054
public function testGetCliOutput()
3155
{
@@ -39,8 +63,6 @@ public function testGetCliOutput()
3963
'pwd'
4064
)
4165
);
42-
43-
$this->assertInternalType('string', $result);
4466
}
4567
}
4668
}

0 commit comments

Comments
 (0)