You are here

protected function WidgetTestBase::setUp in Facets 8

Sets up the container and other variables used in all the tests.

Overrides UnitTestCase::setUp

5 calls to WidgetTestBase::setUp()
ArrayWidgetTest::setUp in tests/src/Unit/Plugin/widget/ArrayWidgetTest.php
Sets up the container and other variables used in all the tests.
CheckboxWidgetTest::setUp in tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php
Creates a new processor object for use in the tests.
DropdownWidgetTest::setUp in tests/src/Unit/Plugin/widget/DropdownWidgetTest.php
Creates a new processor object for use in the tests.
LinksWidgetTest::setUp in tests/src/Unit/Plugin/widget/LinksWidgetTest.php
Sets up the container and other variables used in all the tests.
SliderWidgetTest::setUp in modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php
Sets up the container and other variables used in all the tests.
5 methods override WidgetTestBase::setUp()
ArrayWidgetTest::setUp in tests/src/Unit/Plugin/widget/ArrayWidgetTest.php
Sets up the container and other variables used in all the tests.
CheckboxWidgetTest::setUp in tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php
Creates a new processor object for use in the tests.
DropdownWidgetTest::setUp in tests/src/Unit/Plugin/widget/DropdownWidgetTest.php
Creates a new processor object for use in the tests.
LinksWidgetTest::setUp in tests/src/Unit/Plugin/widget/LinksWidgetTest.php
Sets up the container and other variables used in all the tests.
SliderWidgetTest::setUp in modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php
Sets up the container and other variables used in all the tests.

File

tests/src/Unit/Plugin/widget/WidgetTestBase.php, line 51

Class

WidgetTestBase
Base class for widget unit tests.

Namespace

Drupal\Tests\facets\Unit\Plugin\widget

Code

protected function setUp() {
  parent::setUp();
  $facet = new Facet([], 'facets_facet');
  $this->facet = $facet;

  /** @var \Drupal\facets\Result\Result[] $original_results */
  $original_results = [
    new Result($facet, 'llama', 'Llama', 10),
    new Result($facet, 'badger', 'Badger', 20),
    new Result($facet, 'duck', 'Duck', 15),
    new Result($facet, 'alpaca', 'Alpaca', 9),
  ];
  foreach ($original_results as $original_result) {
    $original_result
      ->setUrl(new Url('test'));
  }
  $this->originalResults = $original_results;

  // Create a container, so we can access string translation.
  $string_translation = $this
    ->prophesize(TranslationInterface::class);
  $url_generator = $this
    ->prophesize(UrlGeneratorInterface::class);
  $widget_manager = $this
    ->prophesize(WidgetPluginManager::class);
  $container = new ContainerBuilder();
  $container
    ->set('plugin.manager.facets.widget', $widget_manager
    ->reveal());
  $container
    ->set('string_translation', $string_translation
    ->reveal());
  $container
    ->set('url_generator', $url_generator
    ->reveal());
  \Drupal::setContainer($container);
  $this->queryTypes = [
    'date' => 'date',
    'string' => 'string',
    'numeric' => 'numeric',
    'range' => 'range',
  ];
}