ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Tests\Setup\ClassFinderTest Class Reference
+ Inheritance diagram for ILIAS\Tests\Setup\ClassFinderTest:
+ Collaboration diagram for ILIAS\Tests\Setup\ClassFinderTest:

Public Member Functions

 testClassImplementsInterface ()
 
 testClassUsesAttribute ()
 
 testGenericClassMatching ()
 

Detailed Description

Definition at line 91 of file ClassFinderTest.php.

Member Function Documentation

◆ testClassImplementsInterface()

ILIAS\Tests\Setup\ClassFinderTest::testClassImplementsInterface ( )

Definition at line 93 of file ClassFinderTest.php.

93  : void
94  {
95  $finder = new ImplementationOfInterfaceFinder();
96  $this->assertTrue($finder->isClassMatching(TestInterface1::class, new \ReflectionClass(TestClass1::class)));
97  $this->assertTrue($finder->isClassMatching(TestInterface2::class, new \ReflectionClass(TestClass2::class)));
98  $this->assertTrue($finder->isClassMatching(TestInterface1::class, new \ReflectionClass(TestClass3::class)));
99  $this->assertTrue($finder->isClassMatching(TestInterface2::class, new \ReflectionClass(TestClass3::class)));
100 
101  $this->assertFalse($finder->isClassMatching(TestInterface3::class, new \ReflectionClass(TestClass3::class)));
102  $this->assertFalse($finder->isClassMatching(TestInterface3::class, new \ReflectionClass(TestClass2::class)));
103  $this->assertFalse($finder->isClassMatching(TestInterface3::class, new \ReflectionClass(TestClass1::class)));
104  }

◆ testClassUsesAttribute()

ILIAS\Tests\Setup\ClassFinderTest::testClassUsesAttribute ( )

Definition at line 106 of file ClassFinderTest.php.

106  : void
107  {
108  $finder = new UsageOfAttributeFinder();
109  $this->assertTrue($finder->isClassMatching(TestAttribute1::class, new \ReflectionClass(TestClass1::class)));
110  $this->assertTrue($finder->isClassMatching(TestAttribute2::class, new \ReflectionClass(TestClass2::class)));
111  $this->assertTrue($finder->isClassMatching(TestAttribute1::class, new \ReflectionClass(TestClass3::class)));
112  $this->assertTrue($finder->isClassMatching(TestAttribute2::class, new \ReflectionClass(TestClass3::class)));
113 
114  $this->assertFalse($finder->isClassMatching(TestAttribute3::class, new \ReflectionClass(TestClass3::class)));
115  $this->assertFalse($finder->isClassMatching(TestAttribute3::class, new \ReflectionClass(TestClass2::class)));
116  $this->assertFalse($finder->isClassMatching(TestAttribute3::class, new \ReflectionClass(TestClass1::class)));
117  }

◆ testGenericClassMatching()

ILIAS\Tests\Setup\ClassFinderTest::testGenericClassMatching ( )

Definition at line 119 of file ClassFinderTest.php.

References $r.

119  : void
120  {
121  $finder = new TestAbstractOfFinder();
122  $finder->class_names = [
123  TestClass1::class,
124  TestClass2::class,
125  TestClass3::class
126  ];
127 
128  $all_true = fn (\ReflectionClass $r): bool => true;
129  $expected = [
130  TestClass1::class,
131  TestClass2::class,
132  TestClass3::class
133  ];
134  $this->assertEquals($expected, iterator_to_array($finder->getMatchingClassNames($all_true)));
135 
136  $all_false = fn (\ReflectionClass $r): bool => false;
137  $expected = [];
138  $this->assertEquals($expected, iterator_to_array($finder->getMatchingClassNames($all_false)));
139 
140  $only_class1 = fn (\ReflectionClass $r): bool => $r->getName() === TestClass1::class;
141  $expected = [
142  TestClass1::class
143  ];
144  $this->assertEquals($expected, iterator_to_array($finder->getMatchingClassNames($only_class1)));
145  }
$r

The documentation for this class was generated from the following file: