diff -u b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php --- b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php @@ -1,16 +1,12 @@ getArgFormat(); } @@ -112,2 +108,3 @@ } + } diff -u b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php --- b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php +++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php @@ -1,10 +1,5 @@ getArgFormat(); } diff -u b/core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php b/core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php --- b/core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php +++ b/core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php @@ -1,12 +1,9 @@ currentNode = $this->drupalCreateNode(['type' => 'page']); $this->sameTimeNode = $this->drupalCreateNode(['type' => 'page']); $this->otherTimeNode = $this->drupalCreateNode(['type' => 'page', 'created' => strtotime('-5 days'), 'changed' => strtotime('-5 days')]); + $this->fixedTimeNode = $this->drupalCreateNode(['type' => 'page', 'created' => strtotime('1975-05-18'), 'changed' => strtotime('1975-05-18')]); + $this->sameMonthNode = $this->drupalCreateNode(['type' => 'page', 'created' => strtotime('1975-05-13'), 'changed' => strtotime('1975-05-13')]); } /** * Test the 'Current node created time' default argument handler. * - * @see Drupal\node\Plugin\views\argument_default\NodeCreated + * @see \Drupal\node\Plugin\views\argument_default\NodeCreated */ - function testArgumentDefaultNodeCreated() { + public function ptestArgumentDefaultNodeCreated() { $this->drupalPlaceBlock('views_block:test_argument_default_date-block_1', array('label' => 'test_argument_default_date-block_1:1')); // Assert that only nodes with the same creation time as the current node @@ -72,14 +81,28 @@ $this->assertText($this->currentNode->getTitle()); $this->assertText($this->sameTimeNode->getTitle()); $this->assertNoText($this->otherTimeNode->getTitle()); + + // Update the View to use the Y-m format argument. + $view = View::load('test_argument_default_date'); + $display = &$view->getDisplay('block_1'); + $display['display_options']['arguments']['created']['plugin_id'] = 'date_year_month'; + $display['display_options']['arguments']['created']['field'] = 'created_year_month'; + $display['display_options']['arguments']['created']['id'] = 'created_year_month'; + $view->save(); + + // Test that the nodes with a create date in the same month are shown. + $this->drupalGet($this->fixedTimeNode->toUrl()); + $this->assertText($this->fixedTimeNode->getTitle()); + $this->assertText($this->sameMonthNode->getTitle()); + $this->assertNoText($this->currentNode->getTitle()); } /** * Test the 'Current node changed time' default argument handler. * - * @see Drupal\node\Plugin\views\argument_default\NodeChanged + * @see \Drupal\node\Plugin\views\argument_default\NodeChanged */ - function testArgumentDefaultNodeChanged() { + public function testArgumentDefaultNodeChanged() { $this->drupalPlaceBlock('views_block:test_argument_default_date-block_2', array('label' => 'test_argument_default_date-block_2:2')); // Assert that only nodes with the same changed time as the current node diff -u b/core/modules/views/src/Plugin/views/argument_default/Date.php b/core/modules/views/src/Plugin/views/argument_default/Date.php --- b/core/modules/views/src/Plugin/views/argument_default/Date.php +++ b/core/modules/views/src/Plugin/views/argument_default/Date.php @@ -1,10 +1,5 @@