annotate core/modules/migrate/tests/src/Kernel/NodeCommentCombinationTrait.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author |
Chris Cannam |
date |
Thu, 09 May 2019 15:33:08 +0100 |
parents |
4c8ae668cc8c |
children |
|
rev |
line source |
Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\migrate\Kernel;
|
Chris@0
|
4
|
Chris@18
|
5 /**
|
Chris@18
|
6 * @deprecated in Drupal 8.7.x, will be removed before Drupal 9.0.0. Use
|
Chris@18
|
7 * \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase::migrateFields()
|
Chris@18
|
8 * instead.
|
Chris@18
|
9 */
|
Chris@18
|
10
|
Chris@0
|
11 use Drupal\comment\Entity\CommentType;
|
Chris@0
|
12 use Drupal\node\Entity\NodeType;
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * Provides methods for testing node and comment combinations.
|
Chris@0
|
16 */
|
Chris@0
|
17 trait NodeCommentCombinationTrait {
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Creates a node type with a corresponding comment type.
|
Chris@0
|
21 *
|
Chris@0
|
22 * @param string $node_type
|
Chris@0
|
23 * The node type ID.
|
Chris@0
|
24 * @param string $comment_type
|
Chris@0
|
25 * (optional) The comment type ID, if not provided defaults to
|
Chris@0
|
26 * comment_node_{type}.
|
Chris@0
|
27 */
|
Chris@0
|
28 protected function createNodeCommentCombination($node_type, $comment_type = NULL) {
|
Chris@18
|
29 @trigger_error('NodeCommentCombinationTrait::createNodeCommentCombination() is deprecated in Drupal 8.7.x, will be removed before Drupal 9.0.0. Use \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase::migrateFields() instead.', E_USER_DEPRECATED);
|
Chris@18
|
30
|
Chris@0
|
31 if (!$comment_type) {
|
Chris@0
|
32 $comment_type = "comment_node_$node_type";
|
Chris@0
|
33 }
|
Chris@0
|
34 NodeType::create([
|
Chris@0
|
35 'type' => $node_type,
|
Chris@0
|
36 'label' => $this->randomString(),
|
Chris@0
|
37 ])->save();
|
Chris@0
|
38
|
Chris@0
|
39 CommentType::create([
|
Chris@0
|
40 'id' => $comment_type,
|
Chris@0
|
41 'label' => $this->randomString(),
|
Chris@0
|
42 'target_entity_type_id' => 'node',
|
Chris@0
|
43 ])->save();
|
Chris@0
|
44 }
|
Chris@0
|
45
|
Chris@0
|
46 }
|