Ejemplo n.º 1
0
 public function testGetDisplay()
 {
     $output = $this->tester->getOutput();
     $this->provider->alias('Danack\\Console\\Output\\Output', get_class($output));
     $this->provider->share($output);
     $callable = $this->parsedCommand->getCallable();
     $this->provider->execute($callable, []);
     $this->assertEquals('foo' . PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution');
 }
Ejemplo n.º 2
0
 public function testExecuteForApplicationCommandWithXmlOption()
 {
     $application = new Application();
     $commandTester = new CommandTester($application->get('help'));
     $parsedCommand = $commandTester->execute(array('command_name' => 'list', '--format' => 'xml'));
     $provider = new Provider();
     $provider->execute($parsedCommand->getCallable(), []);
     $this->assertRegExp('/list \\[--xml\\] \\[--raw\\] \\[--format="\\.\\.\\."\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
     $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
 }
Ejemplo n.º 3
0
    public function testExecuteListsCommandsWithRawOption()
    {
        $application = new Application();
        $commandTester = new CommandTester($command = $application->get('list'));
        $parsedCommand = $commandTester->execute(array('command' => $command->getName(), '--raw' => true));
        $provider = new Provider();
        $provider->execute($parsedCommand->getCallable(), []);
        $output = <<<EOF
help   Displays help for a command
list   Lists commands

EOF;
        $this->assertEquals($output, $commandTester->getDisplay(true));
    }
Ejemplo n.º 4
0
 public function testSetRunCustomDefaultCommand()
 {
     $command = new \FooCommand();
     $application = new Application();
     $application->setAutoExit(false);
     $application->add($command);
     $application->setDefaultCommand($command->getName());
     $tester = new ApplicationTester($application);
     $parsedCommand = $tester->run(array());
     $provider = new Provider();
     $provider->execute($parsedCommand->getCallable(), []);
     $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
     $application = new CustomDefaultCommandApplication();
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $parsedCommand = $tester->run(array());
     $provider->execute($parsedCommand->getCallable(), []);
     $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
 }
Ejemplo n.º 5
0
 /**
  * Resolves Auryn controller dependencies after everything else has been set up correctly
  *
  * @see <https://github.com/rdlowrey/Auryn>
  */
 public function resolveAuryn()
 {
     $app = $this;
     $config = $this->config['auryn'];
     $provider = new Provider(new ReflectionPool());
     foreach ($config as $key => $values) {
         switch ($key) {
             case $key === 'define':
                 if (!is_null($values)) {
                     array_walk($values, function ($definition, $key) use($provider) {
                         $provider->define($key, $definition);
                     });
                 }
                 break;
             case $key === 'delegate':
                 if (!is_null($values)) {
                     array_walk($values, function ($delegate, $object) use($provider) {
                         $provider->delegate($object, $delegate);
                     });
                 }
                 break;
             case $key === 'alias':
                 if (!is_null($values)) {
                     array_walk($values, function ($concrete, $interface) use($provider) {
                         $provider->alias($interface, $concrete);
                     });
                 }
                 break;
             case $key === 'share':
                 if (!is_null($values)) {
                     array_walk($values, function ($share) use($provider, $app) {
                         $provider->share($app[$share]);
                     });
                 }
                 break;
         }
     }
     $repositoryFiles = glob(__DIR__ . "/Model/Repository/*Repository.php");
     array_walk($repositoryFiles, function ($file) use($app, $provider) {
         /** @var \Doctrine\ORM\EntityManager $orm */
         $orm = $app['orm.em'];
         $repositoryName = str_replace(['Repository', '.php'], '', basename($file));
         $provider->share($orm->getRepository(sprintf('\\App\\Model\\Entity\\%s', $repositoryName)));
     });
     $app['resolver'] = $app->share($app->extend('resolver', function ($resolver, $app) use($provider, $config) {
         return new AurynControllerResolver($resolver, $provider, $app, $app['request'], $config);
     }));
 }