/** * Helper * * @param string $method auth method to instantiate * * @return AbstractBase */ protected function makeAuth($method) { // If an illegal option was passed in, don't allow the object to load: if (!in_array($method, $this->legalAuthOptions)) { throw new \Exception("Illegal authentication method: {$method}"); } $auth = $this->pluginManager->get($method); $auth->setConfig($this->config); return $auth; }
/** * Get a mock plugin manager. * * @return PluginManager */ protected function getMockPluginManager() { $pm = new PluginManager(); $mockChoice = $this->getMockBuilder('VuFind\\Auth\\ChoiceAuth')->disableOriginalConstructor()->getMock(); $mockChoice->expects($this->any())->method('getSelectableAuthOptions')->will($this->returnValue(['Database', 'Shibboleth'])); $mockDb = $this->getMockBuilder('VuFind\\Auth\\Database')->disableOriginalConstructor()->getMock(); $mockMulti = $this->getMockBuilder('VuFind\\Auth\\MultiILS')->disableOriginalConstructor()->getMock(); $mockShib = $this->getMockBuilder('VuFind\\Auth\\Shibboleth')->disableOriginalConstructor()->getMock(); $pm->setService('ChoiceAuth', $mockChoice); $pm->setService('Database', $mockDb); $pm->setService('MultiILS', $mockMulti); $pm->setService('Shibboleth', $mockShib); return $pm; }
/** * Get a mock plugin manager. * * @return PluginManager */ protected function getMockPluginManager() { $pm = new PluginManager(); $mockDb = $this->getMockBuilder('VuFind\\Auth\\Database')->disableOriginalConstructor()->getMock(); $mockShib = $this->getMockBuilder('VuFind\\Auth\\Shibboleth')->disableOriginalConstructor()->getMock(); $pm->setService('Database', $mockDb); $pm->setService('Shibboleth', $mockShib); return $pm; }
/** * Test expected interface. * * @return void * * @expectedException Zend\ServiceManager\Exception\RuntimeException * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Auth\AbstractBase */ public function testExpectedInterface() { $pm = new PluginManager(null); $pm->validatePlugin(new \ArrayObject()); }