protected function SearchTest::setUp in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Unit/Plugin/freelinking/SearchTest.php \Drupal\Tests\freelinking\Unit\Plugin\freelinking\SearchTest::setUp()
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Plugin/ freelinking/ SearchTest.php, line 39
Class
- SearchTest
- Tests the search plugin.
Namespace
Drupal\Tests\freelinking\Unit\Plugin\freelinkingCode
protected function setUp() {
// Mock the string translation.
$tProphet = $this
->prophesize('\\Drupal\\Core\\StringTranslation\\TranslationInterface');
$tProphet
->translateString(Argument::any())
->willReturn('Search this site for content like “%dest”.');
$this->translationInterfaceMock = $tProphet
->reveal();
// Mock path validator.
$pathValidatorProphet = $this
->prophesize('\\Drupal\\Core\\Path\\PathValidatorInterface');
// Mock module handler.
$moduleHandlerProphet = $this
->prophesize('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
$moduleHandlerProphet
->moduleExists('search')
->willReturn(TRUE);
$container = new ContainerBuilder();
$container
->set('string_translation', $this->translationInterfaceMock);
$container
->set('module_handler', $moduleHandlerProphet
->reveal());
$container
->set('path.validator', $pathValidatorProphet
->reveal());
\Drupal::setContainer($container);
$plugin_definition = [
'id' => 'search',
'title' => 'Search',
'hidden' => FALSE,
'weight' => 0,
'settings' => [
'failover' => 'error',
],
];
$configuration = [
'settings' => [
'failover' => 'error',
],
];
$this->plugin = Search::create($container, $configuration, 'search', $plugin_definition);
}