a2dd7c6e8e8b9d1de11a9e491235ae51a36398ce
[yaffs-website] / web / core / modules / migrate / tests / src / Unit / Plugin / migrate / destination / EntityTestBase.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityTestBase
6  */
7
8 namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination;
9
10 use Drupal\Core\Entity\EntityManagerInterface;
11 use Drupal\Core\Entity\EntityStorageInterface;
12 use Drupal\Core\Entity\EntityTypeInterface;
13 use Drupal\Core\Field\BaseFieldDefinition;
14 use Drupal\migrate\Plugin\MigrationInterface;
15 use Drupal\Tests\UnitTestCase;
16
17 /**
18  * Base test class forentity migration destination functionality.
19  */
20 class EntityTestBase extends UnitTestCase {
21
22   /**
23    * @var \Drupal\migrate\Plugin\MigrationInterface
24    */
25   protected $migration;
26
27   /**
28    * @var \Drupal\Core\Entity\EntityStorageInterface
29    */
30   protected $storage;
31
32   /**
33    * @var \Drupal\Core\Entity\EntityTypeInterface
34    */
35   protected $entityType;
36
37   /**
38    * @var \Drupal\Core\Entity\EntityManagerInterface
39    */
40   protected $entityManager;
41
42   /**
43    * {@inheritdoc}
44    */
45   protected function setUp() {
46     parent::setUp();
47
48     $this->migration = $this->prophesize(MigrationInterface::class);
49     $this->storage = $this->prophesize(EntityStorageInterface::class);
50
51     $this->entityType = $this->prophesize(EntityTypeInterface::class);
52     $this->entityType->getPluralLabel()->willReturn('wonkiness');
53     $this->storage->getEntityType()->willReturn($this->entityType->reveal());
54     $this->storage->getEntityTypeId()->willReturn('foo');
55
56     $this->entityManager = $this->prophesize(EntityManagerInterface::class);
57   }
58
59 }
60
61 /**
62  * Stub class for BaseFieldDefinition.
63  */
64 class BaseFieldDefinitionTest extends BaseFieldDefinition {
65
66   public static function create($type) {
67     return new static([]);
68   }
69
70   public function getSettings() {
71     return [];
72   }
73
74   public function getType() {
75     return 'integer';
76   }
77
78 }