/** * @dataProvider getDafeultPlugins * * @param string $dafeult_plugin */ public function testGetDafeultPlugin($dafeult_plugin) { /* @var $plugin \PHPUnit_Framework_MockObject_MockObject|SearchInterface */ $plugin = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Plugin\\Fill\\Search\\SearchInterface'); $plugin->expects($this->atLeastOnce())->method('getName')->will($this->returnValue('foo')); $chain = new Chain($dafeult_plugin); $chain->addPlugin($plugin); if ($dafeult_plugin == 'foo') { $this->assertEquals($plugin, $chain->getDafeultPlugin()); } else { $this->assertNull($chain->getDafeultPlugin()); } }
/** * @param DetectedNewFiles $event * * @return bool */ public function onDetectedNewFilesTryAdd(DetectedNewFiles $event) { // search from default plugin $default_plugin = null; if (($default_plugin = $this->search->getDafeultPlugin()) && $this->tryAddItem($default_plugin, $event)) { return true; } // search from all plugins foreach ($this->search->getPlugins() as $plugin) { /* @var $plugin SearchInterface */ if ($plugin !== $default_plugin && $this->tryAddItem($plugin, $event)) { return true; } } return false; }