You are here

public function ArgumentDateTest::testYearMonthHandler in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/src/Tests/Handler/ArgumentDateTest.php \Drupal\views\Tests\Handler\ArgumentDateTest::testYearMonthHandler()

Tests the YearMonth handler.

See also

\Drupal\node\Plugin\views\argument\CreatedYearMonth

File

core/modules/views/src/Tests/Handler/ArgumentDateTest.php, line 278
Contains \Drupal\views\Tests\Handler\ArgumentDateTest.

Class

ArgumentDateTest
Tests the core date argument handlers.

Namespace

Drupal\views\Tests\Handler

Code

public function testYearMonthHandler() {
  $this->container
    ->get('database')
    ->update('views_test_data')
    ->fields(array(
    'created' => gmmktime(0, 0, 0, 1, 1, 2001),
  ))
    ->condition('id', 3)
    ->execute();
  $this->container
    ->get('database')
    ->update('views_test_data')
    ->fields(array(
    'created' => gmmktime(0, 0, 0, 4, 1, 2001),
  ))
    ->condition('id', 4)
    ->execute();
  $this->container
    ->get('database')
    ->update('views_test_data')
    ->fields(array(
    'created' => gmmktime(0, 0, 0, 4, 1, 2001),
  ))
    ->condition('id', 5)
    ->execute();
  $view = Views::getView('test_argument_date');
  $view
    ->setDisplay('embed_5');
  $this
    ->executeView($view, array(
    '200001',
  ));
  $expected = array();
  $expected[] = array(
    'id' => 1,
  );
  $expected[] = array(
    'id' => 2,
  );
  $this
    ->assertIdenticalResultset($view, $expected, $this->columnMap);
  $view
    ->destroy();
  $view
    ->setDisplay('embed_5');
  $this
    ->executeView($view, array(
    '200101',
  ));
  $expected = array();
  $expected[] = array(
    'id' => 3,
  );
  $this
    ->assertIdenticalResultset($view, $expected, $this->columnMap);
  $view
    ->destroy();
  $view
    ->setDisplay('embed_5');
  $this
    ->executeView($view, array(
    '200104',
  ));
  $expected = array();
  $expected[] = array(
    'id' => 4,
  );
  $expected[] = array(
    'id' => 5,
  );
  $this
    ->assertIdenticalResultset($view, $expected, $this->columnMap);
  $view
    ->destroy();
  $view
    ->setDisplay('embed_5');
  $this
    ->executeView($view, array(
    '201301',
  ));
  $expected = array();
  $this
    ->assertIdenticalResultset($view, $expected, $this->columnMap);
}