Skip to content

Commit 25adbbb

Browse files
committed
Add test for class/method/property kinds
1 parent 1c65972 commit 25adbbb

File tree

2 files changed

+170
-2
lines changed

2 files changed

+170
-2
lines changed

tests/Acceptance/AcceptanceTestCase.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,21 @@ protected function givenSourceFile($filename, $content)
6060
/**
6161
* @return void
6262
*/
63-
protected function runPHPCtags()
63+
protected function runPHPCtags(array $params = array())
6464
{
6565
$entryPoint = realpath(__DIR__ . '/../../bootstrap.php');
6666

67-
exec("php \"$entryPoint\" --recurse=yes -f - {$this->testDir}", $output);
67+
$params = implode(' ', $params);
68+
69+
exec("php \"$entryPoint\" --recurse=yes $params -f - {$this->testDir}", $output);
6870

6971
$this->tagsFileContent = $output;
7072
}
7173

74+
protected function runPHPCtagsWithKinds($kindString)
75+
{
76+
}
77+
7278
/**
7379
* @param string $patterns
7480
*

tests/Acceptance/ClassesTest.php

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,166 @@ class MyClass {
213213
3
214214
);
215215
}
216+
217+
/**
218+
* @test
219+
*/
220+
public function itSupportsClassKindParameter()
221+
{
222+
$this->givenSourceFile('ClassKindsExample.php', <<<'EOS'
223+
<?php
224+
225+
class ClassKindsExample
226+
{
227+
public $publicProperty;
228+
protected $protectedProperty;
229+
private $privateProperty;
230+
231+
public function publicMethod()
232+
{
233+
}
234+
235+
protected function protectedMethod()
236+
{
237+
}
238+
239+
private function privateMethod()
240+
{
241+
}
242+
}
243+
EOS
244+
);
245+
246+
$this->runPHPCtagsWithKinds('c');
247+
248+
$this->assertTagsFileHeaderIsCorrect();
249+
$this->assertNumberOfTagsInTagsFileIs(1);
250+
251+
$this->assertTagsFileContainsTag(
252+
'ClassKindsExample.php',
253+
'ClassKindsExample',
254+
self::KIND_CLASS,
255+
3
256+
);
257+
}
258+
259+
/**
260+
* @test
261+
*/
262+
public function itSupportsPropertyKindParameter()
263+
{
264+
$this->givenSourceFile('PropertyKindsExample.php', <<<'EOS'
265+
<?php
266+
267+
class PropertyKindsExample
268+
{
269+
public $publicProperty;
270+
protected $protectedProperty;
271+
private $privateProperty;
272+
273+
public function publicMethod()
274+
{
275+
}
276+
277+
protected function protectedMethod()
278+
{
279+
}
280+
281+
private function privateMethod()
282+
{
283+
}
284+
}
285+
EOS
286+
);
287+
288+
$this->runPHPCtagsWithKinds('p');
289+
290+
$this->assertTagsFileHeaderIsCorrect();
291+
$this->assertNumberOfTagsInTagsFileIs(3);
292+
293+
$this->assertTagsFileContainsTag(
294+
'PropertyKindsExample.php',
295+
'publicProperty',
296+
self::KIND_PROPERTY,
297+
5,
298+
'class:TestClass',
299+
'public'
300+
);
301+
$this->assertTagsFileContainsTag(
302+
'PropertyKindsExample.php',
303+
'protectedProperty',
304+
self::KIND_PROPERTY,
305+
6,
306+
'class:TestClass',
307+
'protected'
308+
);
309+
$this->assertTagsFileContainsTag(
310+
'PropertyKindsExample.php',
311+
'privateProperty',
312+
self::KIND_PROPERTY,
313+
7,
314+
'class:TestClass',
315+
'private'
316+
);
317+
}
318+
319+
/**
320+
* @test
321+
*/
322+
public function itSupportsMethodKindParameter()
323+
{
324+
$this->givenSourceFile('MethodKindsExample.php', <<<'EOS'
325+
<?php
326+
327+
class MethodKindsExample
328+
{
329+
public $publicProperty;
330+
protected $protectedProperty;
331+
private $privateProperty;
332+
333+
public function publicMethod()
334+
{
335+
}
336+
337+
protected function protectedMethod()
338+
{
339+
}
340+
341+
private function privateMethod()
342+
{
343+
}
344+
}
345+
EOS
346+
);
347+
348+
$this->runPHPCtagsWithKinds('m');
349+
350+
$this->assertTagsFileHeaderIsCorrect();
351+
$this->assertNumberOfTagsInTagsFileIs(3);
352+
353+
$this->assertTagsFileContainsTag(
354+
'MethodKindsExample.php',
355+
'publicMethod',
356+
self::KIND_METHOD,
357+
9,
358+
'class:TestClass',
359+
'public'
360+
);
361+
$this->assertTagsFileContainsTag(
362+
'MethodKindsExample.php',
363+
'protectedMethod',
364+
self::KIND_METHOD,
365+
13,
366+
'class:TestClass',
367+
'protected'
368+
);
369+
$this->assertTagsFileContainsTag(
370+
'MethodKindsExample.php',
371+
'privateMethod',
372+
self::KIND_METHOD,
373+
17,
374+
'class:TestClass',
375+
'private'
376+
);
377+
}
216378
}

0 commit comments

Comments
 (0)