Chris@0: pluginManager = $this->getMock('Drupal\Component\Plugin\PluginManagerInterface'); Chris@0: $this->searchPluginCollection = new SearchPluginCollection($this->pluginManager, 'banana', ['id' => 'banana', 'color' => 'yellow'], 'fruit_stand'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests the get() method. Chris@0: */ Chris@0: public function testGet() { Chris@0: $plugin = $this->getMock('Drupal\search\Plugin\SearchInterface'); Chris@0: $this->pluginManager->expects($this->once()) Chris@0: ->method('createInstance') Chris@0: ->will($this->returnValue($plugin)); Chris@0: $this->assertSame($plugin, $this->searchPluginCollection->get('banana')); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests the get() method with a configurable plugin. Chris@0: */ Chris@0: public function testGetWithConfigurablePlugin() { Chris@0: $plugin = $this->getMock('Drupal\search\Plugin\ConfigurableSearchPluginInterface'); Chris@0: $plugin->expects($this->once()) Chris@0: ->method('setSearchPageId') Chris@0: ->with('fruit_stand') Chris@0: ->will($this->returnValue($plugin)); Chris@0: Chris@0: $this->pluginManager->expects($this->once()) Chris@0: ->method('createInstance') Chris@0: ->will($this->returnValue($plugin)); Chris@0: Chris@0: $this->assertSame($plugin, $this->searchPluginCollection->get('banana')); Chris@0: } Chris@0: Chris@0: }