Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\AssertButtonsTrait.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,12 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Condition\NodeConditionTest.
*/
namespace Drupal\node\Tests\Condition;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
@ -22,11 +19,11 @@ class NodeConditionTest extends EntityUnitTestBase {
parent::setUp();
// Create the node bundles required for testing.
$type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
$type = NodeType::create(['type' => 'page', 'name' => 'page']);
$type->save();
$type = entity_create('node_type', array('type' => 'article', 'name' => 'article'));
$type = NodeType::create(['type' => 'article', 'name' => 'article']);
$type->save();
$type = entity_create('node_type', array('type' => 'test', 'name' => 'test'));
$type = NodeType::create(['type' => 'test', 'name' => 'test']);
$type->save();
}
@ -38,11 +35,11 @@ class NodeConditionTest extends EntityUnitTestBase {
$this->createUser();
// Get some nodes of various types to check against.
$page = entity_create('node', array('type' => 'page', 'title' => $this->randomMachineName(), 'uid' => 1));
$page = Node::create(['type' => 'page', 'title' => $this->randomMachineName(), 'uid' => 1]);
$page->save();
$article = entity_create('node', array('type' => 'article', 'title' => $this->randomMachineName(), 'uid' => 1));
$article = Node::create(['type' => 'article', 'title' => $this->randomMachineName(), 'uid' => 1]);
$article->save();
$test = entity_create('node', array('type' => 'test', 'title' => $this->randomMachineName(), 'uid' => 1));
$test = Node::create(['type' => 'test', 'title' => $this->randomMachineName(), 'uid' => 1]);
$test->save();
// Grab the node type condition and configure it to check against node type

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Config\NodeImportChangeTest.
*/
namespace Drupal\node\Tests\Config;
use Drupal\node\Entity\NodeType;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Config\NodeImportCreateTest.
*/
namespace Drupal\node\Tests\Config;
use Drupal\field\Entity\FieldConfig;

View file

@ -1,48 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\MigrateNodeStubTest.
*/
namespace Drupal\node\Tests\Migrate;
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
use Drupal\migrate_drupal\Tests\StubTestTrait;
use Drupal\node\Entity\NodeType;
/**
* Test stub creation for nodes.
*
* @group node
*/
class MigrateNodeStubTest extends MigrateDrupalTestBase {
use StubTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
// Need at least one node type present.
NodeType::create([
'type' => 'testnodetype',
'name' => 'Test node type',
])->save();
}
/**
* Tests creation of node stubs.
*/
public function testStub() {
$this->performStubTest('node');
}
}

View file

@ -1,83 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeBuilderTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\migrate\Entity\Migration;
/**
* @group migrate_drupal_6
*/
class MigrateNodeBuilderTest extends MigrateDrupal6TestBase {
/**
* @var MigrationInterface[]
*/
protected $builtMigrations = [];
/**
* Asserts various aspects of a migration entity.
*
* @param string $id
* The migration ID.
* @param string $label
* The label.
*/
protected function assertEntity($id, $label) {
$migration = $this->builtMigrations[$id];
$this->assertTrue($migration instanceof Migration);
$this->assertIdentical($id, $migration->id());
$this->assertEqual($label, $migration->label());
}
/**
* Tests creating migrations from a template, using a builder plugin.
*/
public function testCreateMigrations() {
$templates = [
'd6_node' => [
'id' => 'd6_node',
'label' => 'Drupal 6 nodes',
'builder' => [
'plugin' => 'd6_node',
],
'source' => [
'plugin' => 'd6_node',
],
'process' => [
'nid' => 'nid',
'vid' => 'vid',
'uid' => 'uid',
],
'destination' => [
'plugin' => 'entity:node',
],
],
];
$migrations = \Drupal::service('migrate.migration_builder')->createMigrations($templates);
// Key the array.
foreach ($migrations as $migration) {
$this->builtMigrations[$migration->id()] = $migration;
}
$this->assertIdentical(11, count($this->builtMigrations));
$this->assertEntity('d6_node__article', 'Drupal 6 nodes (article)');
$this->assertEntity('d6_node__company', 'Drupal 6 nodes (company)');
$this->assertEntity('d6_node__employee', 'Drupal 6 nodes (employee)');
$this->assertEntity('d6_node__event', 'Drupal 6 nodes (event)');
$this->assertEntity('d6_node__page', 'Drupal 6 nodes (page)');
$this->assertEntity('d6_node__sponsor', 'Drupal 6 nodes (sponsor)');
$this->assertEntity('d6_node__story', 'Drupal 6 nodes (story)');
$this->assertEntity('d6_node__test_event', 'Drupal 6 nodes (test_event)');
$this->assertEntity('d6_node__test_page', 'Drupal 6 nodes (test_page)');
$this->assertEntity('d6_node__test_planet', 'Drupal 6 nodes (test_planet)');
$this->assertEntity('d6_node__test_story', 'Drupal 6 nodes (test_story)');
}
}

View file

