Example #1
0
 /**
  * Test factory
  */
 public function testFactory()
 {
     $this->assertTrue($this->builder->isFactoryRegistered($this->factory));
     $this->assertTrue($this->factory->isFactoryRegistered());
     $this->assertContains(get_class($this->factory), $this->builder->getRegisteredFactories());
     $this->assertSame($this->builder->getRegisteredAdapters($this->factory), $this->factory->getRegisteredAdapters());
     $this->assertEmpty($this->builder->getRegisteredAdapters('NonExistingFactory'));
     $this->assertInstanceOf(__CLASS__ . '\\Adapter1', $this->factory->factory('adapter1'));
     $this->assertInstanceOf(__CLASS__ . '\\Adapter2', $this->factory->factory('adapter2'));
     $this->assertInstanceOf(__CLASS__ . '\\Adapter1', $this->factory->factory('adapter1', array('param1' => 'value1')));
     $this->assertInstanceOf(__CLASS__ . '\\Adapter2', $this->factory->factory(array('adapter' => 'adapter2', 'param2' => 'value2')));
     $this->assertInstanceOf(__CLASS__ . '\\Adapter1', $this->factory->factory(array('param1' => 'value1')));
     $this->assertInstanceOf(__CLASS__ . '\\Adapter2', $this->factory->factory(array('param2' => 'value2')));
     $this->assertSame(null, $this->factory->factory(array()));
     $this->factory->unregisterAdapter('adapter1')->unregisterAdapter('adapter2');
     $this->assertSame(null, $this->factory->factory('NonExistingAdapter'));
 }
Example #2
0
 /**
  * Is this factory registered?
  *
  * @return bool
  */
 public function isFactoryRegistered()
 {
     return $this->builder->isFactoryRegistered(get_called_class());
 }