ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ImplementationOfInterfaceFinderTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 namespace ILIAS\Tests\Setup;
6 
9 
11 {
12  public $class_names = [];
13 
14  protected function getAllClassNames(array $additional_ignore, string $matching_path = null) : \Iterator
15  {
16  foreach ($this->class_names as $name) {
17  yield $name;
18  }
19  }
20 }
21 
22 interface TestInterface1
23 {
24 }
25 interface TestInterface2
26 {
27 }
28 interface TestInterface3
29 {
30 }
31 class TestClass1 implements TestInterface1
32 {
33 }
34 class TestClass2 implements TestInterface2
35 {
36 }
38 {
39 }
40 
42 {
43  public function testWithTestInterface1()
44  {
46  $finder->class_names = [
47  TestClass1::class,
48  TestClass2::class,
49  TestClass3::class
50  ];
51  $expected = [TestClass1::class, TestClass3::class];
52  $result = iterator_to_array($finder->getMatchingClassNames(TestInterface1::class));
53  $this->assertEquals($expected, $result);
54  }
55 
56  public function testWithTestInterface2()
57  {
59  $finder->class_names = [
60  TestClass1::class,
61  TestClass2::class,
62  TestClass3::class
63  ];
64  $expected = [TestClass2::class, TestClass3::class];
65  $result = iterator_to_array($finder->getMatchingClassNames(TestInterface2::class));
66  $this->assertEquals($expected, $result);
67  }
68 
69  public function testWithTestInterface3()
70  {
72  $finder->class_names = [
73  TestClass1::class,
74  TestClass2::class,
75  TestClass3::class
76  ];
77  $expected = [];
78  $result = iterator_to_array($finder->getMatchingClassNames(TestInterface3::class));
79  $this->assertEquals($expected, $result);
80  }
81 }
$result
getAllClassNames(array $additional_ignore, string $matching_path=null)
if($format !==null) $name
Definition: metadata.php:230