Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -9,7 +9,6 @@ namespace Drupal\tracker\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\user\UserInterface;
use Drupal\Component\Utility\SafeMarkup;
/**
* Controller for tracker.user_tab route.
@ -28,6 +27,6 @@ class TrackerUserTab extends ControllerBase {
* Title callback for the tracker.user_tab route.
*/
public function getTitle(UserInterface $user) {
return SafeMarkup::checkPlain($user->getUsername());
return $user->getUsername();
}
}

View file

@ -0,0 +1,47 @@
<?php
/**
* @file
* Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerNode.
*/
namespace Drupal\tracker\Plugin\migrate\source\d7;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 tracker node source from database.
*
* @MigrateSource(
* id = "d7_tracker_node",
* source_provider = "tracker"
* )
*/
class TrackerNode extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
return $this->select('tracker_node', 'tn')->fields('tn');
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'nid' => $this->t('The {node}.nid this record tracks.'),
'published' => $this->t('Boolean indicating whether the node is published.'),
'changed' => $this->t('The Unix timestamp when the node was most recently saved or commented on.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['nid']['type'] = 'integer';
return $ids;
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* @file
* Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerUser.
*/
namespace Drupal\tracker\Plugin\migrate\source\d7;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 tracker user source from database.
*
* @MigrateSource(
* id = "d7_tracker_user",
* source_provider = "tracker"
* )
*/
class TrackerUser extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
return $this->select('tracker_user', 'tu')->fields('tu');
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'nid' => $this->t('The {user}.nid this record tracks.'),
'uid' => $this->t('The {users}.uid of the node author or commenter.'),
'published' => $this->t('Boolean indicating whether the node is published.'),
'changed' => $this->t('The Unix timestamp when the user was most recently saved or commented on.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['nid']['type'] = 'integer';
$ids['uid']['type'] = 'integer';
return $ids;
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
* @file
* Contains \Drupal\tracker\Tests\Migrate\d7\MigrateTrackerNodeTest.
*/
namespace Drupal\tracker\Tests\Migrate\d7;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\Core\Database\Database;
/**
* Tests migration of tracker_node.
*
* @group tracker
*/
class MigrateTrackerNodeTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'node',
'text',
'tracker',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig(static::$modules);
$this->installSchema('node', ['node_access']);
$this->installSchema('tracker', ['tracker_node', 'tracker_user']);
$this->executeMigrations([
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_node__test_content_type',
'd7_tracker_node',
]);
}
/**
* Tests migration of tracker node table.
*/
public function testMigrateTrackerNode() {
$connection = Database::getConnection('default', 'migrate');
$num_rows = $connection
->select('tracker_node', 'tn')
->fields('tn', ['nid', 'published', 'changed'])
->countQuery()
->execute()
->fetchField();
$this->assertIdentical('1', $num_rows);
$tracker_nodes = $connection
->select('tracker_node', 'tn')
->fields('tn', ['nid', 'published', 'changed'])
->execute();
$row = $tracker_nodes->fetchAssoc();
$this->assertIdentical('1', $row['nid']);
$this->assertIdentical('1', $row['published']);
$this->assertIdentical('1421727536', $row['changed']);
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
* @file
* Contains \Drupal\tracker\Tests\Migrate\d7\MigrateTrackerUserTest.
*/
namespace Drupal\tracker\Tests\Migrate\d7;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\Core\Database\Database;
/**
* Tests migration of tracker_user.
*
* @group tracker
*/
class MigrateTrackerUserTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'node',
'text',
'tracker',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig(static::$modules);
$this->installSchema('node', ['node_access']);
$this->installSchema('tracker', ['tracker_node', 'tracker_user']);
$this->executeMigrations([
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_node__test_content_type',
'd7_tracker_node',
]);
}
/**
* Tests migration of tracker user table.
*/
public function testMigrateTrackerUser() {
$connection = Database::getConnection('default', 'migrate');
$num_rows = $connection
->select('tracker_user', 'tn')
->fields('tu', ['nid', 'uid', 'published', 'changed'])
->countQuery()
->execute()
->fetchField();
$this->assertIdentical('1', $num_rows);
$tracker_nodes = $connection
->select('tracker_user', 'tu')
->fields('tu', ['nid', 'uid', 'published', 'changed'])
->execute();
$row = $tracker_nodes->fetchAssoc();
$this->assertIdentical('1', $row['nid']);
$this->assertIdentical('2', $row['uid']);
$this->assertIdentical('1', $row['published']);
$this->assertIdentical('1421727536', $row['changed']);
}
}

