has('unknownMethod')); self::assertFalse($methods->hasConstructor()); self::assertTrue($methods->has($method->name())); self::assertSame($method, $methods->get($method->name())); } public function test_get_non_existing_method_throws_exception(): void { $this->expectException(MethodNotFound::class); $this->expectExceptionCode(1510936269); $this->expectExceptionMessage('The method `unknownMethod` does not exist.'); (new Methods())->get('unknownMethod'); } public function test_constructor_is_found(): void { $method = FakeMethodDefinition::constructor(); $methods = new Methods($method); self::assertTrue($methods->hasConstructor()); self::assertSame($method, $methods->constructor()); } public function test_methods_are_countable(): void { $methods = new Methods( FakeMethodDefinition::new('methodA'), FakeMethodDefinition::new('methodB'), FakeMethodDefinition::new('methodC'), ); self::assertCount(3, $methods); } public function test_methods_are_iterable(): void { $methodsInstances = [ 'methodA' => FakeMethodDefinition::new('methodA'), 'methodB' => FakeMethodDefinition::new('methodB'), 'methodC' => FakeMethodDefinition::new('methodC'), ]; $methods = new Methods(...array_values($methodsInstances)); $this->checkIterable($methods, $methodsInstances); } }