BlacklistTest.php
3.2 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
* This file is part of the GlobalState package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\GlobalState;
use PHPUnit_Framework_TestCase;
/**
*/
class BlacklistTest extends PHPUnit_Framework_TestCase
{
/**
* @var \SebastianBergmann\GlobalState\Blacklist
*/
private $blacklist;
protected function setUp()
{
$this->blacklist = new Blacklist;
}
public function testGlobalVariableThatIsNotBlacklistedIsNotTreatedAsBlacklisted()
{
$this->assertFalse($this->blacklist->isGlobalVariableBlacklisted('variable'));
}
public function testGlobalVariableCanBeBlacklisted()
{
$this->blacklist->addGlobalVariable('variable');
$this->assertTrue($this->blacklist->isGlobalVariableBlacklisted('variable'));
}
public function testStaticAttributeThatIsNotBlacklistedIsNotTreatedAsBlacklisted()
{
$this->assertFalse(
$this->blacklist->isStaticAttributeBlacklisted(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
'attribute'
)
);
}
public function testClassCanBeBlacklisted()
{
$this->blacklist->addClass('SebastianBergmann\GlobalState\TestFixture\BlacklistedClass');
$this->assertTrue(
$this->blacklist->isStaticAttributeBlacklisted(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
'attribute'
)
);
}
public function testSubclassesCanBeBlacklisted()
{
$this->blacklist->addSubclassesOf('SebastianBergmann\GlobalState\TestFixture\BlacklistedClass');
$this->assertTrue(
$this->blacklist->isStaticAttributeBlacklisted(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedChildClass',
'attribute'
)
);
}
public function testImplementorsCanBeBlacklisted()
{
$this->blacklist->addImplementorsOf('SebastianBergmann\GlobalState\TestFixture\BlacklistedInterface');
$this->assertTrue(
$this->blacklist->isStaticAttributeBlacklisted(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedImplementor',
'attribute'
)
);
}
public function testClassNamePrefixesCanBeBlacklisted()
{
$this->blacklist->addClassNamePrefix('SebastianBergmann\GlobalState');
$this->assertTrue(
$this->blacklist->isStaticAttributeBlacklisted(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
'attribute'
)
);
}
public function testStaticAttributeCanBeBlacklisted()
{
$this->blacklist->addStaticAttribute(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
'attribute'
);
$this->assertTrue(
$this->blacklist->isStaticAttributeBlacklisted(
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
'attribute'
)
);
}
}