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);
 }
Beispiel #2
0
 /**
  *
  * @param DependencyInjection $dependencyInjection
  */
 private function registerCommands(DependencyInjection $dependencyInjection)
 {
     foreach ($this->config->getNodes('command') as $commandNode) {
         /**
          * @var Config $commandNode
          */
         $metadataClass = $this->getMetadataClass('command.' . $commandNode->getAttribute('class'), $commandNode);
         $dependencyInjection->register($metadataClass);
     }
 }