Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  *
  * @throws Exception If there is no namespace or location defined for the
  * class type(s) being generated.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inflector = Inflector::get(Inflector::DEFAULT_LOCALE);
     $type_plural = $inflector->pluralize($this->getGeneratorType());
     $this->namespace = $input->getOption('namespace') !== null ? $input->getOption('namespace') : $this->config->get("{$type_plural}.namespace");
     $this->location = $input->getOption('location') !== null ? $input->getOption('location') : $this->config->get("{$type_plural}.location");
     if (null === $this->namespace) {
         throw new Exception("There is no namespace defined for {$type_plural}");
     }
     if (null === $this->location) {
         throw new Exception("There is no location defined for {$type_plural}");
     }
 }
Ejemplo n.º 2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function test_config_throws_exception_on_bad_yaml_parse()
 {
     $file = 'fake.yaml';
     $parser = m::mock('Symfony\\Component\\Yaml\\Parser[parse]', function ($mock) {
         $mock->shouldReceive('parse')->andThrow(new InvalidArgumentException('oops'));
     });
     $file_dispatch = m::mock('Enzyme\\Parrot\\File[exists,getContents]', function ($mock) use($file) {
         $mock->shouldReceive('exists')->with($file)->times(1)->andReturn(true);
         $mock->shouldReceive('getContents')->with($file)->times(1)->andReturn('bad');
     });
     $config = new Config($parser, $file_dispatch, new Dot());
     $config->parse($file);
 }