コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: DictionaryTest.php プロジェクト: weew/collections
 public function test_getters_and_setters()
 {
     $dict = new Dictionary();
     $dict->set('foo', 'bar');
     $array = ['foo' => 'bar', 'bar' => 'foo', 'dict' => $dict, 'item' => new ArrayableItem('foo')];
     $wrapper = new Dictionary($array);
     $this->assertEquals('bar', $wrapper->get('foo'));
     $wrapper->set('bar', 'baz');
     $this->assertEquals('baz', $wrapper->get('bar'));
     $wrapper->remove('foo');
     $this->assertNull($wrapper->get('foo'));
     $this->assertEquals('yolo', $wrapper->get('foobar', 'yolo'));
     $this->assertFalse($wrapper->has('swag'));
     $wrapper->set('swag', 'yolo');
     $this->assertTrue($wrapper->has('swag'));
     $this->assertEquals(['bar' => 'baz', 'dict' => ['foo' => 'bar'], 'swag' => 'yolo', 'item' => ['id' => 'foo']], $wrapper->toArray());
 }
コード例 #3
0
ファイル: ProviderInvokerTest.php プロジェクト: weew/kernel
 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);
 }