Beispiel #1
0
 /**
  * @dataProvider containerProvider
  */
 public function testContainer(Container $container)
 {
     $container->add(['db.host' => 'localhost', 'db.user' => 'root', 'db.pass' => 'passw0rd']);
     $container->bind(SomeService::class)->with(['timeout' => 3600])->using(['config' => ['HOSTNAME' => 'db.host', 'CREDENTIALS' => ['USERNAME' => 'db.user', 'PASSWORD' => 'db.pass']]]);
     $container->bind(AnotherService::class);
     $service = $container->get(AnotherService::class);
     $this->assertInstanceOf(AnotherService::class, $service);
     $this->assertInstanceOf(DatabaseConnection::class, $service->connection);
     $this->assertInstanceOf(SomeService::class, $service->service);
     $this->assertSame('localhost', $service->connection->hostname);
     $this->assertSame('root', $service->connection->username);
     $this->assertSame('passw0rd', $service->connection->password);
     $this->assertSame(3600, $service->service->timeout);
     $this->assertSame(['HOSTNAME' => 'localhost', 'CREDENTIALS' => ['USERNAME' => 'root', 'PASSWORD' => 'passw0rd']], $service->service->config);
 }