public function testKeepsOriginalInstanceOfConfiguration()
 {
     $configuration = new DefaultConfiguration();
     $glue = new Glue($configuration);
     $glue->configure('namespace', 'foobar');
     $this->assertInstanceOf(DefaultConfiguration::class, $glue->getConfiguration());
 }
 public function testCanBindCommandsToConsole()
 {
     $glue = new Glue(new Configuration(['providers' => [ConsoleServiceProvider::class], 'commands' => [TinkerCommand::class]]));
     $glue->boot();
     /** @var Application $console */
     $console = $glue->getContainer()->get('console');
     $this->assertArrayHasKey('tinker', $console->all());
 }
 public function testCanBindCommandsToConsole()
 {
     $glue = new Glue(new Configuration(['definitions' => [new SymfonyConsoleDefinition([TinkerCommand::class])]]));
     $glue->boot();
     /** @var Application $console */
     $console = $glue->getContainer()->get('console');
     $this->assertArrayHasKey('tinker', $console->all());
 }
 public function testCanMirrorPhinxCommands()
 {
     $glue = new Glue(new Configuration(['paths' => ['migrations' => 'foobar'], 'providers' => [ConsoleServiceProvider::class, PhinxServiceProvider::class]]));
     $glue->boot();
     $console = $glue->getContainer()->get('console');
     /* @var Application $console */
     $this->assertArrayHasKey('migrate:migrate', $console->all());
     $config = $console->get('migrate:migrate')->getConfig();
     $this->assertEquals('foobar', $config['paths']['migrations']);
 }
 public function testCanMirrorPhinxCommands()
 {
     $glue = new Glue(new Configuration(['paths' => ['migrations' => 'foobar'], 'definitions' => [new SymfonyConsoleDefinition(), new PhinxDefinition(['paths' => ['migrations' => 'foobar']])]]));
     $glue->boot();
     $console = $glue->getContainer()->get('console');
     /* @var Application $console */
     $this->assertArrayHasKey('migrate:migrate', $console->all());
     /** @var Migrate $command */
     $command = $console->get('migrate:migrate');
     $config = $command->getConfig();
     $this->assertEquals('foobar', $config['paths']['migrations']);
 }
Beispiel #6
0
 public function testCanUseDifferentMiddlewaresPipeline()
 {
     $container = new Container();
     $container->add(SapiEmitter::class, function () {
         $emitter = Mockery::mock(SapiEmitter::class);
         $emitter->shouldReceive('emit')->once()->andReturnUsing(function (Response $response) {
             $this->assertEquals(302, $response->getStatusCode());
         });
         return $emitter;
     });
     $container->add('pipeline', function () {
         return function ($request, Response $response) {
             return $response->withStatus(302);
         };
     });
     $app = new Glue();
     $app->setContainer($container);
     $app->setDefinitionProviders([new ZendDiactorosDefinition(), new MockRouterDefinition()]);
     $app->get('foo', 'bar');
     $app->run();
 }
Beispiel #7
0
 public function testCanOverrideIndividualKeys()
 {
     $glue = new Glue(new DummyConfiguration());
     $glue->configure('providers', ['foo' => 'baz', 'qux']);
     $this->assertEquals(['debug' => true, 'providers' => ['foo' => 'baz', 'bar' => 'bar', 'qux'], 'middlewares' => ['foo', 'bar']], $glue->getConfiguration()->toArray());
 }
 public function testCanBindPaths()
 {
     $glue = new Glue(new Configuration(['providers' => [], 'paths' => ['foo' => 'bar']]));
     $glue->boot();
     $this->assertEquals('bar', $glue->getContainer()->get('paths.foo'));
 }
Beispiel #9
0
 public function testCanRunApp()
 {
     $request = Mockery::mock(ServerRequestInterface::class);
     $request->shouldReceive('getMethod')->andReturn('GET');
     $request->shouldReceive('getUri')->andReturn(new Uri('/foobar'));
     $response = Mockery::mock(ResponseInterface::class);
     $response->shouldReceive('getBody->isWritable')->andReturn(true);
     $response->shouldReceive('getBody->write')->with('foobar');
     $emitter = Mockery::mock(SapiEmitter::class);
     $emitter->shouldReceive('emit')->once()->with($response);
     $bus = Mockery::mock(CommandBus::class);
     $bus->shouldReceive('handle')->andReturn('foobar');
     $bus->shouldIgnoreMissing();
     $container = new Container();
     $container->add(ServerRequestInterface::class, $request);
     $container->add(ResponseInterface::class, $response);
     $container->add(DummyController::class, new DummyController($bus));
     $container->add(SapiEmitter::class, $emitter);
     $glue = new Glue(new Configuration(['debug' => false, 'providers' => [RoutingServiceProvider::class], 'middlewares' => [LeagueRouteMiddleware::class]]), $container);
     $glue->get('foobar', DummyController::class . '::index');
     $glue->run();
 }
 public function testCanBindConfiguration()
 {
     $glue = new Glue(new Configuration(['foo' => 'bar']));
     $glue->boot();
     $this->assertEquals('bar', $glue->getContainer()->get('config.foo'));
 }