You are here

class ResetFacetsProcessorTest in Facets 8

Class ResetFacetsProcessorTest.

@group facets @coversDefaultClass \Drupal\facets_summary\Plugin\facets_summary\processor\ResetFacetsProcessor

Hierarchy

Expanded class hierarchy of ResetFacetsProcessorTest

File

modules/facets_summary/tests/src/Unit/Plugin/Processor/ResetFacetsProcessorTest.php, line 17

Namespace

Drupal\Tests\facets_summary\Unit\Plugin\Processor
View source
class ResetFacetsProcessorTest extends UnitTestCase {

  /**
   * The processor we're testing.
   *
   * @var \Drupal\facets_summary\Processor\ProcessorInterface|\Drupal\facets_summary\Processor\BuildProcessorInterface
   */
  protected $processor;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $string_translation = $this
      ->prophesize(TranslationInterface::class);
    $container = new ContainerBuilder();
    $container
      ->set('string_translation', $string_translation
      ->reveal());
    \Drupal::setContainer($container);
    $this->processor = new ResetFacetsProcessor([
      'settings' => [
        'link_text' => 'Text',
      ],
    ], 'reset_facets', []);
  }

  /**
   * Tests the is hidden method.
   *
   * @covers ::isHidden
   */
  public function testIsHidden() {
    $this
      ->assertFalse($this->processor
      ->isHidden());
  }

  /**
   * Tests the is locked method.
   *
   * @covers ::isLocked
   */
  public function testIsLocked() {
    $this
      ->assertFalse($this->processor
      ->isLocked());
  }

  /**
   * Tests the build method.
   *
   * @covers ::build
   */
  public function testBuildWithEmptyItems() {
    $summary = new FacetsSummary([], 'facets_summary');
    $summary
      ->setFacetSourceId('foo');
    $config = [
      'processor_id' => 'reset_facets',
      'weights' => [],
      'settings' => [
        'link_text' => 'Text',
      ],
    ];
    $summary
      ->addProcessor($config);
    $result = $this->processor
      ->build($summary, [
      'foo',
    ], []);
    $this
      ->assertSame('array', gettype($result));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
ResetFacetsProcessorTest::$processor protected property The processor we're testing.
ResetFacetsProcessorTest::setUp public function Overrides UnitTestCase::setUp
ResetFacetsProcessorTest::testBuildWithEmptyItems public function Tests the build method.
ResetFacetsProcessorTest::testIsHidden public function Tests the is hidden method.
ResetFacetsProcessorTest::testIsLocked public function Tests the is locked method.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.