View file

@ -86,10 +86,16 @@ class TrackerTest extends WebTestBase {
$this->assertLink(t('My recent content'), 0, 'User tab shows up on the global tracker page.');
// Assert cache contexts, specifically the pager and node access contexts.
$this->assertCacheContexts(['languages:language_interface', 'route.name', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user.node_grants:view', 'user']);
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user.node_grants:view', 'user']);
// Assert cache tags for the action/tabs blocks, visible node, and node list
// cache tag.
$expected_tags = Cache::mergeTags($published->getCacheTags(), $published->getOwner()->getCacheTags());
// Because the 'user.permissions' cache context is being optimized away.
$role_tags = [];
foreach ($this->user->getRoles() as $rid) {
$role_tags[] = "config:user.role.$rid";
}
$expected_tags = Cache::mergeTags($expected_tags, $role_tags);
$block_tags = [
'block_view',
'config:block.block.page_actions_block',
@ -164,12 +170,18 @@ class TrackerTest extends WebTestBase {
$this->assertText($other_published_my_comment->label(), "Nodes that the user has commented on appear in the user's tracker listing.");
// Assert cache contexts.
$this->assertCacheContexts(['languages:language_interface', 'route.name', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
// Assert cache tags for the visible nodes (including owners) and node list
// cache tag.
$expected_tags = Cache::mergeTags($my_published->getCacheTags(), $my_published->getOwner()->getCacheTags());
$expected_tags = Cache::mergeTags($expected_tags, $other_published_my_comment->getCacheTags());
$expected_tags = Cache::mergeTags($expected_tags, $other_published_my_comment->getOwner()->getCacheTags());
// Because the 'user.permissions' cache context is being optimized away.
$role_tags = [];
foreach ($this->user->getRoles() as $rid) {
$role_tags[] = "config:user.role.$rid";
}
$expected_tags = Cache::mergeTags($expected_tags, $role_tags);
$block_tags = [
'block_view',
'config:block.block.page_actions_block',
@ -184,7 +196,7 @@ class TrackerTest extends WebTestBase {
$expected_tags = Cache::mergeTags($expected_tags, $additional_tags);
$this->assertCacheTags($expected_tags);
$this->assertCacheContexts(['languages:language_interface', 'route.name', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']);
$this->assertLink($my_published->label());
$this->assertNoLink($unpublished->label());
@ -198,6 +210,19 @@ class TrackerTest extends WebTestBase {
$this->drupalPostForm('comment/1/edit', array('status' => CommentInterface::NOT_PUBLISHED), t('Save'));
$this->drupalGet('user/' . $this->user->id() . '/activity');
$this->assertNoText($other_published_my_comment->label(), 'Unpublished comments are not counted on the tracker listing.');
// Test escaping of title on user's tracker tab.
\Drupal::service('module_installer')->install(['user_hooks_test']);
Cache::invalidateTags(['rendered']);
\Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE);
$this->drupalGet('user/' . $this->user->id() . '/activity');
$this->assertEscaped('<em>' . $this->user->id() . '</em>');
\Drupal::state()->set('user_hooks_test_user_format_name_alter_safe', TRUE);
Cache::invalidateTags(['rendered']);
$this->drupalGet('user/' . $this->user->id() . '/activity');
$this->assertNoEscaped('<em>' . $this->user->id() . '</em>');
$this->assertRaw('<em>' . $this->user->id() . '</em>');
}
/**