diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index 6f3320f..27b58ab 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -270,7 +270,7 @@ function node_views_data() { ), ); - $data['node']['date_year_month'] = array( + $data['node']['created_year_month'] = array( 'title' => t('Created year + month'), 'help' => t('Date in the form of YYYYMM.'), 'argument' => array( diff --git a/core/modules/views/config/views.view.archive.yml b/core/modules/views/config/views.view.archive.yml index c1bfca9..b5102a5 100644 --- a/core/modules/views/config/views.view.archive.yml +++ b/core/modules/views/config/views.view.archive.yml @@ -48,7 +48,7 @@ display: override: '1' items_per_page: '30' specify_validation: '1' - plugin_id: node_created_year_month + plugin_id: date_year_month filters: status: id: status diff --git a/core/modules/views/lib/Drupal/views/Tests/ProvidedViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/ProvidedViewsTest.php new file mode 100644 index 0000000..4fc2c9a --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/ProvidedViewsTest.php @@ -0,0 +1,68 @@ + 'Provided views', + 'description' => 'Tests default views provided by the Views module.', + 'group' => 'Views Config', + ); + } + + /** + * Tests the archive view. + */ + public function testArchiveView() { + // Create two nodes in the same month, and one in each following month. + $node = array( + 'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT + ); + $this->drupalCreateNode($node); + $this->drupalCreateNode($node); + $node = array( + 'created' => 282891600, // Tue, 19 Dec 1978 05:00:00 GMT + ); + $this->drupalCreateNode($node); + $node = array( + 'created' => 285570000, // Fri, 19 Jan 1979 05:00:00 GMT + ); + $this->drupalCreateNode($node); + + $view = views_get_view('archive'); + $view->setDisplay('page_1'); + $this->executeView($view); + $column_map = array('nid' => 'nid', 'created_year_month' => 'created_year_month', 'num_records' => 'num_records'); + $expected_result = array( + array( + 'nid' => 4, + 'created_year_month' => 197901, + 'num_records' => 1, + ), + array( + 'nid' => 3, + 'created_year_month' => 197812, + 'num_records' => 1, + ), + array( + 'nid' => 1, + 'created_year_month' => 197811, + 'num_records' => 2, + ), + ); + $this->assertIdenticalResultset($view, $expected_result, $column_map); + } + +}