@ -1,66 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeBundleSettingsTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\Core\Field\Entity\BaseFieldOverride;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
/**
* Test migrating node settings into the base_field_bundle_override config entity.
*
* @group migrate_drupal_6
*/
class MigrateNodeBundleSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['node']);
$this->executeMigration('d6_node_type');
// Create a config entity that already exists.
BaseFieldOverride::create([
'field_name' => 'promote',
'entity_type' => 'node',
'bundle' => 'page',
])->save();
$this->executeMigrations([
'd6_node_setting_promote',
'd6_node_setting_status',
'd6_node_setting_sticky'
]);
}
/**
* Tests Drupal 6 node type settings to Drupal 8 migration.
*/
public function testNodeBundleSettings() {
// Test settings on test_page bundle.
$node = Node::create(['type' => 'test_page']);
$this->assertIdentical(1, $node->status->value);
$this->assertIdentical(1, $node->promote->value);
$this->assertIdentical(1, $node->sticky->value);
// Test settings for test_story bundle.
$node = Node::create(['type' => 'test_story']);
$this->assertIdentical(1, $node->status->value);
$this->assertIdentical(1, $node->promote->value);
$this->assertIdentical(0, $node->sticky->value);
// Test settings for the test_event bundle.
$node = Node::create(['type' => 'test_event']);
$this->assertIdentical(0, $node->status->value);
$this->assertIdentical(0, $node->promote->value);
$this->assertIdentical(1, $node->sticky->value);
}
}

View file

@ -1,39 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeConfigsTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to node.settings.yml.
*
* @group migrate_drupal_6
*/
class MigrateNodeConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_node_settings');
}
/**
* Tests Drupal 6 node settings to Drupal 8 migration.
*/
public function testNodeSettings() {
$config = $this->config('node.settings');
$this->assertIdentical(FALSE, $config->get('use_admin_theme'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'node.settings', $config->get());
}
}

View file

@ -1,11 +1,7 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeRevisionTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeTestBase;
/**
* Node content revisions migration.
@ -19,7 +15,7 @@ class MigrateNodeRevisionTest extends MigrateNodeTestBase {
*/
protected function setUp() {
parent::setUp();
$this->executeMigrations(['d6_node:*', 'd6_node_revision:*']);
$this->executeMigrations(['d6_node', 'd6_node_revision']);
}
/**

View file

@ -1,37 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeSettingPromoteTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\Core\Field\Entity\BaseFieldOverride;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* @group migrate_drupal_6
*/
class MigrateNodeSettingPromoteTest extends MigrateDrupal6TestBase {
public static $modules = ['node', 'text'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['node']);
$this->executeMigration('d6_node_type');
$this->executeMigration('d6_node_setting_promote');
}
/**
* Tests migration of the promote checkbox's settings.
*/
public function testMigration() {
$this->assertIdentical('Promoted to front page', BaseFieldOverride::load('node.article.promote')->label());
}
}

View file

@ -1,37 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeSettingStickyTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\Core\Field\Entity\BaseFieldOverride;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* @group migrate_drupal_6
*/
class MigrateNodeSettingStickyTest extends MigrateDrupal6TestBase {
public static $modules = ['node', 'text'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['node']);
$this->executeMigration('d6_node_type');
$this->executeMigration('d6_node_setting_sticky');
}
/**
* Tests migration of the sticky checkbox's settings.
*/
public function testMigration() {
$this->assertIdentical('Sticky at the top of lists', BaseFieldOverride::load('node.article.sticky')->label());
}
}

View file

@ -1,136 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\migrate\Entity\Migration;
use Drupal\Core\Database\Database;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\node\Entity\Node;
/**
* Node content migration.
*
* @group migrate_drupal_6
*/
class MigrateNodeTest extends MigrateNodeTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigrations(['d6_node:*']);
}
/**
* Test node migration from Drupal 6 to 8.
*/
public function testNode() {
$node = Node::load(1);
$this->assertIdentical('1', $node->id(), 'Node 1 loaded.');
$this->assertIdentical('und', $node->langcode->value);
$this->assertIdentical('test', $node->body->value);
$this->assertIdentical('test', $node->body->summary);
$this->assertIdentical('filtered_html', $node->body->format);
$this->assertIdentical('story', $node->getType(), 'Node has the correct bundle.');
$this->assertIdentical('Test title', $node->getTitle(), 'Node has the correct title.');
$this->assertIdentical('1388271197', $node->getCreatedTime(), 'Node has the correct created time.');
$this->assertIdentical(FALSE, $node->isSticky());
$this->assertIdentical('1', $node->getOwnerId());
$this->assertIdentical('1420861423', $node->getRevisionCreationTime());
/** @var \Drupal\node\NodeInterface $node_revision */
$node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1);
$this->assertIdentical('Test title', $node_revision->getTitle());
$this->assertIdentical('1', $node_revision->getRevisionAuthor()->id(), 'Node revision has the correct user');
// This is empty on the first revision.
$this->assertIdentical(NULL, $node_revision->revision_log->value);
$node = Node::load(2);
$this->assertIdentical('Test title rev 3', $node->getTitle());
$this->assertIdentical('test rev 3', $node->body->value);
$this->assertIdentical('filtered_html', $node->body->format);
// Test that link fields are migrated.
$this->assertIdentical('http://groups.drupal.org/', $node->field_test_link->uri);
$this->assertIdentical('Drupal Groups', $node->field_test_link->title);
$this->assertIdentical([], $node->field_test_link->options['attributes']);
// Rerun migration with invalid link attributes and a different URL and
// title. If only the attributes are changed the error does not occur.
Database::getConnection('default', 'migrate')
->update('content_type_story')
->fields([
'field_test_link_url' => 'https://www.drupal.org/node/2127611',
'field_test_link_title' => 'Migrate API in Drupal 8',
'field_test_link_attributes' => '',
])
->condition('nid', '2')
->condition('vid', '3')
->execute();
$this->rerunMigration();
$node = Node::load(2);
$this->assertIdentical('https://www.drupal.org/node/2127611', $node->field_test_link->uri);
$this->assertIdentical('Migrate API in Drupal 8', $node->field_test_link->title);
$this->assertIdentical([], $node->field_test_link->options['attributes']);
// Test that we can re-import using the EntityContentBase destination.
$title = $this->rerunMigration();
$node = Node::load(2);
$this->assertIdentical($title, $node->getTitle());
// Test multi-column fields are correctly upgraded.
$this->assertIdentical('test rev 3', $node->body->value);
$this->assertIdentical('full_html', $node->body->format);
// Now insert a row indicating a failure and set to update later.
$title = $this->rerunMigration(array(
'sourceid1' => 2,
'destid1' => NULL,
'source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
));
$node = Node::load(2);
$this->assertIdentical($title, $node->getTitle());
}
/**
* Execute the migration a second time.
*
* @param array $new_row
* An optional row to be inserted into the id map.
*
* @return string
* The new title in the source for vid 3.
*/
protected function rerunMigration($new_row = []) {
$title = $this->randomString();
$migration = Migration::load('d6_node__story');
$source_connection = Database::getConnection('default', 'migrate');
$source_connection->update('node_revisions')
->fields(array(
'title' => $title,
'format' => 2,
))
->condition('vid', 3)
->execute();
$table_name = $migration->getIdMap()->mapTableName();
$default_connection = \Drupal::database();
$default_connection->truncate($table_name)->execute();
if ($new_row) {
$hash = $migration->getIdMap()->getSourceIDsHash(['nid' => $new_row['sourceid1']]);
$new_row['source_ids_hash'] = $hash;
$default_connection->insert($table_name)
->fields($new_row)
->execute();
}
$this->executeMigration($migration);
return $title;
}
}

