Commit 29146a41 authored by webchick's avatar webchick

Issue #1806334 by dawehner, xjm, tim.plunkett, rootatwc: Convert the node...

Issue #1806334 by dawehner, xjm, tim.plunkett, rootatwc: Convert the node listing at /node to Views.
parent 5a4ab9f0
......@@ -234,6 +234,8 @@ public function getHookInfo() {
$this->hookInfo = array();
// We can't use $this->invokeAll() here or it would cause an infinite
// loop.
// Make sure that the modules are loaded before checking.
$this->reload();
foreach ($this->moduleList as $module => $filename) {
$function = $module . '_hook_info';
if (function_exists($function)) {
......
......@@ -17,7 +17,7 @@ class AggregatorRenderingTest extends AggregatorTestBase {
*
* @var array
*/
public static $modules = array('block');
public static $modules = array('block', 'test_page_test');
public static function getInfo() {
return array(
......@@ -53,7 +53,7 @@ public function testBlockLinks() {
$block = $this->drupalPlaceBlock("aggregator_feed_block:{$feed->id()}", array('label' => 'feed-' . $feed->label()), array('block_count' => 2));
// Confirm that the block is now being displayed on pages.
$this->drupalGet('node');
$this->drupalGet('test-page');
$this->assertText($block->label(), 'Feed block is displayed on the page.');
// Find the expected read_more link.
......@@ -71,7 +71,7 @@ public function testBlockLinks() {
$feed->block = 0;
$feed->save();
// Check that the block is no longer displayed.
$this->drupalGet('node');
$this->drupalGet('test-page');
$this->assertNoText($block->label(), 'Feed block is not displayed on the page when number of items is set to 0.');
}
......
......@@ -109,10 +109,6 @@ function testCommentInterface() {
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$this->assertTrue($this->commentExists($reply, TRUE), 'Modified reply found.');
// Correct link count
$this->drupalGet('node');
$this->assertRaw('4 comments', 'Link to the 4 comments exist.');
// Confirm a new comment is posted to the correct page.
$this->setCommentsPerPage(2);
$comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
......
......@@ -12,6 +12,15 @@
*/
class CommentLinksTest extends CommentTestBase {
/**
* Use the main node listing to test rendering on teasers.
*
* @var array
*
* @todo Remove this dependency.
*/
public static $modules = array('views');
public static function getInfo() {
return array(
'name' => 'Comment links',
......
......@@ -12,6 +12,15 @@
*/
class CommentNewIndicatorTest extends CommentTestBase {
/**
* Use the main node listing to test rendering on teasers.
*
* @var array
*
* @todo Remove this dependency.
*/
public static $modules = array('views');
public static function getInfo() {
return array(
'name' => "Comment 'new' indicator",
......
......@@ -19,7 +19,7 @@ class ContextualDynamicContextTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('contextual', 'node');
public static $modules = array('contextual', 'node', 'views');
public static function getInfo() {
return array(
......
......@@ -79,13 +79,16 @@ function setUp() {
* We check data structure for both node and node revision tables.
*/
function testViewsData() {
$data = drupal_container()->get('views.views_data')->get();
$views_data = $this->container->get('views.views_data');
$data = array();
// Check the table and the joins of the first field.
// Attached to node only.
$field = $this->fields[0];
$current_table = _field_sql_storage_tablename($field);
$revision_table = _field_sql_storage_revision_tablename($field);
$data[$current_table] = $views_data->get($current_table);
$data[$revision_table] = $views_data->get($revision_table);
$this->assertTrue(isset($data[$current_table]));
$this->assertTrue(isset($data[$revision_table]));
......@@ -117,6 +120,8 @@ function testViewsData() {
$field_2 = $this->fields[2];
$current_table_2 = _field_sql_storage_tablename($field_2);
$revision_table_2 = _field_sql_storage_revision_tablename($field_2);
$data[$current_table_2] = $views_data->get($current_table_2);
$data[$revision_table_2] = $views_data->get($revision_table_2);
$this->assertTrue(isset($data[$current_table_2]));
$this->assertTrue(isset($data[$revision_table_2]));
......
......@@ -179,9 +179,9 @@ function testContentTypeDirLang() {
));
}
$this->drupalGet('node');
// Check if English node does not have lang tag.
$this->drupalGet('node/' . $nodes['en']->nid);
$pattern = '|id="node-' . $nodes['en']->nid . '"[^<>]*lang="en"|';
$this->assertNoPattern($pattern, 'The lang tag has not been assigned to the English node.');
......@@ -190,18 +190,18 @@ function testContentTypeDirLang() {
$this->assertNoPattern($pattern, 'The dir tag has not been assigned to the English node.');
// Check if Arabic node has lang="ar" & dir="rtl" tags.
$this->drupalGet('node/' . $nodes['ar']->nid);
$pattern = '|id="node-' . $nodes['ar']->nid . '"[^<>]*lang="ar" dir="rtl"|';
$this->assertPattern($pattern, 'The lang and dir tags have been assigned correctly to the Arabic node.');
// Check if Spanish node has lang="es" tag.
$this->drupalGet('node/' . $nodes['es']->nid);
$pattern = '|id="node-' . $nodes['es']->nid . '"[^<>]*lang="es"|';
$this->assertPattern($pattern, 'The lang tag has been assigned correctly to the Spanish node.');
// Check if Spanish node does not have dir="ltr" tag.
$pattern = '|id="node-' . $nodes['es']->nid . '"[^<>]*lang="es" dir="ltr"|';
$this->assertNoPattern($pattern, 'The dir tag has not been assigned to the Spanish node.');
$this->drupalLogout();
}
......
......@@ -19,7 +19,7 @@ class LocalePathTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('node', 'locale', 'path');
public static $modules = array('node', 'locale', 'path', 'views');
public static function getInfo() {
return array(
......
......@@ -16,7 +16,7 @@ class MenuTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('menu', 'block');
public static $modules = array('menu', 'block', 'test_page_test');
protected $big_user;
protected $std_user;
......@@ -270,14 +270,14 @@ function testMenuQueryAndFragment() {
$this->drupalLogin($this->big_user);
// Make a path with query and fragment on.
$path = 'node?arg1=value1&arg2=value2';
$path = 'test-page?arg1=value1&arg2=value2';
$item = $this->addMenuLink(0, $path);
$this->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
$this->assertFieldByName('link_path', $path, 'Path is found with both query and fragment.');
// Now change the path to something without query and fragment.
$path = 'node';
$path = 'test-page';
$this->drupalPost('admin/structure/menu/item/' . $item['mlid'] . '/edit', array('link_path' => $path), t('Save'));
$this->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
$this->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.');
......
status: '0'
module: node
id: frontpage
description: 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'
tag: default
base_field: nid
base_table: node
human_name: 'Front page'
core: '8'
core: 8.x
description: 'A list of nodes marked for display on the front page.'
status: '1'
display:
default:
id: default
display_title: Master
display_plugin: default
position: '1'
display_options:
query:
type: views_query
options:
query_comment: false
access:
type: none
type: perm
cache:
type: none
empty:
area:
admin_label: ''
content: 'No front page content has been created yet.'
empty: '1'
field: area
format: plain_text
group_type: group
id: area
label: ''
relationship: none
table: views
tokenize: '0'
plugin_id: text
node_listing_empty:
admin_label: ''
empty: '1'
field: node_listing_empty
group_type: group
id: node_listing_empty
label: ''
relationship: none
table: node
plugin_id: node_listing_empty
title:
id: title
table: views
field: title
relationship: none
group_type: group
admin_label: ''
label: ''
empty: '1'
title: 'Welcome to Drupal'
plugin_id: title
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: node
options:
links: 1
sorts:
sticky:
id: sticky
table: node
field: sticky
order: DESC
plugin_id: standard
created:
id: created
table: node
field: created
order: DESC
plugin_id: date
filters:
promote:
admin_label: ''
expose:
description: ''
identifier: ''
label: ''
multiple: '0'
operator: ''
operator_id: '0'
remember: '0'
remember_roles:
authenticated: authenticated
required: '0'
use_operator: '0'
exposed: '0'
field: promote
group: '1'
group_info:
default_group: All
default_group_multiple: { }
description: ''
group_items: { }
identifier: ''
label: ''
multiple: '0'
optional: '1'
remember: '0'
widget: select
group_type: group
id: promote
is_grouped: '0'
operator: '='
relationship: none
table: node
field: promote
value: '1'
group: 0
expose:
operator: false
plugin_id: boolean
status:
expose:
operator: '0'
field: status
group: '1'
id: status
table: node
field: status
value: '1'
group: 0
expose:
operator: false
plugin_id: boolean
page_1:
id: page_1
display_title: Page
display_plugin: page
position: '2'
display_options:
query:
type: views_query
options: { }
path: frontpage
feed_1:
id: feed_1
display_title: Feed
display_plugin: feed
position: '3'
display_options:
pager:
options:
items_per_page: '10'
type: full
query:
type: views_query
options: { }
defaults:
title: false
title: 'Front page feed'
pager:
type: some
style:
type: rss
row:
type: node_rss
path: rss.xml
displays:
default: default
page: page
sitename_title: '1'
options:
build_mode: teaser
comments: '0'
links: '1'
type: node
sorts:
created:
field: created
id: created
order: DESC
table: node
plugin_id: date
sticky:
admin_label: ''
expose:
label: ''
exposed: '0'
field: sticky
group_type: group
id: sticky
order: ASC
relationship: none
table: node
plugin_id: boolean
style:
type: default
title: ''
display_plugin: default
display_title: Master
id: default
position: { }
page_1:
display_options:
path: node
display_plugin: page
display_title: Page
id: page_1
position: { }
human_name: Frontpage
langcode: und
module: node
id: frontpage
tag: ''
<?php
/**
* @file
* Contains \Drupal\node\Plugin\views\area\LinkAdd.
*/
namespace Drupal\node\Plugin\views\area;
use Drupal\Component\Annotation\Plugin;
use Drupal\views\Plugin\views\area\AreaPluginBase;
/**
* Defines an area plugin to display a node/add link.
*
* @ingroup views_area_handlers
*
* @Plugin(
* id = "node_listing_empty",
* module = "node"
* )
*/
class ListingEmpty extends AreaPluginBase {
/**
* Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*/
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
$element = array(
'#theme' => 'links',
'#links' => array(
array(
'href' => 'node/add',
'title' => t('Add new content')
)
) ,
'#access' => _node_add_access()
);
return drupal_render($element);
}
}
}
......@@ -12,6 +12,13 @@
*/
class NodeLoadMultipleTest extends NodeTestBase {
/**
* Enable Views to test the frontpage against node_load_multiple() results.
*
* @var array
*/
public static $modules = array('views');
public static function getInfo() {
return array(
'name' => 'Load multiple nodes',
......
......@@ -17,7 +17,7 @@ class NodeTitleTest extends NodeTestBase {
*
* @var array
*/
public static $modules = array('comment');
public static $modules = array('comment', 'views');
protected $admin_user;
......
......@@ -1708,13 +1708,6 @@ function node_menu() {
'access arguments' => array('administer content types'),
'file' => 'content_types.inc',
);
$items['node'] = array(
'page callback' => 'node_page_default',
'access arguments' => array('access content'),
'menu_name' => 'tools',
'type' => MENU_CALLBACK,
);
$items['node/add'] = array(
'title' => 'Add content',
'page callback' => 'node_add_page',
......@@ -2188,62 +2181,6 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) {
return entity_view_multiple($nodes, $view_mode, $langcode);
}
/**
* Page callback: Generates a listing of promoted nodes.
*
* @return array
* An array in the format expected by drupal_render().
*
* @see node_menu()
*/
function node_page_default() {
$site_config = config('system.site');
$select = db_select('node', 'n')
->fields('n', array('nid', 'sticky', 'created'))
->condition('n.promote', 1)
->condition('n.status', 1)
->orderBy('n.sticky', 'DESC')
->orderBy('n.created', 'DESC')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit(config('node.settings')->get('items_per_page'))
->addTag('node_access');
$nids = $select->execute()->fetchCol();
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
$build['nodes'] = node_view_multiple($nodes);
// 'rss.xml' is a path, not a file, registered in node_menu().
drupal_add_feed('rss.xml', $site_config->get('name') . ' ' . t('RSS'));
$build['pager'] = array(
'#theme' => 'pager',
'#weight' => 5,
);
drupal_set_title('');
}
else {
drupal_set_title(t('Welcome to @site-name', array('@site-name' => $site_config->get('name'))), PASS_THROUGH);
$default_message = '<p>' . t('No front page content has been created yet.') . '</p>';
$default_links = array();
if (_node_add_access()) {
$default_links[] = l(t('Add new content'), 'node/add');
}
if (!empty($default_links)) {
$default_message .= theme('item_list', array('items' => $default_links));
}
$build['default_message'] = array(
'#markup' => $default_message,
'#prefix' => '<div id="first-time">',
'#suffix' => '</div>',
);
}
return $build;
}
/**
* Page callback: Displays a single node.
*
......
......@@ -391,6 +391,14 @@ function node_views_data() {
),
);
$data['node']['node_listing_empty'] = array(
'title' => t('Empty Node Frontpage behavior'),
'help' => t('Provides a link to the node add overview page.'),
'area' => array(
'id' => 'node_listing_empty',
),
);
$data['node']['uid_revision'] = array(
'title' => t('User has a revision'),
'help' => t('All nodes where a certain user has a revision'),
......
......@@ -19,7 +19,7 @@ class CommentAttributesTest extends CommentTestBase {
*
* @var array
*/
public static $modules = array('comment', 'rdf');
public static $modules = array('views', 'node', 'comment', 'rdf');
public static function getInfo() {
return array(
......
......@@ -172,7 +172,10 @@ public function testVariableUpgrade() {
public function testFrontpageUpgrade() {
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
$this->assertTrue(module_exists('views'), 'Views is enabled after the upgrade.');
$this->assertTrue($this->container->get('module_handler')->moduleExists('views'), 'Views is enabled after the upgrade.');
$views = $this->container->get('plugin.manager.entity')->getStorageController('view')->load(array('frontpage'));
$view = reset($views);
$this->assertTrue($view->status(), 'The frontpage view is enabled after the upgrade.');
}
}
......@@ -2058,6 +2058,8 @@ function system_update_8046() {
// This does not fire a hook just calls views.
config_install_default_config('module', 'views');
// This imports the node frontpage view.
config_install_default_config('module', 'node');
}
}
......
......@@ -19,6 +19,13 @@ class AnalyzeTest extends ViewTestBase {
*/
public static $modules = array('views_ui');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() {
return array(
'name' => 'Views Analyze',
......@@ -41,10 +48,8 @@ public function setUp() {
*/
function testAnalyzeBasic() {
$this->drupalLogin($this->admin);
// Enable the frontpage view and click the analyse button.
$view = views_get_view('frontpage');
$this->drupalGet('admin/structure/views/view/frontpage/edit');
$this->drupalGet('admin/structure/views/view/test_view/edit');
$this->assertLink(t('analyze view'));
// This redirects the user to the analyze form.
......
......@@ -175,7 +175,7 @@ public function testTitleArea() {
$view->storage->enable()->save();
$this->drupalGet('frontpage');
$this->drupalGet('node');
$this->assertText('Overridden title', 'Overridden title found.');
}
......
......@@ -138,4 +138,5 @@ public function testRelationshipQuery() {
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
}
......@@ -19,7 +19,7 @@ class DisplayTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_filter_groups', 'test_get_attach_displays');
public static $testViews = array('test_filter_groups', 'test_get_attach_displays', 'test_view');
/**
* Modules to enable.
......@@ -56,7 +56,7 @@ public function setUp() {
* @see Drupal\views_test_data\Plugin\views\display\DisplayTest
*/
function testDisplayPlugin() {
$view = views_get_view('frontpage');
$view = views_get_view('test_view');
// Add a new 'display_test' display and test it's there.
$view->storage->addDisplay('display_test');
......@@ -95,7 +95,7 @@ function testDisplayPlugin() {
$this->assertTrue(strpos($output, '<h1>Test option title</h1>') !== FALSE, 'The test_option value found in display output title.');
// Test that the display category/summary is in the UI.
$this->drupalGet('admin/structure/views/view/frontpage/edit/display_test_1');
$this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1');
$this->assertText('Display test settings');
$this->clickLink('Test option title');
......@@ -104,7 +104,7 @@ function testDisplayPlugin() {
$this->drupalPost(NULL, array('test_option' => $this->randomString), t('Apply'));
// Check the new value has been saved by checking the UI summary text.
$this->drupalGet('admin/structure/views/view/frontpage/edit/display_test_1');
$this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1');
$this->assertRaw($this->randomString);
// Test the enable/disable status of a display.
......
......@@ -17,7 +17,7 @@ class PagerTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_store_pager_settings', 'test_pager_none', 'test_pager_some', 'test_pager_full', 'test_view_pager_full_zero_items_per_page');
public static $testViews = array('test_store_pager_settings', 'test_pager_none', 'test_pager_some', 'test_pager_full', 'test_view_pager_full_zero_items_per_page', 'test_view');