@@ -14,183 +14,183 @@ |
||
14 | 14 | |
15 | 15 | class FilterTest extends TestCase |
16 | 16 | { |
17 | - /** |
|
18 | - * @var Filter |
|
19 | - */ |
|
20 | - private $filter; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - private $files = []; |
|
26 | - |
|
27 | - protected function setUp() |
|
28 | - { |
|
29 | - $this->filter = unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}'); |
|
30 | - |
|
31 | - $this->files = [ |
|
32 | - TEST_FILES_PATH . 'BankAccount.php', |
|
33 | - TEST_FILES_PATH . 'BankAccountTest.php', |
|
34 | - TEST_FILES_PATH . 'CoverageClassExtendedTest.php', |
|
35 | - TEST_FILES_PATH . 'CoverageClassTest.php', |
|
36 | - TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php', |
|
37 | - TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php', |
|
38 | - TEST_FILES_PATH . 'CoverageFunctionTest.php', |
|
39 | - TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php', |
|
40 | - TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php', |
|
41 | - TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php', |
|
42 | - TEST_FILES_PATH . 'CoverageMethodTest.php', |
|
43 | - TEST_FILES_PATH . 'CoverageNoneTest.php', |
|
44 | - TEST_FILES_PATH . 'CoverageNotPrivateTest.php', |
|
45 | - TEST_FILES_PATH . 'CoverageNotProtectedTest.php', |
|
46 | - TEST_FILES_PATH . 'CoverageNotPublicTest.php', |
|
47 | - TEST_FILES_PATH . 'CoverageNothingTest.php', |
|
48 | - TEST_FILES_PATH . 'CoveragePrivateTest.php', |
|
49 | - TEST_FILES_PATH . 'CoverageProtectedTest.php', |
|
50 | - TEST_FILES_PATH . 'CoveragePublicTest.php', |
|
51 | - TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php', |
|
52 | - TEST_FILES_PATH . 'CoveredClass.php', |
|
53 | - TEST_FILES_PATH . 'CoveredFunction.php', |
|
54 | - TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php', |
|
55 | - TEST_FILES_PATH . 'NamespaceCoverageClassTest.php', |
|
56 | - TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php', |
|
57 | - TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php', |
|
58 | - TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php', |
|
59 | - TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php', |
|
60 | - TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php', |
|
61 | - TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php', |
|
62 | - TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php', |
|
63 | - TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php', |
|
64 | - TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php', |
|
65 | - TEST_FILES_PATH . 'NamespaceCoveredClass.php', |
|
66 | - TEST_FILES_PATH . 'NotExistingCoveredElementTest.php', |
|
67 | - TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php', |
|
68 | - TEST_FILES_PATH . 'source_with_ignore.php', |
|
69 | - TEST_FILES_PATH . 'source_with_namespace.php', |
|
70 | - TEST_FILES_PATH . 'source_with_oneline_annotations.php', |
|
71 | - TEST_FILES_PATH . 'source_without_ignore.php', |
|
72 | - TEST_FILES_PATH . 'source_without_namespace.php' |
|
73 | - ]; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist |
|
78 | - * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
79 | - */ |
|
80 | - public function testAddingAFileToTheWhitelistWorks() |
|
81 | - { |
|
82 | - $this->filter->addFileToWhitelist($this->files[0]); |
|
83 | - |
|
84 | - $this->assertEquals( |
|
85 | - [$this->files[0]], |
|
86 | - $this->filter->getWhitelist() |
|
87 | - ); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @covers SebastianBergmann\CodeCoverage\Filter::removeFileFromWhitelist |
|
92 | - * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
93 | - */ |
|
94 | - public function testRemovingAFileFromTheWhitelistWorks() |
|
95 | - { |
|
96 | - $this->filter->addFileToWhitelist($this->files[0]); |
|
97 | - $this->filter->removeFileFromWhitelist($this->files[0]); |
|
98 | - |
|
99 | - $this->assertEquals([], $this->filter->getWhitelist()); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @covers SebastianBergmann\CodeCoverage\Filter::addDirectoryToWhitelist |
|
104 | - * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
105 | - * @depends testAddingAFileToTheWhitelistWorks |
|
106 | - */ |
|
107 | - public function testAddingADirectoryToTheWhitelistWorks() |
|
108 | - { |
|
109 | - $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
110 | - |
|
111 | - $whitelist = $this->filter->getWhitelist(); |
|
112 | - sort($whitelist); |
|
113 | - |
|
114 | - $this->assertEquals($this->files, $whitelist); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @covers SebastianBergmann\CodeCoverage\Filter::addFilesToWhitelist |
|
119 | - * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
120 | - */ |
|
121 | - public function testAddingFilesToTheWhitelistWorks() |
|
122 | - { |
|
123 | - $facade = new \File_Iterator_Facade; |
|
124 | - |
|
125 | - $files = $facade->getFilesAsArray( |
|
126 | - TEST_FILES_PATH, |
|
127 | - $suffixes = '.php' |
|
128 | - ); |
|
129 | - |
|
130 | - $this->filter->addFilesToWhitelist($files); |
|
131 | - |
|
132 | - $whitelist = $this->filter->getWhitelist(); |
|
133 | - sort($whitelist); |
|
134 | - |
|
135 | - $this->assertEquals($this->files, $whitelist); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @covers SebastianBergmann\CodeCoverage\Filter::removeDirectoryFromWhitelist |
|
140 | - * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
141 | - * @depends testAddingADirectoryToTheWhitelistWorks |
|
142 | - */ |
|
143 | - public function testRemovingADirectoryFromTheWhitelistWorks() |
|
144 | - { |
|
145 | - $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
146 | - $this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH); |
|
147 | - |
|
148 | - $this->assertEquals([], $this->filter->getWhitelist()); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @covers SebastianBergmann\CodeCoverage\Filter::isFile |
|
153 | - */ |
|
154 | - public function testIsFile() |
|
155 | - { |
|
156 | - $this->assertFalse($this->filter->isFile('vfs://root/a/path')); |
|
157 | - $this->assertFalse($this->filter->isFile('xdebug://debug-eval')); |
|
158 | - $this->assertFalse($this->filter->isFile('eval()\'d code')); |
|
159 | - $this->assertFalse($this->filter->isFile('runtime-created function')); |
|
160 | - $this->assertFalse($this->filter->isFile('assert code')); |
|
161 | - $this->assertFalse($this->filter->isFile('regexp code')); |
|
162 | - $this->assertTrue($this->filter->isFile(__FILE__)); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @covers SebastianBergmann\CodeCoverage\Filter::isFiltered |
|
167 | - */ |
|
168 | - public function testWhitelistedFileIsNotFiltered() |
|
169 | - { |
|
170 | - $this->filter->addFileToWhitelist($this->files[0]); |
|
171 | - $this->assertFalse($this->filter->isFiltered($this->files[0])); |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @covers SebastianBergmann\CodeCoverage\Filter::isFiltered |
|
176 | - */ |
|
177 | - public function testNotWhitelistedFileIsFiltered() |
|
178 | - { |
|
179 | - $this->filter->addFileToWhitelist($this->files[0]); |
|
180 | - $this->assertTrue($this->filter->isFiltered($this->files[1])); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * @covers SebastianBergmann\CodeCoverage\Filter::isFiltered |
|
185 | - * @covers SebastianBergmann\CodeCoverage\Filter::isFile |
|
186 | - */ |
|
187 | - public function testNonFilesAreFiltered() |
|
188 | - { |
|
189 | - $this->assertTrue($this->filter->isFiltered('vfs://root/a/path')); |
|
190 | - $this->assertTrue($this->filter->isFiltered('xdebug://debug-eval')); |
|
191 | - $this->assertTrue($this->filter->isFiltered('eval()\'d code')); |
|
192 | - $this->assertTrue($this->filter->isFiltered('runtime-created function')); |
|
193 | - $this->assertTrue($this->filter->isFiltered('assert code')); |
|
194 | - $this->assertTrue($this->filter->isFiltered('regexp code')); |
|
195 | - } |
|
17 | + /** |
|
18 | + * @var Filter |
|
19 | + */ |
|
20 | + private $filter; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + private $files = []; |
|
26 | + |
|
27 | + protected function setUp() |
|
28 | + { |
|
29 | + $this->filter = unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}'); |
|
30 | + |
|
31 | + $this->files = [ |
|
32 | + TEST_FILES_PATH . 'BankAccount.php', |
|
33 | + TEST_FILES_PATH . 'BankAccountTest.php', |
|
34 | + TEST_FILES_PATH . 'CoverageClassExtendedTest.php', |
|
35 | + TEST_FILES_PATH . 'CoverageClassTest.php', |
|
36 | + TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php', |
|
37 | + TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php', |
|
38 | + TEST_FILES_PATH . 'CoverageFunctionTest.php', |
|
39 | + TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php', |
|
40 | + TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php', |
|
41 | + TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php', |
|
42 | + TEST_FILES_PATH . 'CoverageMethodTest.php', |
|
43 | + TEST_FILES_PATH . 'CoverageNoneTest.php', |
|
44 | + TEST_FILES_PATH . 'CoverageNotPrivateTest.php', |
|
45 | + TEST_FILES_PATH . 'CoverageNotProtectedTest.php', |
|
46 | + TEST_FILES_PATH . 'CoverageNotPublicTest.php', |
|
47 | + TEST_FILES_PATH . 'CoverageNothingTest.php', |
|
48 | + TEST_FILES_PATH . 'CoveragePrivateTest.php', |
|
49 | + TEST_FILES_PATH . 'CoverageProtectedTest.php', |
|
50 | + TEST_FILES_PATH . 'CoveragePublicTest.php', |
|
51 | + TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php', |
|
52 | + TEST_FILES_PATH . 'CoveredClass.php', |
|
53 | + TEST_FILES_PATH . 'CoveredFunction.php', |
|
54 | + TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php', |
|
55 | + TEST_FILES_PATH . 'NamespaceCoverageClassTest.php', |
|
56 | + TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php', |
|
57 | + TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php', |
|
58 | + TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php', |
|
59 | + TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php', |
|
60 | + TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php', |
|
61 | + TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php', |
|
62 | + TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php', |
|
63 | + TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php', |
|
64 | + TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php', |
|
65 | + TEST_FILES_PATH . 'NamespaceCoveredClass.php', |
|
66 | + TEST_FILES_PATH . 'NotExistingCoveredElementTest.php', |
|
67 | + TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php', |
|
68 | + TEST_FILES_PATH . 'source_with_ignore.php', |
|
69 | + TEST_FILES_PATH . 'source_with_namespace.php', |
|
70 | + TEST_FILES_PATH . 'source_with_oneline_annotations.php', |
|
71 | + TEST_FILES_PATH . 'source_without_ignore.php', |
|
72 | + TEST_FILES_PATH . 'source_without_namespace.php' |
|
73 | + ]; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist |
|
78 | + * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
79 | + */ |
|
80 | + public function testAddingAFileToTheWhitelistWorks() |
|
81 | + { |
|
82 | + $this->filter->addFileToWhitelist($this->files[0]); |
|
83 | + |
|
84 | + $this->assertEquals( |
|
85 | + [$this->files[0]], |
|
86 | + $this->filter->getWhitelist() |
|
87 | + ); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @covers SebastianBergmann\CodeCoverage\Filter::removeFileFromWhitelist |
|
92 | + * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
93 | + */ |
|
94 | + public function testRemovingAFileFromTheWhitelistWorks() |
|
95 | + { |
|
96 | + $this->filter->addFileToWhitelist($this->files[0]); |
|
97 | + $this->filter->removeFileFromWhitelist($this->files[0]); |
|
98 | + |
|
99 | + $this->assertEquals([], $this->filter->getWhitelist()); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @covers SebastianBergmann\CodeCoverage\Filter::addDirectoryToWhitelist |
|
104 | + * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
105 | + * @depends testAddingAFileToTheWhitelistWorks |
|
106 | + */ |
|
107 | + public function testAddingADirectoryToTheWhitelistWorks() |
|
108 | + { |
|
109 | + $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
110 | + |
|
111 | + $whitelist = $this->filter->getWhitelist(); |
|
112 | + sort($whitelist); |
|
113 | + |
|
114 | + $this->assertEquals($this->files, $whitelist); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @covers SebastianBergmann\CodeCoverage\Filter::addFilesToWhitelist |
|
119 | + * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
120 | + */ |
|
121 | + public function testAddingFilesToTheWhitelistWorks() |
|
122 | + { |
|
123 | + $facade = new \File_Iterator_Facade; |
|
124 | + |
|
125 | + $files = $facade->getFilesAsArray( |
|
126 | + TEST_FILES_PATH, |
|
127 | + $suffixes = '.php' |
|
128 | + ); |
|
129 | + |
|
130 | + $this->filter->addFilesToWhitelist($files); |
|
131 | + |
|
132 | + $whitelist = $this->filter->getWhitelist(); |
|
133 | + sort($whitelist); |
|
134 | + |
|
135 | + $this->assertEquals($this->files, $whitelist); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @covers SebastianBergmann\CodeCoverage\Filter::removeDirectoryFromWhitelist |
|
140 | + * @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist |
|
141 | + * @depends testAddingADirectoryToTheWhitelistWorks |
|
142 | + */ |
|
143 | + public function testRemovingADirectoryFromTheWhitelistWorks() |
|
144 | + { |
|
145 | + $this->filter->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
146 | + $this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH); |
|
147 | + |
|
148 | + $this->assertEquals([], $this->filter->getWhitelist()); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @covers SebastianBergmann\CodeCoverage\Filter::isFile |
|
153 | + */ |
|
154 | + public function testIsFile() |
|
155 | + { |
|
156 | + $this->assertFalse($this->filter->isFile('vfs://root/a/path')); |
|
157 | + $this->assertFalse($this->filter->isFile('xdebug://debug-eval')); |
|
158 | + $this->assertFalse($this->filter->isFile('eval()\'d code')); |
|
159 | + $this->assertFalse($this->filter->isFile('runtime-created function')); |
|
160 | + $this->assertFalse($this->filter->isFile('assert code')); |
|
161 | + $this->assertFalse($this->filter->isFile('regexp code')); |
|
162 | + $this->assertTrue($this->filter->isFile(__FILE__)); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @covers SebastianBergmann\CodeCoverage\Filter::isFiltered |
|
167 | + */ |
|
168 | + public function testWhitelistedFileIsNotFiltered() |
|
169 | + { |
|
170 | + $this->filter->addFileToWhitelist($this->files[0]); |
|
171 | + $this->assertFalse($this->filter->isFiltered($this->files[0])); |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @covers SebastianBergmann\CodeCoverage\Filter::isFiltered |
|
176 | + */ |
|
177 | + public function testNotWhitelistedFileIsFiltered() |
|
178 | + { |
|
179 | + $this->filter->addFileToWhitelist($this->files[0]); |
|
180 | + $this->assertTrue($this->filter->isFiltered($this->files[1])); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * @covers SebastianBergmann\CodeCoverage\Filter::isFiltered |
|
185 | + * @covers SebastianBergmann\CodeCoverage\Filter::isFile |
|
186 | + */ |
|
187 | + public function testNonFilesAreFiltered() |
|
188 | + { |
|
189 | + $this->assertTrue($this->filter->isFiltered('vfs://root/a/path')); |
|
190 | + $this->assertTrue($this->filter->isFiltered('xdebug://debug-eval')); |
|
191 | + $this->assertTrue($this->filter->isFiltered('eval()\'d code')); |
|
192 | + $this->assertTrue($this->filter->isFiltered('runtime-created function')); |
|
193 | + $this->assertTrue($this->filter->isFiltered('assert code')); |
|
194 | + $this->assertTrue($this->filter->isFiltered('regexp code')); |
|
195 | + } |
|
196 | 196 | } |
@@ -29,47 +29,47 @@ |
||
29 | 29 | $this->filter = unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}'); |
30 | 30 | |
31 | 31 | $this->files = [ |
32 | - TEST_FILES_PATH . 'BankAccount.php', |
|
33 | - TEST_FILES_PATH . 'BankAccountTest.php', |
|
34 | - TEST_FILES_PATH . 'CoverageClassExtendedTest.php', |
|
35 | - TEST_FILES_PATH . 'CoverageClassTest.php', |
|
36 | - TEST_FILES_PATH . 'CoverageFunctionParenthesesTest.php', |
|
37 | - TEST_FILES_PATH . 'CoverageFunctionParenthesesWhitespaceTest.php', |
|
38 | - TEST_FILES_PATH . 'CoverageFunctionTest.php', |
|
39 | - TEST_FILES_PATH . 'CoverageMethodOneLineAnnotationTest.php', |
|
40 | - TEST_FILES_PATH . 'CoverageMethodParenthesesTest.php', |
|
41 | - TEST_FILES_PATH . 'CoverageMethodParenthesesWhitespaceTest.php', |
|
42 | - TEST_FILES_PATH . 'CoverageMethodTest.php', |
|
43 | - TEST_FILES_PATH . 'CoverageNoneTest.php', |
|
44 | - TEST_FILES_PATH . 'CoverageNotPrivateTest.php', |
|
45 | - TEST_FILES_PATH . 'CoverageNotProtectedTest.php', |
|
46 | - TEST_FILES_PATH . 'CoverageNotPublicTest.php', |
|
47 | - TEST_FILES_PATH . 'CoverageNothingTest.php', |
|
48 | - TEST_FILES_PATH . 'CoveragePrivateTest.php', |
|
49 | - TEST_FILES_PATH . 'CoverageProtectedTest.php', |
|
50 | - TEST_FILES_PATH . 'CoveragePublicTest.php', |
|
51 | - TEST_FILES_PATH . 'CoverageTwoDefaultClassAnnotations.php', |
|
52 | - TEST_FILES_PATH . 'CoveredClass.php', |
|
53 | - TEST_FILES_PATH . 'CoveredFunction.php', |
|
54 | - TEST_FILES_PATH . 'NamespaceCoverageClassExtendedTest.php', |
|
55 | - TEST_FILES_PATH . 'NamespaceCoverageClassTest.php', |
|
56 | - TEST_FILES_PATH . 'NamespaceCoverageCoversClassPublicTest.php', |
|
57 | - TEST_FILES_PATH . 'NamespaceCoverageCoversClassTest.php', |
|
58 | - TEST_FILES_PATH . 'NamespaceCoverageMethodTest.php', |
|
59 | - TEST_FILES_PATH . 'NamespaceCoverageNotPrivateTest.php', |
|
60 | - TEST_FILES_PATH . 'NamespaceCoverageNotProtectedTest.php', |
|
61 | - TEST_FILES_PATH . 'NamespaceCoverageNotPublicTest.php', |
|
62 | - TEST_FILES_PATH . 'NamespaceCoveragePrivateTest.php', |
|
63 | - TEST_FILES_PATH . 'NamespaceCoverageProtectedTest.php', |
|
64 | - TEST_FILES_PATH . 'NamespaceCoveragePublicTest.php', |
|
65 | - TEST_FILES_PATH . 'NamespaceCoveredClass.php', |
|
66 | - TEST_FILES_PATH . 'NotExistingCoveredElementTest.php', |
|
67 | - TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php', |
|
68 | - TEST_FILES_PATH . 'source_with_ignore.php', |
|
69 | - TEST_FILES_PATH . 'source_with_namespace.php', |
|
70 | - TEST_FILES_PATH . 'source_with_oneline_annotations.php', |
|
71 | - TEST_FILES_PATH . 'source_without_ignore.php', |
|
72 | - TEST_FILES_PATH . 'source_without_namespace.php' |
|
32 | + TEST_FILES_PATH.'BankAccount.php', |
|
33 | + TEST_FILES_PATH.'BankAccountTest.php', |
|
34 | + TEST_FILES_PATH.'CoverageClassExtendedTest.php', |
|
35 | + TEST_FILES_PATH.'CoverageClassTest.php', |
|
36 | + TEST_FILES_PATH.'CoverageFunctionParenthesesTest.php', |
|
37 | + TEST_FILES_PATH.'CoverageFunctionParenthesesWhitespaceTest.php', |
|
38 | + TEST_FILES_PATH.'CoverageFunctionTest.php', |
|
39 | + TEST_FILES_PATH.'CoverageMethodOneLineAnnotationTest.php', |
|
40 | + TEST_FILES_PATH.'CoverageMethodParenthesesTest.php', |
|
41 | + TEST_FILES_PATH.'CoverageMethodParenthesesWhitespaceTest.php', |
|
42 | + TEST_FILES_PATH.'CoverageMethodTest.php', |
|
43 | + TEST_FILES_PATH.'CoverageNoneTest.php', |
|
44 | + TEST_FILES_PATH.'CoverageNotPrivateTest.php', |
|
45 | + TEST_FILES_PATH.'CoverageNotProtectedTest.php', |
|
46 | + TEST_FILES_PATH.'CoverageNotPublicTest.php', |
|
47 | + TEST_FILES_PATH.'CoverageNothingTest.php', |
|
48 | + TEST_FILES_PATH.'CoveragePrivateTest.php', |
|
49 | + TEST_FILES_PATH.'CoverageProtectedTest.php', |
|
50 | + TEST_FILES_PATH.'CoveragePublicTest.php', |
|
51 | + TEST_FILES_PATH.'CoverageTwoDefaultClassAnnotations.php', |
|
52 | + TEST_FILES_PATH.'CoveredClass.php', |
|
53 | + TEST_FILES_PATH.'CoveredFunction.php', |
|
54 | + TEST_FILES_PATH.'NamespaceCoverageClassExtendedTest.php', |
|
55 | + TEST_FILES_PATH.'NamespaceCoverageClassTest.php', |
|
56 | + TEST_FILES_PATH.'NamespaceCoverageCoversClassPublicTest.php', |
|
57 | + TEST_FILES_PATH.'NamespaceCoverageCoversClassTest.php', |
|
58 | + TEST_FILES_PATH.'NamespaceCoverageMethodTest.php', |
|
59 | + TEST_FILES_PATH.'NamespaceCoverageNotPrivateTest.php', |
|
60 | + TEST_FILES_PATH.'NamespaceCoverageNotProtectedTest.php', |
|
61 | + TEST_FILES_PATH.'NamespaceCoverageNotPublicTest.php', |
|
62 | + TEST_FILES_PATH.'NamespaceCoveragePrivateTest.php', |
|
63 | + TEST_FILES_PATH.'NamespaceCoverageProtectedTest.php', |
|
64 | + TEST_FILES_PATH.'NamespaceCoveragePublicTest.php', |
|
65 | + TEST_FILES_PATH.'NamespaceCoveredClass.php', |
|
66 | + TEST_FILES_PATH.'NotExistingCoveredElementTest.php', |
|
67 | + TEST_FILES_PATH.'source_with_class_and_anonymous_function.php', |
|
68 | + TEST_FILES_PATH.'source_with_ignore.php', |
|
69 | + TEST_FILES_PATH.'source_with_namespace.php', |
|
70 | + TEST_FILES_PATH.'source_with_oneline_annotations.php', |
|
71 | + TEST_FILES_PATH.'source_without_ignore.php', |
|
72 | + TEST_FILES_PATH.'source_without_namespace.php' |
|
73 | 73 | ]; |
74 | 74 | } |
75 | 75 |
@@ -14,90 +14,90 @@ |
||
14 | 14 | |
15 | 15 | class HTMLTest extends TestCase |
16 | 16 | { |
17 | - private static $TEST_REPORT_PATH_SOURCE; |
|
18 | - |
|
19 | - public static function setUpBeforeClass() |
|
20 | - { |
|
21 | - parent::setUpBeforeClass(); |
|
22 | - |
|
23 | - self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML'; |
|
24 | - } |
|
25 | - |
|
26 | - protected function tearDown() |
|
27 | - { |
|
28 | - parent::tearDown(); |
|
29 | - |
|
30 | - $tmpFilesIterator = new \RecursiveIteratorIterator( |
|
31 | - new \RecursiveDirectoryIterator(self::$TEST_TMP_PATH, \RecursiveDirectoryIterator::SKIP_DOTS), |
|
32 | - \RecursiveIteratorIterator::CHILD_FIRST |
|
33 | - ); |
|
34 | - |
|
35 | - foreach ($tmpFilesIterator as $path => $fileInfo) { |
|
36 | - /* @var \SplFileInfo $fileInfo */ |
|
37 | - $pathname = $fileInfo->getPathname(); |
|
38 | - $fileInfo->isDir() ? rmdir($pathname) : unlink($pathname); |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - public function testForBankAccountTest() |
|
43 | - { |
|
44 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount'; |
|
45 | - |
|
46 | - $report = new Facade; |
|
47 | - $report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH); |
|
48 | - |
|
49 | - $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
50 | - } |
|
51 | - |
|
52 | - public function testForFileWithIgnoredLines() |
|
53 | - { |
|
54 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines'; |
|
55 | - |
|
56 | - $report = new Facade; |
|
57 | - $report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH); |
|
58 | - |
|
59 | - $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
60 | - } |
|
61 | - |
|
62 | - public function testForClassWithAnonymousFunction() |
|
63 | - { |
|
64 | - $expectedFilesPath = |
|
65 | - self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction'; |
|
66 | - |
|
67 | - $report = new Facade; |
|
68 | - $report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH); |
|
69 | - |
|
70 | - $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @param string $expectedFilesPath |
|
75 | - * @param string $actualFilesPath |
|
76 | - */ |
|
77 | - private function assertFilesEquals($expectedFilesPath, $actualFilesPath) |
|
78 | - { |
|
79 | - $expectedFilesIterator = new \FilesystemIterator($expectedFilesPath); |
|
80 | - $actualFilesIterator = new \RegexIterator(new \FilesystemIterator($actualFilesPath), '/.html/'); |
|
81 | - |
|
82 | - $this->assertEquals( |
|
83 | - iterator_count($expectedFilesIterator), |
|
84 | - iterator_count($actualFilesIterator), |
|
85 | - 'Generated files and expected files not match' |
|
86 | - ); |
|
87 | - |
|
88 | - foreach ($expectedFilesIterator as $path => $fileInfo) { |
|
89 | - /* @var \SplFileInfo $fileInfo */ |
|
90 | - $filename = $fileInfo->getFilename(); |
|
91 | - |
|
92 | - $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename; |
|
93 | - |
|
94 | - $this->assertFileExists($actualFile); |
|
95 | - |
|
96 | - $this->assertStringMatchesFormatFile( |
|
97 | - $fileInfo->getPathname(), |
|
98 | - str_replace(PHP_EOL, "\n", file_get_contents($actualFile)), |
|
99 | - "${filename} not match" |
|
100 | - ); |
|
101 | - } |
|
102 | - } |
|
17 | + private static $TEST_REPORT_PATH_SOURCE; |
|
18 | + |
|
19 | + public static function setUpBeforeClass() |
|
20 | + { |
|
21 | + parent::setUpBeforeClass(); |
|
22 | + |
|
23 | + self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML'; |
|
24 | + } |
|
25 | + |
|
26 | + protected function tearDown() |
|
27 | + { |
|
28 | + parent::tearDown(); |
|
29 | + |
|
30 | + $tmpFilesIterator = new \RecursiveIteratorIterator( |
|
31 | + new \RecursiveDirectoryIterator(self::$TEST_TMP_PATH, \RecursiveDirectoryIterator::SKIP_DOTS), |
|
32 | + \RecursiveIteratorIterator::CHILD_FIRST |
|
33 | + ); |
|
34 | + |
|
35 | + foreach ($tmpFilesIterator as $path => $fileInfo) { |
|
36 | + /* @var \SplFileInfo $fileInfo */ |
|
37 | + $pathname = $fileInfo->getPathname(); |
|
38 | + $fileInfo->isDir() ? rmdir($pathname) : unlink($pathname); |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + public function testForBankAccountTest() |
|
43 | + { |
|
44 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount'; |
|
45 | + |
|
46 | + $report = new Facade; |
|
47 | + $report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH); |
|
48 | + |
|
49 | + $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
50 | + } |
|
51 | + |
|
52 | + public function testForFileWithIgnoredLines() |
|
53 | + { |
|
54 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines'; |
|
55 | + |
|
56 | + $report = new Facade; |
|
57 | + $report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH); |
|
58 | + |
|
59 | + $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
60 | + } |
|
61 | + |
|
62 | + public function testForClassWithAnonymousFunction() |
|
63 | + { |
|
64 | + $expectedFilesPath = |
|
65 | + self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction'; |
|
66 | + |
|
67 | + $report = new Facade; |
|
68 | + $report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH); |
|
69 | + |
|
70 | + $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @param string $expectedFilesPath |
|
75 | + * @param string $actualFilesPath |
|
76 | + */ |
|
77 | + private function assertFilesEquals($expectedFilesPath, $actualFilesPath) |
|
78 | + { |
|
79 | + $expectedFilesIterator = new \FilesystemIterator($expectedFilesPath); |
|
80 | + $actualFilesIterator = new \RegexIterator(new \FilesystemIterator($actualFilesPath), '/.html/'); |
|
81 | + |
|
82 | + $this->assertEquals( |
|
83 | + iterator_count($expectedFilesIterator), |
|
84 | + iterator_count($actualFilesIterator), |
|
85 | + 'Generated files and expected files not match' |
|
86 | + ); |
|
87 | + |
|
88 | + foreach ($expectedFilesIterator as $path => $fileInfo) { |
|
89 | + /* @var \SplFileInfo $fileInfo */ |
|
90 | + $filename = $fileInfo->getFilename(); |
|
91 | + |
|
92 | + $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename; |
|
93 | + |
|
94 | + $this->assertFileExists($actualFile); |
|
95 | + |
|
96 | + $this->assertStringMatchesFormatFile( |
|
97 | + $fileInfo->getPathname(), |
|
98 | + str_replace(PHP_EOL, "\n", file_get_contents($actualFile)), |
|
99 | + "${filename} not match" |
|
100 | + ); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | parent::setUpBeforeClass(); |
22 | 22 | |
23 | - self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML'; |
|
23 | + self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH.'Report'.DIRECTORY_SEPARATOR.'HTML'; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | protected function tearDown() |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function testForBankAccountTest() |
43 | 43 | { |
44 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount'; |
|
44 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE.DIRECTORY_SEPARATOR.'CoverageForBankAccount'; |
|
45 | 45 | |
46 | 46 | $report = new Facade; |
47 | 47 | $report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | public function testForFileWithIgnoredLines() |
53 | 53 | { |
54 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines'; |
|
54 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE.DIRECTORY_SEPARATOR.'CoverageForFileWithIgnoredLines'; |
|
55 | 55 | |
56 | 56 | $report = new Facade; |
57 | 57 | $report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function testForClassWithAnonymousFunction() |
63 | 63 | { |
64 | 64 | $expectedFilesPath = |
65 | - self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction'; |
|
65 | + self::$TEST_REPORT_PATH_SOURCE.DIRECTORY_SEPARATOR.'CoverageForClassWithAnonymousFunction'; |
|
66 | 66 | |
67 | 67 | $report = new Facade; |
68 | 68 | $report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | /* @var \SplFileInfo $fileInfo */ |
90 | 90 | $filename = $fileInfo->getFilename(); |
91 | 91 | |
92 | - $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename; |
|
92 | + $actualFile = $actualFilesPath.DIRECTORY_SEPARATOR.$filename; |
|
93 | 93 | |
94 | 94 | $this->assertFileExists($actualFile); |
95 | 95 |
@@ -15,198 +15,198 @@ |
||
15 | 15 | |
16 | 16 | class BuilderTest extends TestCase |
17 | 17 | { |
18 | - protected $factory; |
|
19 | - |
|
20 | - protected function setUp() |
|
21 | - { |
|
22 | - $this->factory = new Builder; |
|
23 | - } |
|
24 | - |
|
25 | - public function testSomething() |
|
26 | - { |
|
27 | - $root = $this->getCoverageForBankAccount()->getReport(); |
|
28 | - |
|
29 | - $expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR); |
|
30 | - $this->assertEquals($expectedPath, $root->getName()); |
|
31 | - $this->assertEquals($expectedPath, $root->getPath()); |
|
32 | - $this->assertEquals(10, $root->getNumExecutableLines()); |
|
33 | - $this->assertEquals(5, $root->getNumExecutedLines()); |
|
34 | - $this->assertEquals(1, $root->getNumClasses()); |
|
35 | - $this->assertEquals(0, $root->getNumTestedClasses()); |
|
36 | - $this->assertEquals(4, $root->getNumMethods()); |
|
37 | - $this->assertEquals(3, $root->getNumTestedMethods()); |
|
38 | - $this->assertEquals('0.00%', $root->getTestedClassesPercent()); |
|
39 | - $this->assertEquals('75.00%', $root->getTestedMethodsPercent()); |
|
40 | - $this->assertEquals('50.00%', $root->getLineExecutedPercent()); |
|
41 | - $this->assertEquals(0, $root->getNumFunctions()); |
|
42 | - $this->assertEquals(0, $root->getNumTestedFunctions()); |
|
43 | - $this->assertNull($root->getParent()); |
|
44 | - $this->assertEquals([], $root->getDirectories()); |
|
45 | - #$this->assertEquals(array(), $root->getFiles()); |
|
46 | - #$this->assertEquals(array(), $root->getChildNodes()); |
|
47 | - |
|
48 | - $this->assertEquals( |
|
49 | - [ |
|
50 | - 'BankAccount' => [ |
|
51 | - 'methods' => [ |
|
52 | - 'getBalance' => [ |
|
53 | - 'signature' => 'getBalance()', |
|
54 | - 'startLine' => 6, |
|
55 | - 'endLine' => 9, |
|
56 | - 'executableLines' => 1, |
|
57 | - 'executedLines' => 1, |
|
58 | - 'ccn' => 1, |
|
59 | - 'coverage' => 100, |
|
60 | - 'crap' => '1', |
|
61 | - 'link' => 'BankAccount.php.html#6', |
|
62 | - 'methodName' => 'getBalance', |
|
63 | - 'visibility' => 'public', |
|
64 | - ], |
|
65 | - 'setBalance' => [ |
|
66 | - 'signature' => 'setBalance($balance)', |
|
67 | - 'startLine' => 11, |
|
68 | - 'endLine' => 18, |
|
69 | - 'executableLines' => 5, |
|
70 | - 'executedLines' => 0, |
|
71 | - 'ccn' => 2, |
|
72 | - 'coverage' => 0, |
|
73 | - 'crap' => 6, |
|
74 | - 'link' => 'BankAccount.php.html#11', |
|
75 | - 'methodName' => 'setBalance', |
|
76 | - 'visibility' => 'protected', |
|
77 | - ], |
|
78 | - 'depositMoney' => [ |
|
79 | - 'signature' => 'depositMoney($balance)', |
|
80 | - 'startLine' => 20, |
|
81 | - 'endLine' => 25, |
|
82 | - 'executableLines' => 2, |
|
83 | - 'executedLines' => 2, |
|
84 | - 'ccn' => 1, |
|
85 | - 'coverage' => 100, |
|
86 | - 'crap' => '1', |
|
87 | - 'link' => 'BankAccount.php.html#20', |
|
88 | - 'methodName' => 'depositMoney', |
|
89 | - 'visibility' => 'public', |
|
90 | - ], |
|
91 | - 'withdrawMoney' => [ |
|
92 | - 'signature' => 'withdrawMoney($balance)', |
|
93 | - 'startLine' => 27, |
|
94 | - 'endLine' => 32, |
|
95 | - 'executableLines' => 2, |
|
96 | - 'executedLines' => 2, |
|
97 | - 'ccn' => 1, |
|
98 | - 'coverage' => 100, |
|
99 | - 'crap' => '1', |
|
100 | - 'link' => 'BankAccount.php.html#27', |
|
101 | - 'methodName' => 'withdrawMoney', |
|
102 | - 'visibility' => 'public', |
|
103 | - ], |
|
104 | - ], |
|
105 | - 'startLine' => 2, |
|
106 | - 'executableLines' => 10, |
|
107 | - 'executedLines' => 5, |
|
108 | - 'ccn' => 5, |
|
109 | - 'coverage' => 50, |
|
110 | - 'crap' => '8.12', |
|
111 | - 'package' => [ |
|
112 | - 'namespace' => '', |
|
113 | - 'fullPackage' => '', |
|
114 | - 'category' => '', |
|
115 | - 'package' => '', |
|
116 | - 'subpackage' => '' |
|
117 | - ], |
|
118 | - 'link' => 'BankAccount.php.html#2', |
|
119 | - 'className' => 'BankAccount' |
|
120 | - ] |
|
121 | - ], |
|
122 | - $root->getClasses() |
|
123 | - ); |
|
124 | - |
|
125 | - $this->assertEquals([], $root->getFunctions()); |
|
126 | - } |
|
127 | - |
|
128 | - public function testBuildDirectoryStructure() |
|
129 | - { |
|
130 | - $method = new \ReflectionMethod( |
|
131 | - Builder::class, |
|
132 | - 'buildDirectoryStructure' |
|
133 | - ); |
|
134 | - |
|
135 | - $method->setAccessible(true); |
|
136 | - |
|
137 | - $this->assertEquals( |
|
138 | - [ |
|
139 | - 'src' => [ |
|
140 | - 'Money.php/f' => [], |
|
141 | - 'MoneyBag.php/f' => [] |
|
142 | - ] |
|
143 | - ], |
|
144 | - $method->invoke( |
|
145 | - $this->factory, |
|
146 | - ['src/Money.php' => [], 'src/MoneyBag.php' => []] |
|
147 | - ) |
|
148 | - ); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @dataProvider reducePathsProvider |
|
153 | - */ |
|
154 | - public function testReducePaths($reducedPaths, $commonPath, $paths) |
|
155 | - { |
|
156 | - $method = new \ReflectionMethod( |
|
157 | - Builder::class, |
|
158 | - 'reducePaths' |
|
159 | - ); |
|
160 | - |
|
161 | - $method->setAccessible(true); |
|
162 | - |
|
163 | - $_commonPath = $method->invokeArgs($this->factory, [&$paths]); |
|
164 | - |
|
165 | - $this->assertEquals($reducedPaths, $paths); |
|
166 | - $this->assertEquals($commonPath, $_commonPath); |
|
167 | - } |
|
168 | - |
|
169 | - public function reducePathsProvider() |
|
170 | - { |
|
171 | - return [ |
|
172 | - [ |
|
173 | - [ |
|
174 | - 'Money.php' => [], |
|
175 | - 'MoneyBag.php' => [] |
|
176 | - ], |
|
177 | - '/home/sb/Money', |
|
178 | - [ |
|
179 | - '/home/sb/Money/Money.php' => [], |
|
180 | - '/home/sb/Money/MoneyBag.php' => [] |
|
181 | - ] |
|
182 | - ], |
|
183 | - [ |
|
184 | - [ |
|
185 | - 'Money.php' => [] |
|
186 | - ], |
|
187 | - '/home/sb/Money/', |
|
188 | - [ |
|
189 | - '/home/sb/Money/Money.php' => [] |
|
190 | - ] |
|
191 | - ], |
|
192 | - [ |
|
193 | - [], |
|
194 | - '.', |
|
195 | - [] |
|
196 | - ], |
|
197 | - [ |
|
198 | - [ |
|
199 | - 'Money.php' => [], |
|
200 | - 'MoneyBag.php' => [], |
|
201 | - 'Cash.phar/Cash.php' => [], |
|
202 | - ], |
|
203 | - '/home/sb/Money', |
|
204 | - [ |
|
205 | - '/home/sb/Money/Money.php' => [], |
|
206 | - '/home/sb/Money/MoneyBag.php' => [], |
|
207 | - 'phar:///home/sb/Money/Cash.phar/Cash.php' => [], |
|
208 | - ], |
|
209 | - ], |
|
210 | - ]; |
|
211 | - } |
|
18 | + protected $factory; |
|
19 | + |
|
20 | + protected function setUp() |
|
21 | + { |
|
22 | + $this->factory = new Builder; |
|
23 | + } |
|
24 | + |
|
25 | + public function testSomething() |
|
26 | + { |
|
27 | + $root = $this->getCoverageForBankAccount()->getReport(); |
|
28 | + |
|
29 | + $expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR); |
|
30 | + $this->assertEquals($expectedPath, $root->getName()); |
|
31 | + $this->assertEquals($expectedPath, $root->getPath()); |
|
32 | + $this->assertEquals(10, $root->getNumExecutableLines()); |
|
33 | + $this->assertEquals(5, $root->getNumExecutedLines()); |
|
34 | + $this->assertEquals(1, $root->getNumClasses()); |
|
35 | + $this->assertEquals(0, $root->getNumTestedClasses()); |
|
36 | + $this->assertEquals(4, $root->getNumMethods()); |
|
37 | + $this->assertEquals(3, $root->getNumTestedMethods()); |
|
38 | + $this->assertEquals('0.00%', $root->getTestedClassesPercent()); |
|
39 | + $this->assertEquals('75.00%', $root->getTestedMethodsPercent()); |
|
40 | + $this->assertEquals('50.00%', $root->getLineExecutedPercent()); |
|
41 | + $this->assertEquals(0, $root->getNumFunctions()); |
|
42 | + $this->assertEquals(0, $root->getNumTestedFunctions()); |
|
43 | + $this->assertNull($root->getParent()); |
|
44 | + $this->assertEquals([], $root->getDirectories()); |
|
45 | + #$this->assertEquals(array(), $root->getFiles()); |
|
46 | + #$this->assertEquals(array(), $root->getChildNodes()); |
|
47 | + |
|
48 | + $this->assertEquals( |
|
49 | + [ |
|
50 | + 'BankAccount' => [ |
|
51 | + 'methods' => [ |
|
52 | + 'getBalance' => [ |
|
53 | + 'signature' => 'getBalance()', |
|
54 | + 'startLine' => 6, |
|
55 | + 'endLine' => 9, |
|
56 | + 'executableLines' => 1, |
|
57 | + 'executedLines' => 1, |
|
58 | + 'ccn' => 1, |
|
59 | + 'coverage' => 100, |
|
60 | + 'crap' => '1', |
|
61 | + 'link' => 'BankAccount.php.html#6', |
|
62 | + 'methodName' => 'getBalance', |
|
63 | + 'visibility' => 'public', |
|
64 | + ], |
|
65 | + 'setBalance' => [ |
|
66 | + 'signature' => 'setBalance($balance)', |
|
67 | + 'startLine' => 11, |
|
68 | + 'endLine' => 18, |
|
69 | + 'executableLines' => 5, |
|
70 | + 'executedLines' => 0, |
|
71 | + 'ccn' => 2, |
|
72 | + 'coverage' => 0, |
|
73 | + 'crap' => 6, |
|
74 | + 'link' => 'BankAccount.php.html#11', |
|
75 | + 'methodName' => 'setBalance', |
|
76 | + 'visibility' => 'protected', |
|
77 | + ], |
|
78 | + 'depositMoney' => [ |
|
79 | + 'signature' => 'depositMoney($balance)', |
|
80 | + 'startLine' => 20, |
|
81 | + 'endLine' => 25, |
|
82 | + 'executableLines' => 2, |
|
83 | + 'executedLines' => 2, |
|
84 | + 'ccn' => 1, |
|
85 | + 'coverage' => 100, |
|
86 | + 'crap' => '1', |
|
87 | + 'link' => 'BankAccount.php.html#20', |
|
88 | + 'methodName' => 'depositMoney', |
|
89 | + 'visibility' => 'public', |
|
90 | + ], |
|
91 | + 'withdrawMoney' => [ |
|
92 | + 'signature' => 'withdrawMoney($balance)', |
|
93 | + 'startLine' => 27, |
|
94 | + 'endLine' => 32, |
|
95 | + 'executableLines' => 2, |
|
96 | + 'executedLines' => 2, |
|
97 | + 'ccn' => 1, |
|
98 | + 'coverage' => 100, |
|
99 | + 'crap' => '1', |
|
100 | + 'link' => 'BankAccount.php.html#27', |
|
101 | + 'methodName' => 'withdrawMoney', |
|
102 | + 'visibility' => 'public', |
|
103 | + ], |
|
104 | + ], |
|
105 | + 'startLine' => 2, |
|
106 | + 'executableLines' => 10, |
|
107 | + 'executedLines' => 5, |
|
108 | + 'ccn' => 5, |
|
109 | + 'coverage' => 50, |
|
110 | + 'crap' => '8.12', |
|
111 | + 'package' => [ |
|
112 | + 'namespace' => '', |
|
113 | + 'fullPackage' => '', |
|
114 | + 'category' => '', |
|
115 | + 'package' => '', |
|
116 | + 'subpackage' => '' |
|
117 | + ], |
|
118 | + 'link' => 'BankAccount.php.html#2', |
|
119 | + 'className' => 'BankAccount' |
|
120 | + ] |
|
121 | + ], |
|
122 | + $root->getClasses() |
|
123 | + ); |
|
124 | + |
|
125 | + $this->assertEquals([], $root->getFunctions()); |
|
126 | + } |
|
127 | + |
|
128 | + public function testBuildDirectoryStructure() |
|
129 | + { |
|
130 | + $method = new \ReflectionMethod( |
|
131 | + Builder::class, |
|
132 | + 'buildDirectoryStructure' |
|
133 | + ); |
|
134 | + |
|
135 | + $method->setAccessible(true); |
|
136 | + |
|
137 | + $this->assertEquals( |
|
138 | + [ |
|
139 | + 'src' => [ |
|
140 | + 'Money.php/f' => [], |
|
141 | + 'MoneyBag.php/f' => [] |
|
142 | + ] |
|
143 | + ], |
|
144 | + $method->invoke( |
|
145 | + $this->factory, |
|
146 | + ['src/Money.php' => [], 'src/MoneyBag.php' => []] |
|
147 | + ) |
|
148 | + ); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @dataProvider reducePathsProvider |
|
153 | + */ |
|
154 | + public function testReducePaths($reducedPaths, $commonPath, $paths) |
|
155 | + { |
|
156 | + $method = new \ReflectionMethod( |
|
157 | + Builder::class, |
|
158 | + 'reducePaths' |
|
159 | + ); |
|
160 | + |
|
161 | + $method->setAccessible(true); |
|
162 | + |
|
163 | + $_commonPath = $method->invokeArgs($this->factory, [&$paths]); |
|
164 | + |
|
165 | + $this->assertEquals($reducedPaths, $paths); |
|
166 | + $this->assertEquals($commonPath, $_commonPath); |
|
167 | + } |
|
168 | + |
|
169 | + public function reducePathsProvider() |
|
170 | + { |
|
171 | + return [ |
|
172 | + [ |
|
173 | + [ |
|
174 | + 'Money.php' => [], |
|
175 | + 'MoneyBag.php' => [] |
|
176 | + ], |
|
177 | + '/home/sb/Money', |
|
178 | + [ |
|
179 | + '/home/sb/Money/Money.php' => [], |
|
180 | + '/home/sb/Money/MoneyBag.php' => [] |
|
181 | + ] |
|
182 | + ], |
|
183 | + [ |
|
184 | + [ |
|
185 | + 'Money.php' => [] |
|
186 | + ], |
|
187 | + '/home/sb/Money/', |
|
188 | + [ |
|
189 | + '/home/sb/Money/Money.php' => [] |
|
190 | + ] |
|
191 | + ], |
|
192 | + [ |
|
193 | + [], |
|
194 | + '.', |
|
195 | + [] |
|
196 | + ], |
|
197 | + [ |
|
198 | + [ |
|
199 | + 'Money.php' => [], |
|
200 | + 'MoneyBag.php' => [], |
|
201 | + 'Cash.phar/Cash.php' => [], |
|
202 | + ], |
|
203 | + '/home/sb/Money', |
|
204 | + [ |
|
205 | + '/home/sb/Money/Money.php' => [], |
|
206 | + '/home/sb/Money/MoneyBag.php' => [], |
|
207 | + 'phar:///home/sb/Money/Cash.phar/Cash.php' => [], |
|
208 | + ], |
|
209 | + ], |
|
210 | + ]; |
|
211 | + } |
|
212 | 212 | } |
@@ -17,33 +17,33 @@ |
||
17 | 17 | */ |
18 | 18 | class Crap4jTest extends TestCase |
19 | 19 | { |
20 | - public function testForBankAccountTest() |
|
21 | - { |
|
22 | - $crap4j = new Crap4j; |
|
23 | - |
|
24 | - $this->assertStringMatchesFormatFile( |
|
25 | - TEST_FILES_PATH . 'BankAccount-crap4j.xml', |
|
26 | - $crap4j->process($this->getCoverageForBankAccount(), null, 'BankAccount') |
|
27 | - ); |
|
28 | - } |
|
29 | - |
|
30 | - public function testForFileWithIgnoredLines() |
|
31 | - { |
|
32 | - $crap4j = new Crap4j; |
|
33 | - |
|
34 | - $this->assertStringMatchesFormatFile( |
|
35 | - TEST_FILES_PATH . 'ignored-lines-crap4j.xml', |
|
36 | - $crap4j->process($this->getCoverageForFileWithIgnoredLines(), null, 'CoverageForFileWithIgnoredLines') |
|
37 | - ); |
|
38 | - } |
|
39 | - |
|
40 | - public function testForClassWithAnonymousFunction() |
|
41 | - { |
|
42 | - $crap4j = new Crap4j; |
|
43 | - |
|
44 | - $this->assertStringMatchesFormatFile( |
|
45 | - TEST_FILES_PATH . 'class-with-anonymous-function-crap4j.xml', |
|
46 | - $crap4j->process($this->getCoverageForClassWithAnonymousFunction(), null, 'CoverageForClassWithAnonymousFunction') |
|
47 | - ); |
|
48 | - } |
|
20 | + public function testForBankAccountTest() |
|
21 | + { |
|
22 | + $crap4j = new Crap4j; |
|
23 | + |
|
24 | + $this->assertStringMatchesFormatFile( |
|
25 | + TEST_FILES_PATH . 'BankAccount-crap4j.xml', |
|
26 | + $crap4j->process($this->getCoverageForBankAccount(), null, 'BankAccount') |
|
27 | + ); |
|
28 | + } |
|
29 | + |
|
30 | + public function testForFileWithIgnoredLines() |
|
31 | + { |
|
32 | + $crap4j = new Crap4j; |
|
33 | + |
|
34 | + $this->assertStringMatchesFormatFile( |
|
35 | + TEST_FILES_PATH . 'ignored-lines-crap4j.xml', |
|
36 | + $crap4j->process($this->getCoverageForFileWithIgnoredLines(), null, 'CoverageForFileWithIgnoredLines') |
|
37 | + ); |
|
38 | + } |
|
39 | + |
|
40 | + public function testForClassWithAnonymousFunction() |
|
41 | + { |
|
42 | + $crap4j = new Crap4j; |
|
43 | + |
|
44 | + $this->assertStringMatchesFormatFile( |
|
45 | + TEST_FILES_PATH . 'class-with-anonymous-function-crap4j.xml', |
|
46 | + $crap4j->process($this->getCoverageForClassWithAnonymousFunction(), null, 'CoverageForClassWithAnonymousFunction') |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $crap4j = new Crap4j; |
23 | 23 | |
24 | 24 | $this->assertStringMatchesFormatFile( |
25 | - TEST_FILES_PATH . 'BankAccount-crap4j.xml', |
|
25 | + TEST_FILES_PATH.'BankAccount-crap4j.xml', |
|
26 | 26 | $crap4j->process($this->getCoverageForBankAccount(), null, 'BankAccount') |
27 | 27 | ); |
28 | 28 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $crap4j = new Crap4j; |
33 | 33 | |
34 | 34 | $this->assertStringMatchesFormatFile( |
35 | - TEST_FILES_PATH . 'ignored-lines-crap4j.xml', |
|
35 | + TEST_FILES_PATH.'ignored-lines-crap4j.xml', |
|
36 | 36 | $crap4j->process($this->getCoverageForFileWithIgnoredLines(), null, 'CoverageForFileWithIgnoredLines') |
37 | 37 | ); |
38 | 38 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $crap4j = new Crap4j; |
43 | 43 | |
44 | 44 | $this->assertStringMatchesFormatFile( |
45 | - TEST_FILES_PATH . 'class-with-anonymous-function-crap4j.xml', |
|
45 | + TEST_FILES_PATH.'class-with-anonymous-function-crap4j.xml', |
|
46 | 46 | $crap4j->process($this->getCoverageForClassWithAnonymousFunction(), null, 'CoverageForClassWithAnonymousFunction') |
47 | 47 | ); |
48 | 48 | } |
@@ -18,524 +18,524 @@ |
||
18 | 18 | */ |
19 | 19 | class CodeCoverageTest extends TestCase |
20 | 20 | { |
21 | - /** |
|
22 | - * @var CodeCoverage |
|
23 | - */ |
|
24 | - private $coverage; |
|
25 | - |
|
26 | - protected function setUp() |
|
27 | - { |
|
28 | - $this->coverage = new CodeCoverage; |
|
29 | - } |
|
30 | - |
|
31 | - public function testCanBeConstructedForXdebugWithoutGivenFilterObject() |
|
32 | - { |
|
33 | - if (PHP_SAPI == 'phpdbg') { |
|
34 | - $this->markTestSkipped('Requires PHP CLI and Xdebug'); |
|
35 | - } |
|
36 | - |
|
37 | - $this->assertAttributeInstanceOf( |
|
38 | - Xdebug::class, |
|
39 | - 'driver', |
|
40 | - $this->coverage |
|
41 | - ); |
|
42 | - |
|
43 | - $this->assertAttributeInstanceOf( |
|
44 | - Filter::class, |
|
45 | - 'filter', |
|
46 | - $this->coverage |
|
47 | - ); |
|
48 | - } |
|
49 | - |
|
50 | - public function testCanBeConstructedForXdebugWithGivenFilterObject() |
|
51 | - { |
|
52 | - if (PHP_SAPI == 'phpdbg') { |
|
53 | - $this->markTestSkipped('Requires PHP CLI and Xdebug'); |
|
54 | - } |
|
55 | - |
|
56 | - $filter = new Filter; |
|
57 | - $coverage = new CodeCoverage(null, $filter); |
|
58 | - |
|
59 | - $this->assertAttributeInstanceOf( |
|
60 | - Xdebug::class, |
|
61 | - 'driver', |
|
62 | - $coverage |
|
63 | - ); |
|
64 | - |
|
65 | - $this->assertSame($filter, $coverage->filter()); |
|
66 | - } |
|
67 | - |
|
68 | - public function testCanBeConstructedForPhpdbgWithoutGivenFilterObject() |
|
69 | - { |
|
70 | - if (PHP_SAPI != 'phpdbg') { |
|
71 | - $this->markTestSkipped('Requires PHPDBG'); |
|
72 | - } |
|
73 | - |
|
74 | - $this->assertAttributeInstanceOf( |
|
75 | - PHPDBG::class, |
|
76 | - 'driver', |
|
77 | - $this->coverage |
|
78 | - ); |
|
79 | - |
|
80 | - $this->assertAttributeInstanceOf( |
|
81 | - Filter::class, |
|
82 | - 'filter', |
|
83 | - $this->coverage |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - public function testCanBeConstructedForPhpdbgWithGivenFilterObject() |
|
88 | - { |
|
89 | - if (PHP_SAPI != 'phpdbg') { |
|
90 | - $this->markTestSkipped('Requires PHPDBG'); |
|
91 | - } |
|
92 | - |
|
93 | - $filter = new Filter; |
|
94 | - $coverage = new CodeCoverage(null, $filter); |
|
95 | - |
|
96 | - $this->assertAttributeInstanceOf( |
|
97 | - PHPDBG::class, |
|
98 | - 'driver', |
|
99 | - $coverage |
|
100 | - ); |
|
101 | - |
|
102 | - $this->assertSame($filter, $coverage->filter()); |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
107 | - */ |
|
108 | - public function testCannotStartWithInvalidArgument() |
|
109 | - { |
|
110 | - $this->coverage->start(null, null); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
115 | - */ |
|
116 | - public function testCannotStopWithInvalidFirstArgument() |
|
117 | - { |
|
118 | - $this->coverage->stop(null); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
123 | - */ |
|
124 | - public function testCannotStopWithInvalidSecondArgument() |
|
125 | - { |
|
126 | - $this->coverage->stop(true, null); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
131 | - */ |
|
132 | - public function testCannotAppendWithInvalidArgument() |
|
133 | - { |
|
134 | - $this->coverage->append([], null); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
139 | - */ |
|
140 | - public function testSetCacheTokensThrowsExceptionForInvalidArgument() |
|
141 | - { |
|
142 | - $this->coverage->setCacheTokens(null); |
|
143 | - } |
|
144 | - |
|
145 | - public function testSetCacheTokens() |
|
146 | - { |
|
147 | - $this->coverage->setCacheTokens(true); |
|
148 | - $this->assertAttributeEquals(true, 'cacheTokens', $this->coverage); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
153 | - */ |
|
154 | - public function testSetCheckForUnintentionallyCoveredCodeThrowsExceptionForInvalidArgument() |
|
155 | - { |
|
156 | - $this->coverage->setCheckForUnintentionallyCoveredCode(null); |
|
157 | - } |
|
158 | - |
|
159 | - public function testSetCheckForUnintentionallyCoveredCode() |
|
160 | - { |
|
161 | - $this->coverage->setCheckForUnintentionallyCoveredCode(true); |
|
162 | - $this->assertAttributeEquals( |
|
163 | - true, |
|
164 | - 'checkForUnintentionallyCoveredCode', |
|
165 | - $this->coverage |
|
166 | - ); |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
171 | - */ |
|
172 | - public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument() |
|
173 | - { |
|
174 | - $this->coverage->setForceCoversAnnotation(null); |
|
175 | - } |
|
176 | - |
|
177 | - public function testSetCheckForMissingCoversAnnotation() |
|
178 | - { |
|
179 | - $this->coverage->setCheckForMissingCoversAnnotation(true); |
|
180 | - $this->assertAttributeEquals( |
|
181 | - true, |
|
182 | - 'checkForMissingCoversAnnotation', |
|
183 | - $this->coverage |
|
184 | - ); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
189 | - */ |
|
190 | - public function testSetCheckForMissingCoversAnnotationThrowsExceptionForInvalidArgument() |
|
191 | - { |
|
192 | - $this->coverage->setCheckForMissingCoversAnnotation(null); |
|
193 | - } |
|
194 | - |
|
195 | - public function testSetForceCoversAnnotation() |
|
196 | - { |
|
197 | - $this->coverage->setForceCoversAnnotation(true); |
|
198 | - $this->assertAttributeEquals( |
|
199 | - true, |
|
200 | - 'forceCoversAnnotation', |
|
201 | - $this->coverage |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
207 | - */ |
|
208 | - public function testSetCheckForUnexecutedCoveredCodeThrowsExceptionForInvalidArgument() |
|
209 | - { |
|
210 | - $this->coverage->setCheckForUnexecutedCoveredCode(null); |
|
211 | - } |
|
212 | - |
|
213 | - public function testSetCheckForUnexecutedCoveredCode() |
|
214 | - { |
|
215 | - $this->coverage->setCheckForUnexecutedCoveredCode(true); |
|
216 | - $this->assertAttributeEquals( |
|
217 | - true, |
|
218 | - 'checkForUnexecutedCoveredCode', |
|
219 | - $this->coverage |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
225 | - */ |
|
226 | - public function testSetAddUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() |
|
227 | - { |
|
228 | - $this->coverage->setAddUncoveredFilesFromWhitelist(null); |
|
229 | - } |
|
230 | - |
|
231 | - public function testSetAddUncoveredFilesFromWhitelist() |
|
232 | - { |
|
233 | - $this->coverage->setAddUncoveredFilesFromWhitelist(true); |
|
234 | - $this->assertAttributeEquals( |
|
235 | - true, |
|
236 | - 'addUncoveredFilesFromWhitelist', |
|
237 | - $this->coverage |
|
238 | - ); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
243 | - */ |
|
244 | - public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() |
|
245 | - { |
|
246 | - $this->coverage->setProcessUncoveredFilesFromWhitelist(null); |
|
247 | - } |
|
248 | - |
|
249 | - public function testSetProcessUncoveredFilesFromWhitelist() |
|
250 | - { |
|
251 | - $this->coverage->setProcessUncoveredFilesFromWhitelist(true); |
|
252 | - $this->assertAttributeEquals( |
|
253 | - true, |
|
254 | - 'processUncoveredFilesFromWhitelist', |
|
255 | - $this->coverage |
|
256 | - ); |
|
257 | - } |
|
258 | - |
|
259 | - public function testSetIgnoreDeprecatedCode() |
|
260 | - { |
|
261 | - $this->coverage->setIgnoreDeprecatedCode(true); |
|
262 | - $this->assertAttributeEquals( |
|
263 | - true, |
|
264 | - 'ignoreDeprecatedCode', |
|
265 | - $this->coverage |
|
266 | - ); |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
271 | - */ |
|
272 | - public function testSetIgnoreDeprecatedCodeThrowsExceptionForInvalidArgument() |
|
273 | - { |
|
274 | - $this->coverage->setIgnoreDeprecatedCode(null); |
|
275 | - } |
|
276 | - |
|
277 | - public function testClear() |
|
278 | - { |
|
279 | - $this->coverage->clear(); |
|
280 | - |
|
281 | - $this->assertAttributeEquals(null, 'currentId', $this->coverage); |
|
282 | - $this->assertAttributeEquals([], 'data', $this->coverage); |
|
283 | - $this->assertAttributeEquals([], 'tests', $this->coverage); |
|
284 | - } |
|
285 | - |
|
286 | - public function testCollect() |
|
287 | - { |
|
288 | - $coverage = $this->getCoverageForBankAccount(); |
|
289 | - |
|
290 | - $this->assertEquals( |
|
291 | - $this->getExpectedDataArrayForBankAccount(), |
|
292 | - $coverage->getData() |
|
293 | - ); |
|
294 | - |
|
295 | - $this->assertEquals( |
|
296 | - [ |
|
297 | - 'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => null], |
|
298 | - 'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => null], |
|
299 | - 'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => null], |
|
300 | - 'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => null] |
|
301 | - ], |
|
302 | - $coverage->getTests() |
|
303 | - ); |
|
304 | - } |
|
305 | - |
|
306 | - public function testMerge() |
|
307 | - { |
|
308 | - $coverage = $this->getCoverageForBankAccountForFirstTwoTests(); |
|
309 | - $coverage->merge($this->getCoverageForBankAccountForLastTwoTests()); |
|
310 | - |
|
311 | - $this->assertEquals( |
|
312 | - $this->getExpectedDataArrayForBankAccount(), |
|
313 | - $coverage->getData() |
|
314 | - ); |
|
315 | - } |
|
316 | - |
|
317 | - public function testMerge2() |
|
318 | - { |
|
319 | - $coverage = new CodeCoverage( |
|
320 | - $this->createMock(Xdebug::class), |
|
321 | - new Filter |
|
322 | - ); |
|
323 | - |
|
324 | - $coverage->merge($this->getCoverageForBankAccount()); |
|
325 | - |
|
326 | - $this->assertEquals( |
|
327 | - $this->getExpectedDataArrayForBankAccount(), |
|
328 | - $coverage->getData() |
|
329 | - ); |
|
330 | - } |
|
331 | - |
|
332 | - public function testGetLinesToBeIgnored() |
|
333 | - { |
|
334 | - $this->assertEquals( |
|
335 | - [ |
|
336 | - 1, |
|
337 | - 3, |
|
338 | - 4, |
|
339 | - 5, |
|
340 | - 7, |
|
341 | - 8, |
|
342 | - 9, |
|
343 | - 10, |
|
344 | - 11, |
|
345 | - 12, |
|
346 | - 13, |
|
347 | - 14, |
|
348 | - 15, |
|
349 | - 16, |
|
350 | - 17, |
|
351 | - 18, |
|
352 | - 19, |
|
353 | - 20, |
|
354 | - 21, |
|
355 | - 22, |
|
356 | - 23, |
|
357 | - 24, |
|
358 | - 25, |
|
359 | - 26, |
|
360 | - 27, |
|
361 | - 28, |
|
362 | - 30, |
|
363 | - 32, |
|
364 | - 33, |
|
365 | - 34, |
|
366 | - 35, |
|
367 | - 36, |
|
368 | - 37, |
|
369 | - 38 |
|
370 | - ], |
|
371 | - $this->getLinesToBeIgnored()->invoke( |
|
372 | - $this->coverage, |
|
373 | - TEST_FILES_PATH . 'source_with_ignore.php' |
|
374 | - ) |
|
375 | - ); |
|
376 | - } |
|
377 | - |
|
378 | - public function testGetLinesToBeIgnored2() |
|
379 | - { |
|
380 | - $this->assertEquals( |
|
381 | - [1, 5], |
|
382 | - $this->getLinesToBeIgnored()->invoke( |
|
383 | - $this->coverage, |
|
384 | - TEST_FILES_PATH . 'source_without_ignore.php' |
|
385 | - ) |
|
386 | - ); |
|
387 | - } |
|
388 | - |
|
389 | - public function testGetLinesToBeIgnored3() |
|
390 | - { |
|
391 | - $this->assertEquals( |
|
392 | - [ |
|
393 | - 1, |
|
394 | - 2, |
|
395 | - 3, |
|
396 | - 4, |
|
397 | - 5, |
|
398 | - 8, |
|
399 | - 11, |
|
400 | - 15, |
|
401 | - 16, |
|
402 | - 19, |
|
403 | - 20 |
|
404 | - ], |
|
405 | - $this->getLinesToBeIgnored()->invoke( |
|
406 | - $this->coverage, |
|
407 | - TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' |
|
408 | - ) |
|
409 | - ); |
|
410 | - } |
|
411 | - |
|
412 | - public function testGetLinesToBeIgnoredOneLineAnnotations() |
|
413 | - { |
|
414 | - $this->assertEquals( |
|
415 | - [ |
|
416 | - 1, |
|
417 | - 2, |
|
418 | - 3, |
|
419 | - 4, |
|
420 | - 5, |
|
421 | - 6, |
|
422 | - 7, |
|
423 | - 8, |
|
424 | - 9, |
|
425 | - 10, |
|
426 | - 11, |
|
427 | - 12, |
|
428 | - 13, |
|
429 | - 14, |
|
430 | - 15, |
|
431 | - 16, |
|
432 | - 18, |
|
433 | - 20, |
|
434 | - 21, |
|
435 | - 23, |
|
436 | - 24, |
|
437 | - 25, |
|
438 | - 27, |
|
439 | - 28, |
|
440 | - 29, |
|
441 | - 30, |
|
442 | - 31, |
|
443 | - 32, |
|
444 | - 33, |
|
445 | - 34, |
|
446 | - 37 |
|
447 | - ], |
|
448 | - $this->getLinesToBeIgnored()->invoke( |
|
449 | - $this->coverage, |
|
450 | - TEST_FILES_PATH . 'source_with_oneline_annotations.php' |
|
451 | - ) |
|
452 | - ); |
|
453 | - } |
|
454 | - |
|
455 | - /** |
|
456 | - * @return \ReflectionMethod |
|
457 | - */ |
|
458 | - private function getLinesToBeIgnored() |
|
459 | - { |
|
460 | - $getLinesToBeIgnored = new \ReflectionMethod( |
|
461 | - 'SebastianBergmann\CodeCoverage\CodeCoverage', |
|
462 | - 'getLinesToBeIgnored' |
|
463 | - ); |
|
464 | - |
|
465 | - $getLinesToBeIgnored->setAccessible(true); |
|
466 | - |
|
467 | - return $getLinesToBeIgnored; |
|
468 | - } |
|
469 | - |
|
470 | - public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled() |
|
471 | - { |
|
472 | - $this->coverage->setDisableIgnoredLines(true); |
|
473 | - |
|
474 | - $this->assertEquals( |
|
475 | - [], |
|
476 | - $this->getLinesToBeIgnored()->invoke( |
|
477 | - $this->coverage, |
|
478 | - TEST_FILES_PATH . 'source_with_ignore.php' |
|
479 | - ) |
|
480 | - ); |
|
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * @expectedException SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException |
|
485 | - */ |
|
486 | - public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted() |
|
487 | - { |
|
488 | - $this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
489 | - $this->coverage->setCheckForUnexecutedCoveredCode(true); |
|
490 | - |
|
491 | - $data = [ |
|
492 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
493 | - 29 => -1, |
|
494 | - 31 => -1 |
|
495 | - ] |
|
496 | - ]; |
|
497 | - |
|
498 | - $linesToBeCovered = [ |
|
499 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
500 | - 22, |
|
501 | - 24 |
|
502 | - ] |
|
503 | - ]; |
|
504 | - |
|
505 | - $linesToBeUsed = []; |
|
506 | - |
|
507 | - $this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed); |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * @expectedException SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException |
|
512 | - */ |
|
513 | - public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted() |
|
514 | - { |
|
515 | - $this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
516 | - $this->coverage->setCheckForUnexecutedCoveredCode(true); |
|
517 | - |
|
518 | - $data = [ |
|
519 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
520 | - 29 => -1, |
|
521 | - 31 => -1 |
|
522 | - ] |
|
523 | - ]; |
|
524 | - |
|
525 | - $linesToBeCovered = [ |
|
526 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
527 | - 29, |
|
528 | - 31 |
|
529 | - ] |
|
530 | - ]; |
|
531 | - |
|
532 | - $linesToBeUsed = [ |
|
533 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
534 | - 22, |
|
535 | - 24 |
|
536 | - ] |
|
537 | - ]; |
|
538 | - |
|
539 | - $this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed); |
|
540 | - } |
|
21 | + /** |
|
22 | + * @var CodeCoverage |
|
23 | + */ |
|
24 | + private $coverage; |
|
25 | + |
|
26 | + protected function setUp() |
|
27 | + { |
|
28 | + $this->coverage = new CodeCoverage; |
|
29 | + } |
|
30 | + |
|
31 | + public function testCanBeConstructedForXdebugWithoutGivenFilterObject() |
|
32 | + { |
|
33 | + if (PHP_SAPI == 'phpdbg') { |
|
34 | + $this->markTestSkipped('Requires PHP CLI and Xdebug'); |
|
35 | + } |
|
36 | + |
|
37 | + $this->assertAttributeInstanceOf( |
|
38 | + Xdebug::class, |
|
39 | + 'driver', |
|
40 | + $this->coverage |
|
41 | + ); |
|
42 | + |
|
43 | + $this->assertAttributeInstanceOf( |
|
44 | + Filter::class, |
|
45 | + 'filter', |
|
46 | + $this->coverage |
|
47 | + ); |
|
48 | + } |
|
49 | + |
|
50 | + public function testCanBeConstructedForXdebugWithGivenFilterObject() |
|
51 | + { |
|
52 | + if (PHP_SAPI == 'phpdbg') { |
|
53 | + $this->markTestSkipped('Requires PHP CLI and Xdebug'); |
|
54 | + } |
|
55 | + |
|
56 | + $filter = new Filter; |
|
57 | + $coverage = new CodeCoverage(null, $filter); |
|
58 | + |
|
59 | + $this->assertAttributeInstanceOf( |
|
60 | + Xdebug::class, |
|
61 | + 'driver', |
|
62 | + $coverage |
|
63 | + ); |
|
64 | + |
|
65 | + $this->assertSame($filter, $coverage->filter()); |
|
66 | + } |
|
67 | + |
|
68 | + public function testCanBeConstructedForPhpdbgWithoutGivenFilterObject() |
|
69 | + { |
|
70 | + if (PHP_SAPI != 'phpdbg') { |
|
71 | + $this->markTestSkipped('Requires PHPDBG'); |
|
72 | + } |
|
73 | + |
|
74 | + $this->assertAttributeInstanceOf( |
|
75 | + PHPDBG::class, |
|
76 | + 'driver', |
|
77 | + $this->coverage |
|
78 | + ); |
|
79 | + |
|
80 | + $this->assertAttributeInstanceOf( |
|
81 | + Filter::class, |
|
82 | + 'filter', |
|
83 | + $this->coverage |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + public function testCanBeConstructedForPhpdbgWithGivenFilterObject() |
|
88 | + { |
|
89 | + if (PHP_SAPI != 'phpdbg') { |
|
90 | + $this->markTestSkipped('Requires PHPDBG'); |
|
91 | + } |
|
92 | + |
|
93 | + $filter = new Filter; |
|
94 | + $coverage = new CodeCoverage(null, $filter); |
|
95 | + |
|
96 | + $this->assertAttributeInstanceOf( |
|
97 | + PHPDBG::class, |
|
98 | + 'driver', |
|
99 | + $coverage |
|
100 | + ); |
|
101 | + |
|
102 | + $this->assertSame($filter, $coverage->filter()); |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
107 | + */ |
|
108 | + public function testCannotStartWithInvalidArgument() |
|
109 | + { |
|
110 | + $this->coverage->start(null, null); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
115 | + */ |
|
116 | + public function testCannotStopWithInvalidFirstArgument() |
|
117 | + { |
|
118 | + $this->coverage->stop(null); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
123 | + */ |
|
124 | + public function testCannotStopWithInvalidSecondArgument() |
|
125 | + { |
|
126 | + $this->coverage->stop(true, null); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
131 | + */ |
|
132 | + public function testCannotAppendWithInvalidArgument() |
|
133 | + { |
|
134 | + $this->coverage->append([], null); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
139 | + */ |
|
140 | + public function testSetCacheTokensThrowsExceptionForInvalidArgument() |
|
141 | + { |
|
142 | + $this->coverage->setCacheTokens(null); |
|
143 | + } |
|
144 | + |
|
145 | + public function testSetCacheTokens() |
|
146 | + { |
|
147 | + $this->coverage->setCacheTokens(true); |
|
148 | + $this->assertAttributeEquals(true, 'cacheTokens', $this->coverage); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
153 | + */ |
|
154 | + public function testSetCheckForUnintentionallyCoveredCodeThrowsExceptionForInvalidArgument() |
|
155 | + { |
|
156 | + $this->coverage->setCheckForUnintentionallyCoveredCode(null); |
|
157 | + } |
|
158 | + |
|
159 | + public function testSetCheckForUnintentionallyCoveredCode() |
|
160 | + { |
|
161 | + $this->coverage->setCheckForUnintentionallyCoveredCode(true); |
|
162 | + $this->assertAttributeEquals( |
|
163 | + true, |
|
164 | + 'checkForUnintentionallyCoveredCode', |
|
165 | + $this->coverage |
|
166 | + ); |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
171 | + */ |
|
172 | + public function testSetForceCoversAnnotationThrowsExceptionForInvalidArgument() |
|
173 | + { |
|
174 | + $this->coverage->setForceCoversAnnotation(null); |
|
175 | + } |
|
176 | + |
|
177 | + public function testSetCheckForMissingCoversAnnotation() |
|
178 | + { |
|
179 | + $this->coverage->setCheckForMissingCoversAnnotation(true); |
|
180 | + $this->assertAttributeEquals( |
|
181 | + true, |
|
182 | + 'checkForMissingCoversAnnotation', |
|
183 | + $this->coverage |
|
184 | + ); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
189 | + */ |
|
190 | + public function testSetCheckForMissingCoversAnnotationThrowsExceptionForInvalidArgument() |
|
191 | + { |
|
192 | + $this->coverage->setCheckForMissingCoversAnnotation(null); |
|
193 | + } |
|
194 | + |
|
195 | + public function testSetForceCoversAnnotation() |
|
196 | + { |
|
197 | + $this->coverage->setForceCoversAnnotation(true); |
|
198 | + $this->assertAttributeEquals( |
|
199 | + true, |
|
200 | + 'forceCoversAnnotation', |
|
201 | + $this->coverage |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
207 | + */ |
|
208 | + public function testSetCheckForUnexecutedCoveredCodeThrowsExceptionForInvalidArgument() |
|
209 | + { |
|
210 | + $this->coverage->setCheckForUnexecutedCoveredCode(null); |
|
211 | + } |
|
212 | + |
|
213 | + public function testSetCheckForUnexecutedCoveredCode() |
|
214 | + { |
|
215 | + $this->coverage->setCheckForUnexecutedCoveredCode(true); |
|
216 | + $this->assertAttributeEquals( |
|
217 | + true, |
|
218 | + 'checkForUnexecutedCoveredCode', |
|
219 | + $this->coverage |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
225 | + */ |
|
226 | + public function testSetAddUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() |
|
227 | + { |
|
228 | + $this->coverage->setAddUncoveredFilesFromWhitelist(null); |
|
229 | + } |
|
230 | + |
|
231 | + public function testSetAddUncoveredFilesFromWhitelist() |
|
232 | + { |
|
233 | + $this->coverage->setAddUncoveredFilesFromWhitelist(true); |
|
234 | + $this->assertAttributeEquals( |
|
235 | + true, |
|
236 | + 'addUncoveredFilesFromWhitelist', |
|
237 | + $this->coverage |
|
238 | + ); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
243 | + */ |
|
244 | + public function testSetProcessUncoveredFilesFromWhitelistThrowsExceptionForInvalidArgument() |
|
245 | + { |
|
246 | + $this->coverage->setProcessUncoveredFilesFromWhitelist(null); |
|
247 | + } |
|
248 | + |
|
249 | + public function testSetProcessUncoveredFilesFromWhitelist() |
|
250 | + { |
|
251 | + $this->coverage->setProcessUncoveredFilesFromWhitelist(true); |
|
252 | + $this->assertAttributeEquals( |
|
253 | + true, |
|
254 | + 'processUncoveredFilesFromWhitelist', |
|
255 | + $this->coverage |
|
256 | + ); |
|
257 | + } |
|
258 | + |
|
259 | + public function testSetIgnoreDeprecatedCode() |
|
260 | + { |
|
261 | + $this->coverage->setIgnoreDeprecatedCode(true); |
|
262 | + $this->assertAttributeEquals( |
|
263 | + true, |
|
264 | + 'ignoreDeprecatedCode', |
|
265 | + $this->coverage |
|
266 | + ); |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * @expectedException SebastianBergmann\CodeCoverage\Exception |
|
271 | + */ |
|
272 | + public function testSetIgnoreDeprecatedCodeThrowsExceptionForInvalidArgument() |
|
273 | + { |
|
274 | + $this->coverage->setIgnoreDeprecatedCode(null); |
|
275 | + } |
|
276 | + |
|
277 | + public function testClear() |
|
278 | + { |
|
279 | + $this->coverage->clear(); |
|
280 | + |
|
281 | + $this->assertAttributeEquals(null, 'currentId', $this->coverage); |
|
282 | + $this->assertAttributeEquals([], 'data', $this->coverage); |
|
283 | + $this->assertAttributeEquals([], 'tests', $this->coverage); |
|
284 | + } |
|
285 | + |
|
286 | + public function testCollect() |
|
287 | + { |
|
288 | + $coverage = $this->getCoverageForBankAccount(); |
|
289 | + |
|
290 | + $this->assertEquals( |
|
291 | + $this->getExpectedDataArrayForBankAccount(), |
|
292 | + $coverage->getData() |
|
293 | + ); |
|
294 | + |
|
295 | + $this->assertEquals( |
|
296 | + [ |
|
297 | + 'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => null], |
|
298 | + 'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => null], |
|
299 | + 'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => null], |
|
300 | + 'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => null] |
|
301 | + ], |
|
302 | + $coverage->getTests() |
|
303 | + ); |
|
304 | + } |
|
305 | + |
|
306 | + public function testMerge() |
|
307 | + { |
|
308 | + $coverage = $this->getCoverageForBankAccountForFirstTwoTests(); |
|
309 | + $coverage->merge($this->getCoverageForBankAccountForLastTwoTests()); |
|
310 | + |
|
311 | + $this->assertEquals( |
|
312 | + $this->getExpectedDataArrayForBankAccount(), |
|
313 | + $coverage->getData() |
|
314 | + ); |
|
315 | + } |
|
316 | + |
|
317 | + public function testMerge2() |
|
318 | + { |
|
319 | + $coverage = new CodeCoverage( |
|
320 | + $this->createMock(Xdebug::class), |
|
321 | + new Filter |
|
322 | + ); |
|
323 | + |
|
324 | + $coverage->merge($this->getCoverageForBankAccount()); |
|
325 | + |
|
326 | + $this->assertEquals( |
|
327 | + $this->getExpectedDataArrayForBankAccount(), |
|
328 | + $coverage->getData() |
|
329 | + ); |
|
330 | + } |
|
331 | + |
|
332 | + public function testGetLinesToBeIgnored() |
|
333 | + { |
|
334 | + $this->assertEquals( |
|
335 | + [ |
|
336 | + 1, |
|
337 | + 3, |
|
338 | + 4, |
|
339 | + 5, |
|
340 | + 7, |
|
341 | + 8, |
|
342 | + 9, |
|
343 | + 10, |
|
344 | + 11, |
|
345 | + 12, |
|
346 | + 13, |
|
347 | + 14, |
|
348 | + 15, |
|
349 | + 16, |
|
350 | + 17, |
|
351 | + 18, |
|
352 | + 19, |
|
353 | + 20, |
|
354 | + 21, |
|
355 | + 22, |
|
356 | + 23, |
|
357 | + 24, |
|
358 | + 25, |
|
359 | + 26, |
|
360 | + 27, |
|
361 | + 28, |
|
362 | + 30, |
|
363 | + 32, |
|
364 | + 33, |
|
365 | + 34, |
|
366 | + 35, |
|
367 | + 36, |
|
368 | + 37, |
|
369 | + 38 |
|
370 | + ], |
|
371 | + $this->getLinesToBeIgnored()->invoke( |
|
372 | + $this->coverage, |
|
373 | + TEST_FILES_PATH . 'source_with_ignore.php' |
|
374 | + ) |
|
375 | + ); |
|
376 | + } |
|
377 | + |
|
378 | + public function testGetLinesToBeIgnored2() |
|
379 | + { |
|
380 | + $this->assertEquals( |
|
381 | + [1, 5], |
|
382 | + $this->getLinesToBeIgnored()->invoke( |
|
383 | + $this->coverage, |
|
384 | + TEST_FILES_PATH . 'source_without_ignore.php' |
|
385 | + ) |
|
386 | + ); |
|
387 | + } |
|
388 | + |
|
389 | + public function testGetLinesToBeIgnored3() |
|
390 | + { |
|
391 | + $this->assertEquals( |
|
392 | + [ |
|
393 | + 1, |
|
394 | + 2, |
|
395 | + 3, |
|
396 | + 4, |
|
397 | + 5, |
|
398 | + 8, |
|
399 | + 11, |
|
400 | + 15, |
|
401 | + 16, |
|
402 | + 19, |
|
403 | + 20 |
|
404 | + ], |
|
405 | + $this->getLinesToBeIgnored()->invoke( |
|
406 | + $this->coverage, |
|
407 | + TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' |
|
408 | + ) |
|
409 | + ); |
|
410 | + } |
|
411 | + |
|
412 | + public function testGetLinesToBeIgnoredOneLineAnnotations() |
|
413 | + { |
|
414 | + $this->assertEquals( |
|
415 | + [ |
|
416 | + 1, |
|
417 | + 2, |
|
418 | + 3, |
|
419 | + 4, |
|
420 | + 5, |
|
421 | + 6, |
|
422 | + 7, |
|
423 | + 8, |
|
424 | + 9, |
|
425 | + 10, |
|
426 | + 11, |
|
427 | + 12, |
|
428 | + 13, |
|
429 | + 14, |
|
430 | + 15, |
|
431 | + 16, |
|
432 | + 18, |
|
433 | + 20, |
|
434 | + 21, |
|
435 | + 23, |
|
436 | + 24, |
|
437 | + 25, |
|
438 | + 27, |
|
439 | + 28, |
|
440 | + 29, |
|
441 | + 30, |
|
442 | + 31, |
|
443 | + 32, |
|
444 | + 33, |
|
445 | + 34, |
|
446 | + 37 |
|
447 | + ], |
|
448 | + $this->getLinesToBeIgnored()->invoke( |
|
449 | + $this->coverage, |
|
450 | + TEST_FILES_PATH . 'source_with_oneline_annotations.php' |
|
451 | + ) |
|
452 | + ); |
|
453 | + } |
|
454 | + |
|
455 | + /** |
|
456 | + * @return \ReflectionMethod |
|
457 | + */ |
|
458 | + private function getLinesToBeIgnored() |
|
459 | + { |
|
460 | + $getLinesToBeIgnored = new \ReflectionMethod( |
|
461 | + 'SebastianBergmann\CodeCoverage\CodeCoverage', |
|
462 | + 'getLinesToBeIgnored' |
|
463 | + ); |
|
464 | + |
|
465 | + $getLinesToBeIgnored->setAccessible(true); |
|
466 | + |
|
467 | + return $getLinesToBeIgnored; |
|
468 | + } |
|
469 | + |
|
470 | + public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled() |
|
471 | + { |
|
472 | + $this->coverage->setDisableIgnoredLines(true); |
|
473 | + |
|
474 | + $this->assertEquals( |
|
475 | + [], |
|
476 | + $this->getLinesToBeIgnored()->invoke( |
|
477 | + $this->coverage, |
|
478 | + TEST_FILES_PATH . 'source_with_ignore.php' |
|
479 | + ) |
|
480 | + ); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * @expectedException SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException |
|
485 | + */ |
|
486 | + public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted() |
|
487 | + { |
|
488 | + $this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
489 | + $this->coverage->setCheckForUnexecutedCoveredCode(true); |
|
490 | + |
|
491 | + $data = [ |
|
492 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
493 | + 29 => -1, |
|
494 | + 31 => -1 |
|
495 | + ] |
|
496 | + ]; |
|
497 | + |
|
498 | + $linesToBeCovered = [ |
|
499 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
500 | + 22, |
|
501 | + 24 |
|
502 | + ] |
|
503 | + ]; |
|
504 | + |
|
505 | + $linesToBeUsed = []; |
|
506 | + |
|
507 | + $this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed); |
|
508 | + } |
|
509 | + |
|
510 | + /** |
|
511 | + * @expectedException SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException |
|
512 | + */ |
|
513 | + public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted() |
|
514 | + { |
|
515 | + $this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH); |
|
516 | + $this->coverage->setCheckForUnexecutedCoveredCode(true); |
|
517 | + |
|
518 | + $data = [ |
|
519 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
520 | + 29 => -1, |
|
521 | + 31 => -1 |
|
522 | + ] |
|
523 | + ]; |
|
524 | + |
|
525 | + $linesToBeCovered = [ |
|
526 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
527 | + 29, |
|
528 | + 31 |
|
529 | + ] |
|
530 | + ]; |
|
531 | + |
|
532 | + $linesToBeUsed = [ |
|
533 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
534 | + 22, |
|
535 | + 24 |
|
536 | + ] |
|
537 | + ]; |
|
538 | + |
|
539 | + $this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed); |
|
540 | + } |
|
541 | 541 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | ], |
371 | 371 | $this->getLinesToBeIgnored()->invoke( |
372 | 372 | $this->coverage, |
373 | - TEST_FILES_PATH . 'source_with_ignore.php' |
|
373 | + TEST_FILES_PATH.'source_with_ignore.php' |
|
374 | 374 | ) |
375 | 375 | ); |
376 | 376 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | [1, 5], |
382 | 382 | $this->getLinesToBeIgnored()->invoke( |
383 | 383 | $this->coverage, |
384 | - TEST_FILES_PATH . 'source_without_ignore.php' |
|
384 | + TEST_FILES_PATH.'source_without_ignore.php' |
|
385 | 385 | ) |
386 | 386 | ); |
387 | 387 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | ], |
405 | 405 | $this->getLinesToBeIgnored()->invoke( |
406 | 406 | $this->coverage, |
407 | - TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' |
|
407 | + TEST_FILES_PATH.'source_with_class_and_anonymous_function.php' |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | ], |
448 | 448 | $this->getLinesToBeIgnored()->invoke( |
449 | 449 | $this->coverage, |
450 | - TEST_FILES_PATH . 'source_with_oneline_annotations.php' |
|
450 | + TEST_FILES_PATH.'source_with_oneline_annotations.php' |
|
451 | 451 | ) |
452 | 452 | ); |
453 | 453 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | [], |
476 | 476 | $this->getLinesToBeIgnored()->invoke( |
477 | 477 | $this->coverage, |
478 | - TEST_FILES_PATH . 'source_with_ignore.php' |
|
478 | + TEST_FILES_PATH.'source_with_ignore.php' |
|
479 | 479 | ) |
480 | 480 | ); |
481 | 481 | } |
@@ -489,14 +489,14 @@ discard block |
||
489 | 489 | $this->coverage->setCheckForUnexecutedCoveredCode(true); |
490 | 490 | |
491 | 491 | $data = [ |
492 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
492 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
493 | 493 | 29 => -1, |
494 | 494 | 31 => -1 |
495 | 495 | ] |
496 | 496 | ]; |
497 | 497 | |
498 | 498 | $linesToBeCovered = [ |
499 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
499 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
500 | 500 | 22, |
501 | 501 | 24 |
502 | 502 | ] |
@@ -516,21 +516,21 @@ discard block |
||
516 | 516 | $this->coverage->setCheckForUnexecutedCoveredCode(true); |
517 | 517 | |
518 | 518 | $data = [ |
519 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
519 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
520 | 520 | 29 => -1, |
521 | 521 | 31 => -1 |
522 | 522 | ] |
523 | 523 | ]; |
524 | 524 | |
525 | 525 | $linesToBeCovered = [ |
526 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
526 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
527 | 527 | 29, |
528 | 528 | 31 |
529 | 529 | ] |
530 | 530 | ]; |
531 | 531 | |
532 | 532 | $linesToBeUsed = [ |
533 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
533 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
534 | 534 | 22, |
535 | 535 | 24 |
536 | 536 | ] |
@@ -14,86 +14,86 @@ |
||
14 | 14 | |
15 | 15 | class XMLTest extends TestCase |
16 | 16 | { |
17 | - private static $TEST_REPORT_PATH_SOURCE; |
|
17 | + private static $TEST_REPORT_PATH_SOURCE; |
|
18 | 18 | |
19 | - public static function setUpBeforeClass() |
|
20 | - { |
|
21 | - parent::setUpBeforeClass(); |
|
19 | + public static function setUpBeforeClass() |
|
20 | + { |
|
21 | + parent::setUpBeforeClass(); |
|
22 | 22 | |
23 | - self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML'; |
|
24 | - } |
|
23 | + self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML'; |
|
24 | + } |
|
25 | 25 | |
26 | - protected function tearDown() |
|
27 | - { |
|
28 | - parent::tearDown(); |
|
26 | + protected function tearDown() |
|
27 | + { |
|
28 | + parent::tearDown(); |
|
29 | 29 | |
30 | - $tmpFilesIterator = new \FilesystemIterator(self::$TEST_TMP_PATH); |
|
30 | + $tmpFilesIterator = new \FilesystemIterator(self::$TEST_TMP_PATH); |
|
31 | 31 | |
32 | - foreach ($tmpFilesIterator as $path => $fileInfo) { |
|
33 | - /* @var \SplFileInfo $fileInfo */ |
|
34 | - unlink($fileInfo->getPathname()); |
|
35 | - } |
|
36 | - } |
|
32 | + foreach ($tmpFilesIterator as $path => $fileInfo) { |
|
33 | + /* @var \SplFileInfo $fileInfo */ |
|
34 | + unlink($fileInfo->getPathname()); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - public function testForBankAccountTest() |
|
39 | - { |
|
40 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount'; |
|
38 | + public function testForBankAccountTest() |
|
39 | + { |
|
40 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount'; |
|
41 | 41 | |
42 | - $xml = new Facade('1.0.0'); |
|
43 | - $xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH); |
|
42 | + $xml = new Facade('1.0.0'); |
|
43 | + $xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH); |
|
44 | 44 | |
45 | - $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
46 | - } |
|
45 | + $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
46 | + } |
|
47 | 47 | |
48 | - public function testForFileWithIgnoredLines() |
|
49 | - { |
|
50 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines'; |
|
48 | + public function testForFileWithIgnoredLines() |
|
49 | + { |
|
50 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines'; |
|
51 | 51 | |
52 | - $xml = new Facade('1.0.0'); |
|
53 | - $xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH); |
|
52 | + $xml = new Facade('1.0.0'); |
|
53 | + $xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH); |
|
54 | 54 | |
55 | - $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
56 | - } |
|
55 | + $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
56 | + } |
|
57 | 57 | |
58 | - public function testForClassWithAnonymousFunction() |
|
59 | - { |
|
60 | - $expectedFilesPath = |
|
61 | - self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction'; |
|
58 | + public function testForClassWithAnonymousFunction() |
|
59 | + { |
|
60 | + $expectedFilesPath = |
|
61 | + self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction'; |
|
62 | 62 | |
63 | - $xml = new Facade('1.0.0'); |
|
64 | - $xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH); |
|
63 | + $xml = new Facade('1.0.0'); |
|
64 | + $xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH); |
|
65 | 65 | |
66 | - $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
67 | - } |
|
66 | + $this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $expectedFilesPath |
|
71 | - * @param string $actualFilesPath |
|
72 | - */ |
|
73 | - private function assertFilesEquals($expectedFilesPath, $actualFilesPath) |
|
74 | - { |
|
75 | - $expectedFilesIterator = new \FilesystemIterator($expectedFilesPath); |
|
76 | - $actualFilesIterator = new \FilesystemIterator($actualFilesPath); |
|
69 | + /** |
|
70 | + * @param string $expectedFilesPath |
|
71 | + * @param string $actualFilesPath |
|
72 | + */ |
|
73 | + private function assertFilesEquals($expectedFilesPath, $actualFilesPath) |
|
74 | + { |
|
75 | + $expectedFilesIterator = new \FilesystemIterator($expectedFilesPath); |
|
76 | + $actualFilesIterator = new \FilesystemIterator($actualFilesPath); |
|
77 | 77 | |
78 | - $this->assertEquals( |
|
79 | - iterator_count($expectedFilesIterator), |
|
80 | - iterator_count($actualFilesIterator), |
|
81 | - 'Generated files and expected files not match' |
|
82 | - ); |
|
78 | + $this->assertEquals( |
|
79 | + iterator_count($expectedFilesIterator), |
|
80 | + iterator_count($actualFilesIterator), |
|
81 | + 'Generated files and expected files not match' |
|
82 | + ); |
|
83 | 83 | |
84 | - foreach ($expectedFilesIterator as $path => $fileInfo) { |
|
85 | - /* @var \SplFileInfo $fileInfo */ |
|
86 | - $filename = $fileInfo->getFilename(); |
|
84 | + foreach ($expectedFilesIterator as $path => $fileInfo) { |
|
85 | + /* @var \SplFileInfo $fileInfo */ |
|
86 | + $filename = $fileInfo->getFilename(); |
|
87 | 87 | |
88 | - $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename; |
|
88 | + $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename; |
|
89 | 89 | |
90 | - $this->assertFileExists($actualFile); |
|
90 | + $this->assertFileExists($actualFile); |
|
91 | 91 | |
92 | - $this->assertStringMatchesFormatFile( |
|
93 | - $fileInfo->getPathname(), |
|
94 | - file_get_contents($actualFile), |
|
95 | - "${filename} not match" |
|
96 | - ); |
|
97 | - } |
|
98 | - } |
|
92 | + $this->assertStringMatchesFormatFile( |
|
93 | + $fileInfo->getPathname(), |
|
94 | + file_get_contents($actualFile), |
|
95 | + "${filename} not match" |
|
96 | + ); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | parent::setUpBeforeClass(); |
22 | 22 | |
23 | - self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML'; |
|
23 | + self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH.'Report'.DIRECTORY_SEPARATOR.'XML'; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | protected function tearDown() |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function testForBankAccountTest() |
39 | 39 | { |
40 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount'; |
|
40 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE.DIRECTORY_SEPARATOR.'CoverageForBankAccount'; |
|
41 | 41 | |
42 | 42 | $xml = new Facade('1.0.0'); |
43 | 43 | $xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function testForFileWithIgnoredLines() |
49 | 49 | { |
50 | - $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines'; |
|
50 | + $expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE.DIRECTORY_SEPARATOR.'CoverageForFileWithIgnoredLines'; |
|
51 | 51 | |
52 | 52 | $xml = new Facade('1.0.0'); |
53 | 53 | $xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function testForClassWithAnonymousFunction() |
59 | 59 | { |
60 | 60 | $expectedFilesPath = |
61 | - self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction'; |
|
61 | + self::$TEST_REPORT_PATH_SOURCE.DIRECTORY_SEPARATOR.'CoverageForClassWithAnonymousFunction'; |
|
62 | 62 | |
63 | 63 | $xml = new Facade('1.0.0'); |
64 | 64 | $xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /* @var \SplFileInfo $fileInfo */ |
86 | 86 | $filename = $fileInfo->getFilename(); |
87 | 87 | |
88 | - $actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename; |
|
88 | + $actualFile = $actualFilesPath.DIRECTORY_SEPARATOR.$filename; |
|
89 | 89 | |
90 | 90 | $this->assertFileExists($actualFile); |
91 | 91 |
@@ -6,12 +6,12 @@ |
||
6 | 6 | */ |
7 | 7 | class NamespaceCoverageCoversClassPublicTest extends TestCase |
8 | 8 | { |
9 | - /** |
|
10 | - * @covers ::publicMethod |
|
11 | - */ |
|
12 | - public function testSomething() |
|
13 | - { |
|
14 | - $o = new Foo\CoveredClass; |
|
15 | - $o->publicMethod(); |
|
16 | - } |
|
9 | + /** |
|
10 | + * @covers ::publicMethod |
|
11 | + */ |
|
12 | + public function testSomething() |
|
13 | + { |
|
14 | + $o = new Foo\CoveredClass; |
|
15 | + $o->publicMethod(); |
|
16 | + } |
|
17 | 17 | } |
@@ -3,9 +3,9 @@ |
||
3 | 3 | |
4 | 4 | class CoverageNoneTest extends TestCase |
5 | 5 | { |
6 | - public function testSomething() |
|
7 | - { |
|
8 | - $o = new CoveredClass; |
|
9 | - $o->publicMethod(); |
|
10 | - } |
|
6 | + public function testSomething() |
|
7 | + { |
|
8 | + $o = new CoveredClass; |
|
9 | + $o->publicMethod(); |
|
10 | + } |
|
11 | 11 | } |
@@ -3,10 +3,10 @@ |
||
3 | 3 | |
4 | 4 | class CoverageMethodOneLineAnnotationTest extends TestCase |
5 | 5 | { |
6 | - /** @covers CoveredClass::publicMethod */ |
|
7 | - public function testSomething() |
|
8 | - { |
|
9 | - $o = new CoveredClass; |
|
10 | - $o->publicMethod(); |
|
11 | - } |
|
6 | + /** @covers CoveredClass::publicMethod */ |
|
7 | + public function testSomething() |
|
8 | + { |
|
9 | + $o = new CoveredClass; |
|
10 | + $o->publicMethod(); |
|
11 | + } |
|
12 | 12 | } |