function testDisablePlugin() { $plugin_dao = new MockPluginDao($this); $access_result = new MockDataAccessResult($this); $plugin_dao->setReturnReference('searchById', $access_result); $access_result->setReturnValueAt(0, 'getRow', array('id' => '123', 'name' => 'plugin 123', 'available' => '1')); //enabled = 1 $access_result->setReturnValueAt(1, 'getRow', false); $plugin_dao->expectOnce('updateAvailableByPluginId', array('0', 123)); $restrictor = mock('PluginResourceRestrictor'); $pf = partial_mock('PluginFactory', array('_getClassNameForPluginName'), array($plugin_dao, $restrictor)); $pf->setReturnValue('_getClassNameForPluginName', array('class' => 'Plugin', 'custom' => false)); $p = $pf->getPluginById(123); $pf->unavailablePlugin($p); }
function testDisablePlugin() { $plugin_dao = new MockPluginDao($this); $access_result = new MockDataAccessResult($this); $plugin_dao->setReturnReference('searchById', $access_result); $access_result->setReturnValueAt(0, 'getRow', array('id' => '123', 'name' => 'plugin 123', 'available' => '1')); //enabled = 1 $access_result->setReturnValueAt(1, 'getRow', false); $plugin_dao->expectOnce('updateAvailableByPluginId', array('0', 123)); $pf = new PluginFactoryTestVersion($this); $pf->setReturnValue('_getClassNameForPluginName', array('class' => 'Plugin', 'custom' => false)); $pf->PluginFactory($plugin_dao); //Only for test. You should use singleton instead $p = $pf->getPluginById(123); $pf->unavailablePlugin($p); }