function MonthDatePluginTest::testMonthDatePlugin

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/MonthDatePluginTest.php \Drupal\Tests\views\Functional\Plugin\MonthDatePluginTest::testMonthDatePlugin()
  2. 8.9.x core/modules/views/tests/src/Functional/Plugin/MonthDatePluginTest.php \Drupal\Tests\views\Functional\Plugin\MonthDatePluginTest::testMonthDatePlugin()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/MonthDatePluginTest.php \Drupal\Tests\views\Functional\Plugin\MonthDatePluginTest::testMonthDatePlugin()

Tests the Month Date Plugin.

File

core/modules/views/tests/src/Functional/Plugin/MonthDatePluginTest.php, line 66

Class

MonthDatePluginTest
Tests the Month Date Plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testMonthDatePlugin() : void {
  $assert_session = $this->assertSession();
  // Test fallback value.
  $this->drupalGet('test-month-date-plugin');
  $assert_session->statusCodeEquals(200);
  $assert_session->pageTextContains($this->node1
    ->getTitle());
  $assert_session->pageTextContains($this->node2
    ->getTitle());
  // Test 'all' values.
  $this->drupalGet('test-month-date-plugin/all');
  $assert_session->statusCodeEquals(200);
  $assert_session->pageTextContains($this->node1
    ->getTitle());
  $assert_session->pageTextContains($this->node2
    ->getTitle());
  // Test valid month value.
  $this->drupalGet('test-month-date-plugin/10');
  $assert_session->statusCodeEquals(200);
  $assert_session->pageTextContains($this->node1
    ->getTitle());
  $assert_session->pageTextNotContains($this->node2
    ->getTitle());
  // Test query parameter.
  $url = Url::fromUserInput('/test-month-date-plugin', [
    'query' => [
      'month' => 10,
    ],
  ]);
  $this->drupalGet($url);
  $assert_session->statusCodeEquals(200);
  $assert_session->pageTextContains($this->node1
    ->getTitle());
  $assert_session->pageTextNotContains($this->node2
    ->getTitle());
  // Test invalid month name.
  $this->drupalGet('test-month-date-plugin/invalid-month');
  $assert_session->statusCodeEquals(200);
  $assert_session->pageTextNotContains($this->node1
    ->getTitle());
  $assert_session->pageTextNotContains($this->node2
    ->getTitle());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.