function MonthDatePluginTest::testMonthDatePlugin

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Functional/Plugin/MonthDatePluginTest.php \Drupal\Tests\views\Functional\Plugin\MonthDatePluginTest::testMonthDatePlugin()
  2. 10 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() {
    $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.