You are here

public function FacetsDateHandlerTest::testGapCompare in Facets 8

Tests for ::gapCompare method.

File

tests/src/Unit/Utility/FacetsDateHandlerTest.php, line 198

Class

FacetsDateHandlerTest
Unit test for Date Handler Service.

Namespace

Drupal\Tests\facets\Unit\Utility

Code

public function testGapCompare() {
  $fd = $this->handler;

  // Timestamps are equals.
  $this
    ->assertEquals(0, $fd
    ->gapCompare(static::TIMESTAMP, static::TIMESTAMP));

  // Timestamps are equals.
  $this
    ->assertEquals(0, $fd
    ->gapCompare($fd::FACETS_DATE_YEAR, $fd::FACETS_DATE_YEAR));

  // gap1 is less than gap2.
  $this
    ->assertEquals(-1, $fd
    ->gapCompare($fd::FACETS_DATE_MONTH, $fd::FACETS_DATE_YEAR));

  // gap1 is less than gap2.
  $this
    ->assertEquals(1, $fd
    ->gapCompare($fd::FACETS_DATE_MONTH, $fd::FACETS_DATE_DAY));
}