Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function register($command)
 {
     if (is_string($command)) {
         $command = $this->siphon->get($command);
     }
     if ($command instanceof Command) {
         $command->setSiphon($this->siphon);
     }
     return $this->addToParent($command);
 }
Esempio n. 2
0
<?php

use Siphon\Application as Siphon;
use Siphon\Console\Application;
describe("Console Application", function () {
    describe("->add()", function () {
        it("adds a command to the application", function () {
            $app = new Siphon();
            $console = new Application($app);
            $console->register('Siphon\\Spec\\Console\\Asset\\SampleCommand');
            expect($console->has('sample'))->toBe(true);
            expect($app->has('Siphon\\Spec\\Console\\Asset\\SampleCommand'))->toBe(true);
        });
    });
    describe("->call()", function () {
        it("calls a console command", function () {
            $app = new Siphon();
            $console = new Application($app);
            $console->register('Siphon\\Spec\\Console\\Asset\\SampleCommand');
            expect($console->call('sample'))->toBe(0);
        });
    });
});
Esempio n. 3
0
             $app = new Application();
             $app->abort(405);
         };
         expect($closure)->toThrow(new Siphon\Exception\HttpException(405));
     });
     it("aborts the current request with a NotFoundHttpException", function () {
         $closure = function () {
             $app = new Application();
             $app->abort(404);
         };
         expect($closure)->toThrow(new Siphon\Exception\NotFoundHttpException());
     });
 });
 describe("default registered service definitions", function () {
     it("returns the default registered services", function () {
         $app = new Application();
         $app->boot();
         expect($app['app'] === $app)->toBe(true);
         expect($app)->toBeAnInstanceOf('Siphon\\ApplicationInterface')->toBeAnInstanceOf('Siphon\\Container\\ContainerInterface')->toBeAnInstanceOf('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->toBeAnInstanceOf('Symfony\\Component\\HttpKernel\\TerminableInterface');
         expect($app->get('router'))->toBeAnInstanceOf('Siphon\\Route\\RouteCollection');
         expect($app['Siphon\\Event\\DispatcherInterface'])->toBeAnInstanceOf('Siphon\\Event\\Dispatcher');
         expect($app['Siphon\\Event\\Dispatcher'])->toBeAnInstanceOf('Siphon\\Event\\Dispatcher');
         expect($app['event'])->toBeAnInstanceOf('Siphon\\Event\\Dispatcher');
         expect($app['Georgeff\\Filesystem\\File'])->toBeAnInstanceOf('Georgeff\\Filesystem\\File');
         expect($app['Georgeff\\Filesystem\\Directory'])->toBeAnInstanceOf('Georgeff\\Filesystem\\Directory');
         expect($app['Georgeff\\Filesystem\\Factory'])->toBeAnInstanceOf('Georgeff\\Filesystem\\Factory');
         expect($app['file'])->toBeAnInstanceOf('Georgeff\\Filesystem\\File');
         expect($app['directory'])->toBeAnInstanceOf('Georgeff\\Filesystem\\Directory');
         expect($app['filesystem'])->toBeAnInstanceOf('Georgeff\\Filesystem\\Factory');
         expect($app['Siphon\\Config\\RepositoryInterface'])->toBeAnInstanceOf('Siphon\\Config\\RepositoryInterface');
         expect($app['Siphon\\Config\\Repository'])->toBeAnInstanceOf('Siphon\\Config\\Repository');
 /**
  * Load the application configuration files
  *
  * @param \Siphon\Application $app
  */
 protected function loadAppConfig($app)
 {
     if (is_dir($app->configPath())) {
         $app['config.loader']->load($app->configPath());
     }
 }