You are here

public function ShowTextWhenEmptyProcessorTest::testBuild in Facets 8

Tests the build method.

@covers ::build

File

modules/facets_summary/tests/src/Unit/Plugin/Processor/ShowTextWhenEmptyProcessorTest.php, line 64

Class

ShowTextWhenEmptyProcessorTest
Class ShowTextWhenEmptyProcessorTest.

Namespace

Drupal\Tests\facets_summary\Unit\Plugin\Processor

Code

public function testBuild() {
  $summary = new FacetsSummary([], 'facets_summary');
  $summary
    ->setFacetSourceId('foo');
  $result = $this->processor
    ->build($summary, [
    'foo',
  ], []);
  $this
    ->assertSame('array', gettype($result));
  $this
    ->assertArrayHasKey('#theme', $result);
  $this
    ->assertEquals('facets_summary_empty', $result['#theme']);
  $this
    ->assertArrayHasKey('#message', $result);
  $configuration = [
    'text' => [
      'value' => 'llama',
      'format' => 'html',
    ],
  ];
  $this->processor
    ->setConfiguration($configuration);
  $result = $this->processor
    ->build($summary, [
    'foo',
  ], []);
  $this
    ->assertEquals('llama', $result['#message']['#text']);
}