예제 #1
0
 function testPluginIsCustom()
 {
     $plugin_dao = new MockPluginDao($this);
     $access_result_custom = new MockDataAccessResult($this);
     $access_result_custom->setReturnValue('getRow', false);
     $access_result_custom->setReturnValueAt(0, 'getRow', array('id' => '123', 'name' => 'custom', 'available' => 1));
     $plugin_dao->setReturnReferenceAt(0, 'searchByName', $access_result_custom);
     $access_result_official = new MockDataAccessResult($this);
     $access_result_official->setReturnValue('getRow', false);
     $access_result_official->setReturnValueAt(0, 'getRow', array('id' => '124', 'name' => 'official', 'available' => 1));
     $plugin_dao->setReturnReferenceAt(1, 'searchByName', $access_result_official);
     $restrictor = mock('PluginResourceRestrictor');
     $pf = partial_mock('PluginFactory', array('_getClassNameForPluginName'), array($plugin_dao, $restrictor));
     $pf->setReturnValueAt(0, '_getClassNameForPluginName', array('class' => 'customPlugin', 'custom' => true));
     $pf->setReturnValueAt(1, '_getClassNameForPluginName', array('class' => 'officialPlugin', 'custom' => false));
     $plugin_custom = $pf->getPluginByName('custom');
     $this->assertIsA($plugin_custom, 'Plugin');
     $this->assertTrue($pf->pluginIsCustom($plugin_custom));
     $plugin_official = $pf->getPluginByName('official');
     $this->assertIsA($plugin_official, 'Plugin');
     $this->assertFalse($pf->pluginIsCustom($plugin_official));
 }
예제 #2
0
 function testPluginIsCustom()
 {
     $plugin_dao = new MockPluginDao($this);
     $access_result_custom = new MockDataAccessResult($this);
     $access_result_custom->setReturnValue('getRow', false);
     $access_result_custom->setReturnValueAt(0, 'getRow', array('id' => '123', 'name' => 'custom', 'available' => 1));
     $plugin_dao->setReturnReferenceAt(0, 'searchByName', $access_result_custom);
     $access_result_official = new MockDataAccessResult($this);
     $access_result_official->setReturnValue('getRow', false);
     $access_result_official->setReturnValueAt(0, 'getRow', array('id' => '124', 'name' => 'official', 'available' => 1));
     $plugin_dao->setReturnReferenceAt(1, 'searchByName', $access_result_official);
     $pf = new PluginFactoryTestVersion($this);
     $pf->setReturnValueAt(0, '_getClassNameForPluginName', array('class' => 'customPlugin', 'custom' => true));
     $pf->setReturnValueAt(1, '_getClassNameForPluginName', array('class' => 'officialPlugin', 'custom' => false));
     $pf->PluginFactory($plugin_dao);
     //Only for test. You should use singleton instead
     $plugin_custom = $pf->getPluginByName('custom');
     $this->assertIsA($plugin_custom, 'Plugin');
     $this->assertTrue($pf->pluginIsCustom($plugin_custom));
     $plugin_official = $pf->getPluginByName('official');
     $this->assertIsA($plugin_official, 'Plugin');
     $this->assertFalse($pf->pluginIsCustom($plugin_official));
 }