View file

@ -1,43 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeTestBase.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\user\Entity\User;
/**
* Base class for Node migration tests.
*/
abstract class MigrateNodeTestBase extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig(['node']);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
// Create a new user which needs to have UID 1, because that is expected by
// the assertions from
// \Drupal\migrate_drupal\Tests\d6\MigrateNodeRevisionTest.
User::create([
'uid' => 1,
'name' => $this->randomMachineName(),
'status' => 1,
])->enforceIsNew()->save();
$this->migrateUsers(FALSE);
$this->migrateFields();
$this->executeMigration('d6_node_settings');
}
}

View file

@ -1,75 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateNodeTypeTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\field\Entity\FieldConfig;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\NodeType;
/**
* Upgrade node types to node.type.*.yml.
*
* @group migrate_drupal_6
*/
class MigrateNodeTypeTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['node']);
$this->executeMigration('d6_node_type');
}
/**
* Tests Drupal 6 node type to Drupal 8 migration.
*/
public function testNodeType() {
$id_map = Migration::load('d6_node_type')->getIdMap();
// Test the test_page content type.
$node_type_page = NodeType::load('test_page');
$this->assertIdentical('test_page', $node_type_page->id(), 'Node type test_page loaded');
$this->assertIdentical(TRUE, $node_type_page->displaySubmitted());
$this->assertIdentical(FALSE, $node_type_page->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_page->getPreviewMode());
$this->assertIdentical($id_map->lookupDestinationID(array('test_page')), array('test_page'));
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_page', 'body');
$this->assertIdentical('This is the body field label', $field->getLabel(), 'Body field was found.');
// Test the test_story content type.
$node_type_story = NodeType::load('test_story');
$this->assertIdentical('test_story', $node_type_story->id(), 'Node type test_story loaded');
$this->assertIdentical(TRUE, $node_type_story->displaySubmitted());
$this->assertIdentical(FALSE, $node_type_story->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_story->getPreviewMode());
$this->assertIdentical($id_map->lookupDestinationID(array('test_story')), array('test_story'));
// Test we don't have a body field.
$field = FieldConfig::loadByName('node', 'test_story', 'body');
$this->assertIdentical(NULL, $field, 'No body field found');
// Test the test_event content type.
$node_type_event = NodeType::load('test_event');
$this->assertIdentical('test_event', $node_type_event->id(), 'Node type test_event loaded');
$this->assertIdentical(TRUE, $node_type_event->displaySubmitted());
$this->assertIdentical(TRUE, $node_type_event->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_event->getPreviewMode());
$this->assertIdentical($id_map->lookupDestinationID(array('test_event')), array('test_event'));
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_event', 'body');
$this->assertIdentical('Body', $field->getLabel(), 'Body field was found.');
}
}

View file

@ -1,41 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d6\MigrateViewModesTest.
*/
namespace Drupal\node\Tests\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Migrate view modes.
*
* @group migrate_drupal_6
*/
class MigrateViewModesTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_view_modes');
}
/**
* Tests Drupal 6 view modes to Drupal 8 migration.
*/
public function testViewModes() {
// Test a new view mode.
$view_mode = EntityViewMode::load('node.preview');
$this->assertIdentical(FALSE, is_null($view_mode), 'Preview view mode loaded.');
$this->assertIdentical('Preview', $view_mode->label(), 'View mode has correct label.');
// Test the ID map.
$this->assertIdentical(array('node', 'preview'), Migration::load('d6_view_modes')->getIdMap()->lookupDestinationID(array(1)));
}
}

View file

@ -1,45 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d7\MigrateNodeSettingsTest.
*/
namespace Drupal\node\Tests\Migrate\d7;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Upgrade variables to node.settings config object.
*
* @group node
*/
class MigrateNodeSettingsTest extends MigrateDrupal7TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d7_node_settings');
}
/**
* Tests migration of node variables to node.settings config object.
*/
public function testAggregatorSettings() {
$config = $this->config('node.settings');
$this->assertEqual(1, $config->get('use_admin_theme'));
}
}

View file

