has('unknownParameter')); self::assertTrue($parameters->has($parameter->name())); self::assertSame($parameter, $parameters->get($parameter->name())); } public function test_get_non_existing_parameter_throws_exception(): void { $this->expectException(ParameterNotFound::class); $this->expectExceptionCode(1514302629); $this->expectExceptionMessage('The parameter `unknownParameter` does not exist.'); (new Parameters())->get('unknownParameter'); } public function test_get_parameter_at_index_returns_correct_parameter(): void { $parameterA = FakeParameterDefinition::new('SomeParameterA'); $parameterB = FakeParameterDefinition::new('SomeParameterB'); $parameters = new Parameters($parameterA, $parameterB); self::assertSame($parameterA, $parameters->at(0)); self::assertSame($parameterB, $parameters->at(1)); } public function test_get_parameter_at_index_out_of_range_throws_exception(): void { $this->expectException(InvalidParameterIndex::class); $this->expectExceptionCode(1644936619); $this->expectExceptionMessage('Index 1 is out of range, it should be between 0 and 0.'); (new Parameters(FakeParameterDefinition::new()))->at(1); } public function test_parameters_are_countable(): void { $parameters = new Parameters( FakeParameterDefinition::new('parameterA'), FakeParameterDefinition::new('parameterB'), FakeParameterDefinition::new('parameterC'), ); self::assertCount(3, $parameters); } public function test_parameters_are_iterable(): void { $parametersInstances = [ 'parameterA' => FakeParameterDefinition::new('parameterA'), 'parameterB' => FakeParameterDefinition::new('parameterB'), 'parameterC' => FakeParameterDefinition::new('parameterC'), ]; $parameters = new Parameters(...array_values($parametersInstances)); $this->checkIterable($parameters, $parametersInstances); } }