public function testGetInvalidTypeException() { $metadataClass = new MetadataClass('standalone', 'Asset\\StandaloneClass'); $metadataMethod = new MetadataMethod('__construct'); $metadataMethod->addArgument('unknown', 'param1'); $metadataMethod->addArgument(MetadataMethod::PRIMITIVE_TYPE, 'param2'); $metadataClass->registerInvoke($metadataMethod); $metadataMethod = new MetadataMethod('setParam3'); $metadataMethod->addArgument(MetadataMethod::PRIMITIVE_TYPE, 'data'); $metadataClass->registerInvoke($metadataMethod); $di = new DependencyInjection(); $di->register($metadataClass); $exception = null; try { $di->get('standalone'); } catch (\Exception $e) { $exception = $e; } $this->assertInstanceOf(InvalidTypeException::class, $exception); }
/** * * @param Config $methodNode * @return MetadataMethod */ private function getMetadataDependencyMethod(Config $methodNode) { $metadataMethod = new MetadataMethod($methodNode->getAttribute('name')); foreach ($methodNode->getNodes('argument') as $argumentNode) { /** * @var Config $argumentNode */ $metadataMethod->addArgument($argumentNode->getAttribute('type'), $argumentNode->getAttribute('value')); } return $metadataMethod; }