@ -1,152 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d7\MigrateNodeTest.
*/
namespace Drupal\node\Tests\Migrate\d7;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
/**
* Tests node migration.
*
* @group node
*/
class MigrateNodeTest extends MigrateDrupal7TestBase {
static $modules = array(
'comment',
'datetime',
'filter',
'image',
'link',
'node',
'taxonomy',
'telephone',
'text',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('comment');
$this->installEntitySchema('taxonomy_term');
$this->installEntitySchema('file');
$this->installConfig(static::$modules);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
$this->executeMigrations([
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_comment_type',
'd7_field',
'd7_field_instance',
'd7_node__test_content_type',
'd7_node__article',
]);
}
/**
* Asserts various aspects of a node.
*
* @param string $id
* The node ID.
* @param string $type
* The node type.
* @param string $langcode
* The expected language code.
* @param string $title
* The expected title.
* @param int $uid
* The expected author ID.
* @param bool $status
* The expected status of the node.
* @param int $created
* The expected creation time.
* @param int $changed
* The expected modification time.
* @param bool $promoted
* Whether the node is expected to be promoted to the front page.
* @param bool $sticky
* Whether the node is expected to be sticky.
*/
protected function assertEntity($id, $type, $langcode, $title, $uid, $status, $created, $changed, $promoted, $sticky) {
/** @var \Drupal\node\NodeInterface $node */
$node = Node::load($id);
$this->assertTrue($node instanceof NodeInterface);
$this->assertIdentical($type, $node->getType());
$this->assertIdentical($langcode, $node->langcode->value);
$this->assertIdentical($title, $node->getTitle());
$this->assertIdentical($uid, $node->getOwnerId());
$this->assertIdentical($status, $node->isPublished());
$this->assertIdentical($created, $node->getCreatedTime());
if (isset($changed)) {
$this->assertIdentical($changed, $node->getChangedTime());
}
$this->assertIdentical($promoted, $node->isPromoted());
$this->assertIdentical($sticky, $node->isSticky());
}
/**
* Asserts various aspects of a node revision.
*
* @param int $id
* The revision ID.
* @param string $title
* The expected title.
* @param int $uid
* The revision author ID.
* @param string $log
* The revision log message.
* @param int $timestamp
* The revision's time stamp.
*/
protected function assertRevision($id, $title, $uid, $log, $timestamp) {
$revision = \Drupal::entityManager()->getStorage('node')->loadRevision($id);
$this->assertTrue($revision instanceof NodeInterface);
$this->assertIdentical($title, $revision->getTitle());
$this->assertIdentical($uid, $revision->getRevisionAuthor()->id());
$this->assertIdentical($log, $revision->revision_log->value);
$this->assertIdentical($timestamp, $revision->getRevisionCreationTime());
}
/**
* Test node migration from Drupal 7 to 8.
*/
public function testNode() {
$this->assertEntity(1, 'test_content_type', 'en', 'A Node', '2', TRUE, '1421727515', '1441032132', TRUE, FALSE);
$this->assertRevision(1, 'A Node', '1', NULL, '1441032132');
$node = Node::load(1);
$this->assertTrue($node->field_boolean->value);
$this->assertIdentical('99-99-99-99', $node->field_phone->value);
// Use assertEqual() here instead, since SQLite interprets floats strictly.
$this->assertEqual('1', $node->field_float->value);
$this->assertIdentical('5', $node->field_integer->value);
$this->assertIdentical('Some more text', $node->field_text_list[0]->value);
$this->assertIdentical('7', $node->field_integer_list[0]->value);
$this->assertIdentical('qwerty', $node->field_text->value);
$this->assertIdentical('2', $node->field_file->target_id);
$this->assertIdentical('file desc', $node->field_file->description);
$this->assertTrue($node->field_file->display);
$this->assertIdentical('1', $node->field_images->target_id);
$this->assertIdentical('alt text', $node->field_images->alt);
$this->assertIdentical('title text', $node->field_images->title);
$this->assertIdentical('93', $node->field_images->width);
$this->assertIdentical('93', $node->field_images->height);
$node = Node::load(2);
$this->assertIdentical("...is that it's the absolute best show ever. Trust me, I would know.", $node->body->value);
}
}

View file

@ -1,59 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d7\MigrateNodeTitleLabelTest.
*/
namespace Drupal\node\Tests\Migrate\d7;
use Drupal\Core\Field\Entity\BaseFieldOverride;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Tests migration of the title field label for node types.
*
* @group node
*/
class MigrateNodeTitleLabelTest extends MigrateDrupal7TestBase {
public static $modules = ['node', 'text'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(static::$modules);
$this->installEntitySchema('node');
$this->executeMigrations(['d7_node_type', 'd7_node_title_label']);
}
/**
* Asserts various aspects of a base_field_override entity.
*
* @param string $id
* The override ID.
* @param string $label
* The label's expected (overridden) value.
*/
protected function assertEntity($id, $label) {
$override = BaseFieldOverride::load($id);
$this->assertTrue($override instanceof BaseFieldOverride);
/** @var \Drupal\Core\Field\Entity\BaseFieldOverride $override */
$this->assertIdentical($label, $override->getLabel());
}
/**
* Tests migration of node title field overrides.
*/
public function testMigration() {
$this->assertEntity('node.article.title', 'Title');
$this->assertEntity('node.blog.title', 'Title');
$this->assertEntity('node.book.title', 'Title');
$this->assertEntity('node.forum.title', 'Subject');
$this->assertEntity('node.page.title', 'Title');
$this->assertEntity('node.test_content_type.title', 'Title');
}
}

View file

