You are here

class RangeSliderWidgetTest in Facets 8

Unit test for widget.

@group facets

Hierarchy

Expanded class hierarchy of RangeSliderWidgetTest

File

modules/facets_range_widget/tests/src/Unit/Plugin/widget/RangeSliderWidgetTest.php, line 12

Namespace

Drupal\Tests\facets_range_widget\Unit\Plugin\widget
View source
class RangeSliderWidgetTest extends SliderWidgetTest {

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this->widget = new RangeSliderWidget([], 'range_slider_widget', []);
  }

  /**
   * {@inheritdoc}
   */
  public function testGetQueryType() {
    $result = $this->widget
      ->getQueryType($this->queryTypes);
    $this
      ->assertEquals('range', $result);
  }

  /**
   * {@inheritdoc}
   */
  public function testDefaultConfiguration() {
    $default_config = $this->widget
      ->defaultConfiguration();
    $expected = [
      'show_numbers' => FALSE,
      'prefix' => '',
      'suffix' => '',
      'min_type' => 'search_result',
      'min_value' => 0,
      'max_type' => 'search_result',
      'max_value' => 10,
      'step' => 1,
    ];
    $this
      ->assertEquals($expected, $default_config);
  }

  /**
   * {@inheritdoc}
   */
  public function testIsPropertyRequired() {
    $this
      ->assertFalse($this->widget
      ->isPropertyRequired('llama', 'owl'));
    $this
      ->assertTrue($this->widget
      ->isPropertyRequired('range_slider', 'processors'));
    $this
      ->assertTrue($this->widget
      ->isPropertyRequired('show_only_one_result', 'settings'));
  }

  /**
   * {@inheritdoc}
   */
  public function testBuild() {
    $build = parent::testBuild();
    $this
      ->assertTrue($build['range']);
    $this
      ->assertEquals([
      3,
      19999,
    ], $build['values']);
  }

}

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.
RangeSliderWidgetTest::setUp public function Sets up the container and other variables used in all the tests. Overrides SliderWidgetTest::setUp
RangeSliderWidgetTest::testBuild public function Tests building of the widget. Overrides SliderWidgetTest::testBuild
RangeSliderWidgetTest::testDefaultConfiguration public function Tests default configuration. Overrides SliderWidgetTest::testDefaultConfiguration
RangeSliderWidgetTest::testGetQueryType public function Tests get query type. Overrides SliderWidgetTest::testGetQueryType
RangeSliderWidgetTest::testIsPropertyRequired public function Tests default for required properties. Overrides SliderWidgetTest::testIsPropertyRequired
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.
WidgetTestBase::$facet protected property The facet used for the widget test.
WidgetTestBase::$originalResults protected property An array containing the results for the widget.
WidgetTestBase::$queryTypes protected property An array of possible query types.
WidgetTestBase::$widget protected property The widget to be tested.
WidgetTestBase::buildLinkAssertion protected function Build a formattable markup object to use as assertion.