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
 public function test_config_stores_correct_values_from_valid_yaml_file()
 {
     $file = 'fake.yaml';
     $contents = "repositories:\n";
     $contents .= "    - location: ~/Code/Acme/src/Repos\n";
     $contents .= "    - namespace: Acme\\Repos\n";
     $file_dispatch = m::mock('Enzyme\\Parrot\\File[exists,getContents]', function ($mock) use($file, $contents) {
         $mock->shouldReceive('exists')->with($file)->times(1)->andReturn(true);
         $mock->shouldReceive('getContents')->with($file)->times(1)->andReturn($contents);
     });
     $config = new Config(new Parser(), $file_dispatch, new Dot());
     $config->parse($file);
     $expected = '~/Code/Acme/src/Repos';
     $actual = $config->get('repositories.location');
     $this->assertEquals($expected, $actual);
 }