ILIAS  release_7 Revision v7.30-3-g800a261c036
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
5namespace ILIAS\Tests\Setup;
6
8use PHPUnit\Framework\TestCase;
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
23{
24}
26{
27}
29{
30}
31class TestClass1 implements TestInterface1
32{
33}
34class 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
An exception for terminatinating execution or to throw for unit testing.
getAllClassNames(array $additional_ignore, string $matching_path=null)
if($format !==null) $name
Definition: metadata.php:230