@ -1,85 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d7\MigrateNodeTypeTest.
*/
namespace Drupal\node\Tests\Migrate\d7;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\NodeType;
use Drupal\node\NodeTypeInterface;
/**
* Upgrade node types to node.type.*.yml.
*
* @group node
*/
class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'text', 'filter');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(array('node'));
$this->executeMigration('d7_node_type');
}
/**
* Tests a single node type.
*
* @dataProvider testNodeTypeDataProvider
* @param string $id
* The node type ID.
* @param string $label
* The expected label.
* @param string $description
* The expected node type description.
* @param string $help
* The expected help text.
*/
protected function assertEntity($id, $label, $description, $help, $display_submitted, $new_revision, $body_label = NULL) {
/** @var \Drupal\node\NodeTypeInterface $entity */
$entity = NodeType::load($id);
$this->assertTrue($entity instanceof NodeTypeInterface);
$this->assertIdentical($label, $entity->label());
$this->assertIdentical($description, $entity->getDescription());
$this->assertIdentical($help, $entity->getHelp());
$this->assertIdentical($display_submitted, $entity->displaySubmitted(), 'Submission info is displayed');
$this->assertIdentical($new_revision, $entity->isNewRevision(), 'Is a new revision');
if ($body_label) {
/** @var \Drupal\field\FieldConfigInterface $body */
$body = FieldConfig::load('node.' . $id . '.body');
$this->assertTrue($body instanceof FieldConfigInterface);
$this->assertIdentical($body_label, $body->label());
}
}
/**
* Tests Drupal 7 node type to Drupal 8 migration.
*/
public function testNodeType() {
$this->assertEntity('article', 'Article', 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.', 'Help text for articles', TRUE, FALSE, "Body");
$this->assertEntity('blog', 'Blog entry', 'Use for multi-user blogs. Every user gets a personal blog.', 'Blog away, good sir!', TRUE, FALSE, 'Body');
// book's display_submitted flag is not set, so it will default to TRUE.
$this->assertEntity('book', 'Book page', '<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.', '', TRUE, TRUE, "Body");
$this->assertEntity('forum', 'Forum topic', 'A <em>forum topic</em> starts a new discussion thread within a forum.', 'No name-calling, no flame wars. Be nice.', TRUE, FALSE, 'Body');
$this->assertEntity('page', 'Basic page', "Use <em>basic pages</em> for your static content, such as an 'About us' page.", 'Help text for basic pages', FALSE, FALSE, "Body");
// This node type does not carry a body field.
$this->assertEntity('test_content_type', 'Test content type', 'This is the description of the test content type.', 'Help text for test content type', FALSE, TRUE);
}
}

View file

@ -1,26 +1,20 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Migrate\d7\NodeBuilderTest.
*/
namespace Drupal\node\Tests\Migrate\d7;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests the d7_node builder.
* Tests the d7_node node deriver.
*
* @group node
*/
class NodeBuilderTest extends MigrateDrupal7TestBase {
class NodeMigrateDeriverTest extends MigrateDrupal7TestBase {
public static $modules = ['node'];
public function testBuilder() {
$process = Migration::load('d7_node__test_content_type')->getProcess();
$process = $this->getMigration('d7_node:test_content_type')->getProcess();
$this->assertIdentical('field_boolean', $process['field_boolean'][0]['source']);
$this->assertIdentical('field_email', $process['field_email'][0]['source']);
$this->assertIdentical('field_phone', $process['field_phone'][0]['source']);

View file

@ -1,12 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\MultiStepNodeFormBasicOptionsTest.
*/
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Tests the persistence of basic options through multiple steps.
@ -32,7 +29,7 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
// Create an unlimited cardinality field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text',
@ -40,12 +37,12 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
))->save();
// Attach an instance of the field to the page content type.
entity_create('field_config', array(
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => 'page',
'label' => $this->randomMachineName() . '_label',
))->save();
])->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($this->fieldName, array(
'type' => 'text_textfield',

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessAutoBubblingTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Url;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessBaseTableTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\NodeType;

View file

@ -1,12 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessFieldTest.
*/
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Tests the interaction of the node access system with fields.
@ -54,16 +51,16 @@ class NodeAccessFieldTest extends NodeTestBase {
// Add a custom field to the page content type.
$this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name');
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text'
))->save();
entity_create('field_config', array(
FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => 'page',
))->save();
])->save();
entity_get_display('node', 'page', 'default')
->setComponent($this->fieldName)
->save();

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessGrantsCacheContextTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessGrantsTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,16 +1,13 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessLanguageAwareCombinationTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Tests node access functionality with multiple languages and two node access
@ -55,7 +52,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// Create the 'private' field, which allows the node to be marked as private
// (restricted access) in a given translation.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => 'field_private',
'entity_type' => 'node',
'type' => 'boolean',
@ -63,7 +60,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
));
$field_storage->save();
entity_create('field_config', array(
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'widget' => array(
@ -73,7 +70,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
'on_label' => 'Private',
'off_label' => 'Not private',
),
))->save();
])->save();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild();

View file

@ -1,15 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessLanguageAwareTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\user\Entity\User;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Tests node_access and db_select() with node_access tag functionality with
@ -52,7 +49,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// Create the 'private' field, which allows the node to be marked as private
// (restricted access) in a given translation.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => 'field_private',
'entity_type' => 'node',
'type' => 'boolean',
@ -60,7 +57,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
));
$field_storage->save();
entity_create('field_config', array(
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'widget' => array(
@ -70,7 +67,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
'on_label' => 'Private',
'off_label' => 'Not private',
),
))->save();
])->save();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild();

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessLanguageTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessMenuLinkTest.
*/
namespace Drupal\node\Tests;
use Drupal\user\RoleInterface;

