/** * @testdox Launch exception when driver is not supported */ public function testUnsupportedDriver() { // testing Mysqli driver $mockDriver = $this->getMock('\\Zend\\Db\\Adapter\\Driver\\Pdo\\Pdo', ['getDatabasePlatformName'], [], '', false); $mockDriver->expects($this->any())->method('getDatabasePlatformName')->will($this->returnValue('NotMysql')); $sManager = new ServiceManager(); $sManager->setService('Config', ['sphinxql' => $mockDriver]); //Test exception by factory $factory = new AdapterServiceFactory(); $this->setExpectedException('\\SphinxSearch\\Db\\Adapter\\Exception\\UnsupportedDriverException'); $factory->createService($sManager); }
/** * {@inheritdoc} * @return \Zend\Db\Adapter\Adapter */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $config = $this->getConfig($container); return AdapterServiceFactory::factory($config[$requestedName]); }