public function test_invoker_uses_container()
 {
     $invoker = new ProviderInvoker(new Container());
     $shared = new Dictionary();
     $shared->set('status', 'created');
     $provider = $invoker->create(ComplexProvider::class, $shared);
     $this->assertTrue($provider->create instanceof Foo);
     $this->assertEquals('created', $provider->status);
     $shared->set('status', 'configured');
     $invoker->configure($provider, $shared);
     $this->assertTrue($provider->configure instanceof Bar);
     $this->assertEquals('configured', $provider->status);
     $shared->set('status', 'initialized');
     $invoker->initialize($provider, $shared);
     $this->assertTrue($provider->initialize instanceof Bar);
     $this->assertEquals('initialized', $provider->status);
     $shared->set('status', 'booted');
     $invoker->boot($provider, $shared);
     $this->assertTrue($provider->boot instanceof Bar);
     $this->assertEquals('booted', $provider->status);
     $shared->set('status', 'shutdown');
     $invoker->shutdown($provider, $shared);
     $this->assertTrue($provider->shutdown instanceof Bar);
     $this->assertEquals('shutdown', $provider->status);
 }
Beispiel #2
0
 public function test_shared_arguments_are_passed()
 {
     $shared = new Dictionary();
     $provider = new SharedFakeProvider();
     $invoker = new ProviderInvoker();
     $shared->set('status', 'initialized');
     $invoker->initialize($provider, $shared);
     $this->assertEquals('initialized', $provider->status);
     $shared->set('status', 'booted');
     $invoker->boot($provider, $shared);
     $this->assertEquals('booted', $provider->status);
     $shared->set('status', 'shutdown');
     $invoker->shutdown($provider, $shared);
     $this->assertEquals('shutdown', $provider->status);
 }
Beispiel #3
0
 public function test_add()
 {
     $dict = new Dictionary(['foo' => 'bar', 'bar' => 'baz']);
     $dict->add('foo', 'baz');
     $this->assertEquals(['foo' => ['bar', 'baz'], 'bar' => 'baz'], $dict->toArray());
 }