View file

@ -1,15 +1,11 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessPagerTest.
*/
namespace Drupal\node\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
/**
* Tests access controlled node views have the right amount of comment pages.
@ -45,7 +41,7 @@ class NodeAccessPagerTest extends WebTestBase {
// Create 60 comments.
for ($i = 0; $i < 60; $i++) {
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessRebuildNodeGrantsTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessRebuildTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessRecordsTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAccessTest.
*/
namespace Drupal\node\Tests;
use Drupal\user\RoleInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeAdminTest.
*/
namespace Drupal\node\Tests;
use Drupal\user\RoleInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeBlockFunctionalTest.
*/
namespace Drupal\node\Tests;
use Drupal\block\Entity\Block;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeBodyFieldStorageTest.
*/
namespace Drupal\node\Tests;
use Drupal\field\Entity\FieldConfig;
@ -29,7 +24,6 @@ class NodeBodyFieldStorageTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this->installSchema('system', 'sequences');
$this->installSchema('system', array('router'));
// Necessary for module uninstall.
$this->installSchema('user', 'users_data');
$this->installEntitySchema('user');

View file

@ -1,13 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeCacheTagsTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
/**
@ -27,13 +24,13 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
*/
protected function createEntity() {
// Create a "Camelids" node type.
entity_create('node_type', array(
NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
))->save();
])->save();
// Create a "Llama" node.
$node = entity_create('node', array('type' => 'camelids'));
$node = Node::create(['type' => 'camelids']);
$node->setTitle('Llama')
->setPublished(TRUE)
->save();

View file

@ -1,14 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeCreationTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Database\Database;
use Drupal\Core\Language\LanguageInterface;
use Drupal\node\Entity\Node;
/**
* Create a node and test saving it.
@ -90,7 +86,7 @@ class NodeCreationTest extends NodeTestBase {
try {
// An exception is generated by node_test_exception_node_insert() if the
// title is 'testing_transaction_exception'.
entity_create('node', $edit)->save();
Node::create($edit)->save();
$this->fail(t('Expected exception has not been thrown.'));
}
catch (\Exception $e) {
@ -168,7 +164,7 @@ class NodeCreationTest extends NodeTestBase {
/**
* Check node/add when no node types exist.
*/
function testNodeAddWithoutContentTypes () {
function testNodeAddWithoutContentTypes() {
$this->drupalGet('node/add');
$this->assertResponse(200);
$this->assertNoLinkByHref('/admin/structure/types/add');

View file

@ -1,13 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeEditFormTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\NodeInterface;
use Drupal\user\Entity\User;
/**
* Create a node and test node edit functionality.
@ -205,10 +201,17 @@ class NodeEditFormTest extends NodeTestBase {
// won't do.
$this->assertTrue($uid === 0 || $uid === '0', 'Node authored by anonymous user.');
// Go back to the edit form and check that the correct value is displayed
// in the author widget.
$this->drupalGet('node/' . $node->id() . '/edit');
$anonymous_user = User::getAnonymousUser();
$expected = $anonymous_user->label() . ' (' . $anonymous_user->id() . ')';
$this->assertFieldByName($form_element_name, $expected, 'Authored by field displays the correct value for the anonymous user.');
// Change the authored by field to another user's name (that is not
// logged in).
$edit[$form_element_name] = $this->webUser->getUsername();
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
$this->nodeStorage->resetCache(array($node->id()));
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($node->getOwnerId(), $this->webUser->id(), 'Node authored by normal user.');

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeEntityViewModeAlterTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Cache\Cache;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeFieldAccessTest.
*/
namespace Drupal\node\Tests;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeFieldMultilingualTest.
*/
namespace Drupal\node\Tests;
use Drupal\field\Entity\FieldStorageConfig;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeFieldOverridesTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Field\Entity\BaseFieldOverride;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeFormButtonsTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeFormSaveChangedTimeTest.
*/
namespace Drupal\node\Tests;
use Drupal\simpletest\WebTestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeHelpTest.
*/
namespace Drupal\node\Tests;
use Drupal\simpletest\WebTestBase;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeLinksTest.
*/
namespace Drupal\node\Tests;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeListBuilderTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeLoadMultipleTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeOwnerTest.
*/
namespace Drupal\node\Tests;
use Drupal\language\Entity\ConfigurableLanguage;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodePostSettingsTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeQueryAlterTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeRSSContentTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeRevisionPermissionsTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeRevisionsAllTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeRevisionsTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Url;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeRevisionsUiBypassAccessTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\NodeType;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeRevisionsUiTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Url;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeSaveTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;
@ -64,7 +59,7 @@ class NodeSaveTest extends NodeTestBase {
'nid' => $test_nid,
);
/** @var \Drupal\node\NodeInterface $node */
$node = entity_create('node', $node);
$node = Node::create($node);
$node->enforceIsNew();
$this->assertEqual($node->getOwnerId(), $this->webUser->id());
@ -89,7 +84,7 @@ class NodeSaveTest extends NodeTestBase {
'title' => $this->randomMachineName(8),
);
entity_create('node', $edit)->save();
Node::create($edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertEqual($node->getCreatedTime(), REQUEST_TIME, 'Creating a node sets default "created" timestamp.');
$this->assertEqual($node->getChangedTime(), REQUEST_TIME, 'Creating a node sets default "changed" timestamp.');
@ -118,7 +113,7 @@ class NodeSaveTest extends NodeTestBase {
'changed' => 979534800, // Drupal 1.0 release.
);
entity_create('node', $edit)->save();
Node::create($edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertEqual($node->getCreatedTime(), 280299600, 'Creating a node programmatically uses programmatically set "created" timestamp.');
$this->assertEqual($node->getChangedTime(), 979534800, 'Creating a node programmatically uses programmatically set "changed" timestamp.');
@ -144,11 +139,11 @@ class NodeSaveTest extends NodeTestBase {
*/
function testDeterminingChanges() {
// Initial creation.
$node = entity_create('node', array(
$node = Node::create([
'uid' => $this->webUser->id(),
'type' => 'article',
'title' => 'test_changes',
));
]);
$node->save();
// Update the node without applying changes.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeSyndicateBlockTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTemplateSuggestionsTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTestBase.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Session\AccountInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTitleTest.
*/
namespace Drupal\node\Tests;
use Drupal\comment\Tests\CommentTestTrait;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTitleXSSTest.
*/
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Html;

View file

@ -1,15 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTokenReplaceTest.
*/
namespace Drupal\node\Tests;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
/**
@ -34,7 +31,7 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase {
parent::setUp();
$this->installConfig(array('filter', 'node'));
$node_type = entity_create('node_type', array('type' => 'article', 'name' => 'Article'));
$node_type = NodeType::create(['type' => 'article', 'name' => 'Article']);
$node_type->save();
node_add_body_field($node_type);
}
@ -51,13 +48,13 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase {
// Create a user and a node.
$account = $this->createUser();
/* @var $node \Drupal\node\NodeInterface */
$node = entity_create('node', array(
$node = Node::create([
'type' => 'article',
'tnid' => 0,
'uid' => $account->id(),
'title' => '<blink>Blinking Text</blink>',
'body' => [['value' => 'Regular NODE body for the test.', 'summary' => 'Fancy NODE summary.', 'format' => 'plain_text']],
));
]);
$node->save();
// Generate and test tokens.
@ -110,12 +107,12 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase {
}
// Repeat for a node without a summary.
$node = entity_create('node', array(
$node = Node::create([
'type' => 'article',
'uid' => $account->id(),
'title' => '<blink>Blinking Text</blink>',
'body' => [['value' => 'A string that looks random like TR5c2I', 'format' => 'plain_text']],
));
]);
$node->save();
// Generate and test token - use full body as expected value.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTranslationUITest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Entity\EntityInterface;
@ -30,7 +25,8 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
'theme',
'route',
'timezone',
'url',
'url.path',
'url.query_args:_wrapper_format',
'user'
];

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTypeInitialLanguageTest.
*/
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;

View file

@ -1,16 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTypeTest.
*/
namespace Drupal\node\Tests;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\NodeType;
use Drupal\Core\Url;
use Drupal\node\NodeTypeInterface;
/**
* Ensures that node type functions work correctly.
@ -126,7 +120,7 @@ class NodeTypeTest extends NodeTestBase {
$this->assertRaw('Body', 'Body field was found.');
// Change the name through the API
/** @var NodeTypeInterface $node_type */
/** @var \Drupal\node\NodeTypeInterface $node_type */
$node_type = NodeType::load('page');
$node_type->set('name', 'NewBar');
$node_type->save();

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeTypeTranslationTest.
*/
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Unicode;

View file

@ -1,12 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeValidationTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
@ -30,7 +27,7 @@ class NodeValidationTest extends EntityUnitTestBase {
parent::setUp();
// Create a node type for testing.
$type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
$type = NodeType::create(['type' => 'page', 'name' => 'page']);
$type->save();
}
@ -39,7 +36,7 @@ class NodeValidationTest extends EntityUnitTestBase {
*/
public function testValidation() {
$this->createUser();
$node = entity_create('node', array('type' => 'page', 'title' => 'test', 'uid' => 1));
$node = Node::create(['type' => 'page', 'title' => 'test', 'uid' => 1]);
$violations = $node->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default node.');

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeViewLanguageTest.
*/
namespace Drupal\node\Tests;
use Drupal\language\Entity\ConfigurableLanguage;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\NodeViewTest.
*/
namespace Drupal\node\Tests;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\PagePreviewTest.
*/
namespace Drupal\node\Tests;
use Drupal\comment\Tests\CommentTestTrait;
@ -15,6 +10,8 @@ use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Tests the node entity preview functionality.
@ -48,24 +45,24 @@ class PagePreviewTest extends NodeTestBase {
$this->drupalLogin($web_user);
// Add a vocabulary so we can test different view modes.
$vocabulary = entity_create('taxonomy_vocabulary', array(
$vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => $this->randomMachineName(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'help' => '',
));
]);
$vocabulary->save();
$this->vocabulary = $vocabulary;
// Add a term to the vocabulary.
$term = entity_create('taxonomy_term', array(
$term = Term::create([
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => $this->vocabulary->id(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
]);
$term->save();
$this->term = $term;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\PageViewTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\SummaryLengthTest.
*/
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\BulkFormAccessTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\Component\Utility\SafeMarkup;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\BulkFormTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\Component\Utility\SafeMarkup;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\FilterUidRevisionTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\FrontPageTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\Core\Cache\Cache;

View file

@ -1,85 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NidArgumentTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\node\Entity\Node;
use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
/**
* Tests the nid argument handler.
*
* @group node
* @see \Drupal\node\Plugin\views\argument\Nid
*/
class NidArgumentTest extends ViewKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'field', 'text', 'node_test_config', 'user', 'node_test_views'];
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_nid_argument'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installConfig(['node', 'field']);
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
/**
* Test the nid argument.
*/
public function testNidArgument() {
$view = Views::getView('test_nid_argument');
$view->setDisplay();
$node1 = Node::create([
'type' => 'default',
'title' => $this->randomMachineName(),
]);
$node1->save();
$node2 = Node::create([
'type' => 'default',
'title' => $this->randomMachineName(),
]);
$node2->save();
$view->preview();
$this->assertEqual(count($view->result), 2, 'Found the expected number of results.');
// Set an the second node id as an argument.
$view->destroy();
$view->preview('default', [$node2->id()]);
// Verify that the title is overridden.
$this->assertEqual($view->getTitle(), $node2->getTitle());
// Verify that the argument filtering works.
$this->assertEqual(count($view->result), 1, 'Found the expected number of results.');
$this->assertEqual($node2->id(), (string) $view->style_plugin->getField(0, 'nid'), 'Found the correct nid.');
// Verify that setting a non-existing id as argument results in no nodes
// being shown.
$view->destroy();
$view->preview('default', [22]);
$this->assertEqual(count($view->result), 0, 'Found the expected number of results.');
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeContextualLinksTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\Component\Serialization\Json;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeFieldFilterTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\language\Entity\ConfigurableLanguage;

View file

@ -1,11 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeFieldTokensTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
/**
* Tests replacement of Views tokens supplied by the Node module.
@ -28,7 +25,7 @@ class NodeFieldTokensTest extends NodeTestBase {
public function testViewsTokenReplacement() {
// Create the Article content type with a standard body field.
/* @var $node_type \Drupal\node\NodeTypeInterface */
$node_type = entity_create('node_type', ['type' => 'article', 'name' => 'Article']);
$node_type = NodeType::create(['type' => 'article', 'name' => 'Article']);
$node_type->save();
node_add_body_field($node_type);
@ -38,7 +35,7 @@ class NodeFieldTokensTest extends NodeTestBase {
$summary = $this->randomMachineName(16);
/** @var $node \Drupal\node\NodeInterface */
$node = entity_create('node', [
$node = Node::create([
'type' => 'article',
'tnid' => 0,
'uid' => $account->id(),

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeIntegrationTest.
*/
namespace Drupal\node\Tests\Views;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeLanguageTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\Core\Language\LanguageInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeRevisionWizardTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Tests\Wizard\WizardTestBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeTestBase.
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Tests\ViewTestBase;

View file

@ -1,79 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeViewsFieldAccessTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User;
use Drupal\views\Tests\Handler\FieldFieldAccessTestBase;
/**
* Tests base field access in Views for the node entity.
*
* @group Node
*/
class NodeViewsFieldAccessTest extends FieldFieldAccessTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'entity_test'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installEntitySchema('node');
}
/**
* Check access for node fields.
*/
public function testNodeFields() {
$user = User::create([
'name' => 'test user',
]);
$user->save();
NodeType::create([
'type' => 'article',
'name' => 'Article',
])->save();
$node = Node::create([
'type' => 'article',
'title' => 'Test title',
'uid' => $user->id(),
'status' => 1,
'promote' => 1,
'sticky' => 0,
'created' => 123456,
]);
$node->save();
// @todo Expand the test coverage in https://www.drupal.org/node/2464635
$this->assertFieldAccess('node', 'nid', $node->id());
$this->assertFieldAccess('node', 'uuid', $node->uuid());
$this->assertFieldAccess('node', 'vid', $node->id());
$this->assertFieldAccess('node', 'type', $node->type->entity->label());
$this->assertFieldAccess('node', 'langcode', $node->language()->getName());
$this->assertFieldAccess('node', 'title', 'Test title');
$this->assertFieldAccess('node', 'uid', $user->getUsername());
// @todo Don't we want to display Published / Unpublished by default,
// see https://www.drupal.org/node/2465623
$this->assertFieldAccess('node', 'status', 'On');
$this->assertFieldAccess('node', 'promote', 'On');
$this->assertFieldAccess('node', 'sticky', 'Off');
// $this->assertFieldAccess('node', 'created', \Drupal::service('date.formatter')->format(123456));
// $this->assertFieldAccess('node', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME));
}
}

View file

@ -1,80 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\RevisionCreateTimestampTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
/**
* Ensures that the revision create time can be accessed in views.
*
* @group views
*/
class RevisionCreateTimestampTest extends ViewKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node_test_views', 'node', 'views', 'user'];
/**
* {@inheritdoc}
*/
public static $testViews = ['test_node_revision_timestamp'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->installSchema('node', 'node_access');
$this->installEntitySchema('node');
$this->installEntitySchema('user');
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
}
public function testRevisionCreateTimestampView() {
$node_type = NodeType::create([
'type' => 'article',
'label' => 'Article',
]);
$node_type->save();
$node = Node::create([
'title' => 'Test node',
'type' => 'article',
'revision_timestamp' => 1000,
]);
$node->save();
$node->setRevisionCreationTime(1200);
$node->setNewRevision(TRUE);
$node->save();
$node->setRevisionCreationTime(1400);
$node->setNewRevision(TRUE);
$node->save();
$view = Views::getView('test_node_revision_timestamp');
$this->executeView($view);
$this->assertIdenticalResultset($view, [
['vid' => 3, 'revision_timestamp' => 1400],
['vid' => 2, 'revision_timestamp' => 1200],
['vid' => 1, 'revision_timestamp' => 1000],
], ['vid' => 'vid', 'revision_timestamp' => 'revision_timestamp']);
}
}

View file

@ -1,9 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\RevisionRelationshipsTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\RowPluginTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\StatusExtraTest.
*/
namespace Drupal\node\Tests\Views;
/**