You are here

public function BambooTwigExtensionsTest::testDateDiffTimeAgoForcedUnit in Bamboo Twig 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/BambooTwigExtensionsTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigExtensionsTest::testDateDiffTimeAgoForcedUnit()
  2. 8.2 tests/src/Functional/BambooTwigExtensionsTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigExtensionsTest::testDateDiffTimeAgoForcedUnit()
  3. 8.3 tests/src/Functional/BambooTwigExtensionsTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigExtensionsTest::testDateDiffTimeAgoForcedUnit()

Cover the \Twig_Extensions_Extension_Date::diff.

File

tests/src/Functional/BambooTwigExtensionsTest.php, line 108

Class

BambooTwigExtensionsTest
Tests Extensions twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

public function testDateDiffTimeAgoForcedUnit() {
  $this
    ->drupalGet('/bamboo-twig-extensions');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-1', '1 second ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-2', '0.016666666666667 minute ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-3', '5 seconds ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-4', '60 seconds ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-5', '1 minute ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-6', '302 seconds ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-7', '3660 seconds ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-8', '32702 seconds ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-9', '0.27152777777778 day ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-10', '4.2715277777778 days ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-11', '30.271527777778 days ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-12', '1.0416666666667 month ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-13', '6.1083333333333 months ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-14', '391.27152777778 days ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-15', '37.408333333333 months ago');
  $this
    ->assertElementContains('.test-extensions div.date-diff-unit-ago-16', '3.072553045859 years ago');
}