Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -45,6 +45,10 @@ class CommentLockTest extends UnitTestCase {
|
|||
$lock->expects($this->exactly(2))
|
||||
->method($this->anything());
|
||||
$container->set('lock', $lock);
|
||||
|
||||
$cache_tag_invalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidator');
|
||||
$container->set('cache_tags.invalidator', $cache_tag_invalidator);
|
||||
|
||||
\Drupal::setContainer($container);
|
||||
$methods = get_class_methods('Drupal\comment\Entity\Comment');
|
||||
unset($methods[array_search('preSave', $methods)]);
|
||||
|
@ -70,6 +74,14 @@ class CommentLockTest extends UnitTestCase {
|
|||
->method('getThread')
|
||||
->will($this->returnValue(''));
|
||||
|
||||
$parent_entity = $this->getMock('\Drupal\Core\Entity\ContentEntityInterface');
|
||||
$parent_entity->expects($this->atLeastOnce())
|
||||
->method('getCacheTagsToInvalidate')
|
||||
->willReturn(['node:1']);
|
||||
$comment->expects($this->once())
|
||||
->method('getCommentedEntity')
|
||||
->willReturn($parent_entity);
|
||||
|
||||
$entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$comment->expects($this->any())
|
||||
->method('getEntityType')
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\comment\Unit\Migrate\d6\CommentSourceWithHighWaterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\comment\Unit\Migrate\d6;
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 comment source w/ high water handling.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentSourceWithHighWaterTest extends CommentTestBase {
|
||||
|
||||
const ORIGINAL_HIGH_WATER = 1382255613;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['highWaterProperty']['field'] = 'timestamp';
|
||||
array_shift($this->expectedResults);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\comment\Unit\Migrate\d6\CommentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\comment\Unit\Migrate\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 comment source plugin.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentTest extends CommentTestBase {
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\comment\Unit\Migrate\d6\CommentTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\comment\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for comment source unit tests.
|
||||
*/
|
||||
abstract class CommentTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d6\Comment';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_comment',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'cid' => 1,
|
||||
'pid' => 0,
|
||||
'nid' => 2,
|
||||
'uid' => 3,
|
||||
'subject' => 'subject value 1',
|
||||
'comment' => 'comment value 1',
|
||||
'hostname' => 'hostname value 1',
|
||||
'timestamp' => 1382255613,
|
||||
'status' => 1,
|
||||
'thread' => '',
|
||||
'name' => '',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'format' => 'testformat1',
|
||||
'type' => 'story',
|
||||
),
|
||||
array(
|
||||
'cid' => 2,
|
||||
'pid' => 1,
|
||||
'nid' => 3,
|
||||
'uid' => 4,
|
||||
'subject' => 'subject value 2',
|
||||
'comment' => 'comment value 2',
|
||||
'hostname' => 'hostname value 2',
|
||||
'timestamp' => 1382255662,
|
||||
'status' => 1,
|
||||
'thread' => '',
|
||||
'name' => '',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'format' => 'testformat2',
|
||||
'type' => 'page',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['comments'][$k] = $row;
|
||||
$this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status'];
|
||||
}
|
||||
// Add node table data.
|
||||
$this->databaseContents['node'][] = array('nid' => 2, 'type' => 'story');
|
||||
$this->databaseContents['node'][] = array('nid' => 3, 'type' => 'page');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
105
core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php
Normal file
105
core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\comment\Unit\Migrate\d7\CommentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\comment\Unit\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 comment source plugin.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\Comment';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_comment',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'cid' => '1',
|
||||
'pid' => '0',
|
||||
'nid' => '1',
|
||||
'uid' => '1',
|
||||
'subject' => 'A comment',
|
||||
'hostname' => '::1',
|
||||
'created' => '1421727536',
|
||||
'changed' => '1421727536',
|
||||
'status' => '1',
|
||||
'thread' => '01/',
|
||||
'name' => 'admin',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'language' => 'und',
|
||||
'comment_body' => array(
|
||||
array(
|
||||
'value' => 'This is a comment',
|
||||
'format' => 'filtered_html',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['comment'] = $this->expectedResults;
|
||||
unset($this->databaseContents['comment'][0]['comment_body']);
|
||||
|
||||
$this->databaseContents['node'] = array(
|
||||
array(
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'type' => 'test_content_type',
|
||||
'language' => 'en',
|
||||
'title' => 'A Node',
|
||||
'uid' => '1',
|
||||
'status' => '1',
|
||||
'created' => '1421727515',
|
||||
'changed' => '1421727515',
|
||||
'comment' => '2',
|
||||
'promote' => '1',
|
||||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
'id' => '14',
|
||||
'field_id' => '1',
|
||||
'field_name' => 'comment_body',
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_data_comment_body'] = array(
|
||||
array(
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'und',
|
||||
'delta' => '0',
|
||||
'comment_body_value' => 'This is a comment',
|
||||
'comment_body_format' => 'filtered_html',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\comment\Unit\Migrate\d7\CommentTypeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\comment\Unit\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 comment type source plugin.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\CommentType';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_comment_type',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'bundle' => 'comment_node_article',
|
||||
'node_type' => 'article',
|
||||
'default_mode' => '1',
|
||||
'per_page' => '50',
|
||||
'anonymous' => '0',
|
||||
'form_location' => '1',
|
||||
'preview' => '0',
|
||||
'subject' => '1',
|
||||
'label' => 'Article comment',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = array(
|
||||
array(
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
'base' => 'node_content',
|
||||
'module' => 'node',
|
||||
'description' => 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.',
|
||||
'help' => 'Help text for articles',
|
||||
'has_title' => '1',
|
||||
'title_label' => 'Title',
|
||||
'custom' => '1',
|
||||
'modified' => '1',
|
||||
'locked' => '0',
|
||||
'disabled' => '0',
|
||||
'orig_type' => 'article',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
'id' => '14',
|
||||
'field_id' => '1',
|
||||
'field_name' => 'comment_body',
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_article',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
'name' => 'comment_default_mode_article',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
'name' => 'comment_per_page_article',
|
||||
'value' => serialize(50),
|
||||
),
|
||||
array(
|
||||
'name' => 'comment_anonymous_article',
|
||||
'value' => serialize(0),
|
||||
),
|
||||
array(
|
||||
'name' => 'comment_form_location_article',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
array(
|
||||
'name' => 'comment_preview_article',
|
||||
'value' => serialize(0),
|
||||
),
|
||||
array(
|
||||
'name' => 'comment_subject_article',
|
||||
'value' => serialize(1),
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue