-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathIntegrationTest.php
More file actions
37 lines (30 loc) · 989 Bytes
/
IntegrationTest.php
File metadata and controls
37 lines (30 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace PHPUnitTests\Extension;
use PHPUnit\Extension\FunctionMocker;
use PHPUnit\Framework\TestCase;
require_once __DIR__ . '/Fixtures/TestClass.php';
class IntegrationTest extends TestCase
{
private $php;
protected function setUp(): void
{
$this->php = FunctionMocker::start($this, 'PHPUnitTests\Extension\Fixtures')
->mockFunction('strpos')
->getMock();
}
public function testMocked()
{
$this->php
->expects($this->once())
->method('strpos')
->with('ffoo', 'o')
->will($this->returnValue('mocked'));
$this->assertSame('mocked', \PHPUnitTests\Extension\Fixtures\TestClass::invokeGlobalFunction());
}
public function testMockingGlobalFunctionAndCallingOriginalAgain()
{
$this->testMocked();
FunctionMocker::tearDown();
$this->assertSame(2, \PHPUnitTests\Extension\Fixtures\TestClass::invokeGlobalFunction());
}
}