This repository was archived by the owner on Mar 15, 2020. It is now read-only.
forked from padraic/phpunit-accelerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestListenerTest.php
78 lines (63 loc) · 1.66 KB
/
TestListenerTest.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
use MyBuilder\PhpunitAccelerator\TestListener;
class TestListenerTest extends \PHPUnit\Framework\TestCase
{
private $listener;
private $dummyTest;
private $listenerFiltersShutdownFunction;
private $dummyTestRegistersShutdownFunction;
protected function setUp()
{
$this->listener = new TestListener();
$this->dummyTest = new DummyTest();
$this->listenerFiltersShutdownFunction = new TestListener(true);
$this->dummyTestRegistersShutdownFunction = new DummyTestRegistersShutdownFunction();
}
/**
* @test
*/
public function shouldFreeProperty()
{
$this->endTest();
$this->assertNull($this->dummyTest->property);
}
/**
* @test
*/
public function shouldNotFreePhpUnitProperty()
{
$this->endTest();
$this->assertNotNull($this->dummyTest->phpUnitProperty);
}
/**
* @test
*/
public function shouldNotFreePhpUnitPropertyIfRegistersShutdownFunction()
{
$this->listenerFiltersShutdownFunction->endTest(
$this->dummyTestRegistersShutdownFunction,
0
);
$this->assertNotNull($this->dummyTestRegistersShutdownFunction->property);
}
private function endTest()
{
$this->listener->endTest($this->dummyTest, 0);
}
}
class PHPUnit_Fake extends \PHPUnit\Framework\TestCase
{
public $phpUnitProperty = 1;
}
class DummyTest extends \PHPUnit_Fake
{
public $property = 1;
}
class DummyTestRegistersShutdownFunction extends \PHPUnit_Fake
{
public $property = 1;
function foo()
{
register_shutdown_function(function() {return;});
}
}