/** * @expectedException \AMQPAL\Adapter\Exception\OutOfBoundsException * @expectedExceptionMessage Unable to find adapter 'foo'. */ public function testCreateAdapterWithInvalidAdapter() { $adapters = []; $factory = new AdapterFactory(); $factory->setAdapters($adapters); $options = ['name' => 'foo', 'options' => []]; $factory->createAdapter($options); }
public function __construct($config = [], $server = null) { $factory = new AdapterFactory(); if (!($this->adapter = $factory->get($config, $server))) { $this->setError("Could not create adapter!"); return false; } return true; }
/** * */ public function run($request) { $indicators = IndicatorFactory::get_all(); $adapter = AdapterFactory::create(); if ($adapter->canConnect()) { echo "Service can be reached...", "<br>"; echo "Fetch indicators...", "<br>"; echo "Indicators:", "<br>"; $adapter->send($indicators); echo "Statistic was updated.", "<br>"; } else { echo "Can't connect to service.", "<br>"; } }
protected function getAdapter($order_type) { return AdapterFactory::create($order_type); }
/** * @covers \Magento\Framework\Image\AdapterFactory::create * @expectedException \InvalidArgumentException * @expectedExceptionMessage stdClass is not instance of \Magento\Framework\Image\Adapter\AdapterInterface */ public function testWrongInstance() { $alias = 'wrongInstance'; $class = 'stdClass'; $objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', array('create'), array(), '', false); $imageAdapterMock = $this->getMock($class, array('checkDependencies')); $objectManagerMock->expects($this->once())->method('create')->with($class)->will($this->returnValue($imageAdapterMock)); $adapterFactory = new AdapterFactory($objectManagerMock, $this->configMock); $adapterFactory->create($alias); }
/** * @param AdapterFactory $adapterFactory */ public function __construct(AdapterFactory $adapterFactory) { $this->adapter = $adapterFactory->create(); }