You are here

protected function CountLimitProcessorTest::setUp in Facets 8

Creates a new processor object for use in the tests.

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php, line 36

Class

CountLimitProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

protected function setUp() {
  parent::setUp();
  $facet = new Facet([], 'facets_facet');
  $this->originalResults = [
    new Result($facet, 'llama', 'llama', 10),
    new Result($facet, 'badger', 'badger', 5),
    new Result($facet, 'duck', 'duck', 15),
  ];
  $processor_id = 'count_limit';
  $this->processor = new CountLimitProcessor([], $processor_id, []);
  $processor_definitions = [
    $processor_id => [
      'id' => $processor_id,
      'class' => CountLimitProcessor::class,
    ],
  ];
  $manager = $this
    ->getMockBuilder(ProcessorPluginManager::class)
    ->disableOriginalConstructor()
    ->getMock();
  $manager
    ->expects($this
    ->any())
    ->method('getDefinitions')
    ->willReturn($processor_definitions);
  $manager
    ->expects($this
    ->any())
    ->method('createInstance')
    ->willReturn($this->processor);
  $container_builder = new ContainerBuilder();
  $container_builder
    ->set('plugin.manager.facets.processor', $manager);
  \Drupal::setContainer($container_builder);
}