function ArgumentDateTimeTest::testDatetimeArgumentMonth

Same name and namespace in other branches
  1. 8.9.x core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\ArgumentDateTimeTest::testDatetimeArgumentMonth()
  2. 10 core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\ArgumentDateTimeTest::testDatetimeArgumentMonth()
  3. 11.x core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\ArgumentDateTimeTest::testDatetimeArgumentMonth()

Tests month argument.

See also

\Drupal\datetime\Plugin\views\argument\MonthDate

File

core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php, line 96

Class

ArgumentDateTimeTest
Tests the <a href="/api/drupal/core%21modules%21datetime%21src%21Plugin%21views%21filter%21Date.php/class/Date/9" title="Date/time views filter." class="local">Drupal\datetime\Plugin\views\filter\Date</a> handler.

Namespace

Drupal\Tests\datetime\Kernel\Views

Code

public function testDatetimeArgumentMonth() {
    $view = Views::getView('test_argument_datetime');
    // The 'embed_1' display has the 'month' argument.
    $view->setDisplay('embed_1');
    $this->executeView($view, [
        '10',
    ]);
    $expected = [];
    $expected[] = [
        'nid' => $this->nodes[0]
            ->id(),
    ];
    $expected[] = [
        'nid' => $this->nodes[1]
            ->id(),
    ];
    $this->assertIdenticalResultset($view, $expected, $this->map);
    $view->destroy();
    $view->setDisplay('embed_1');
    $this->executeView($view, [
        '01',
    ]);
    $expected = [];
    $expected[] = [
        'nid' => $this->nodes[2]
            ->id(),
    ];
    $expected[] = [
        'nid' => $this->nodes[3]
            ->id(),
    ];
    $this->assertIdenticalResultset($view, $expected, $this->map);
    $view->destroy();
}

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