Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Entity / Sql / SqlContentEntityStorageSchemaTest.php
index d16ece2097dd72e784fcf054f645e7eb53f97c10..cf18e2bb9c5ef5afc82f230d6bd4b445b44ca239 100644 (file)
@@ -51,7 +51,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
   /**
    * The storage schema handler used in this test.
    *
-   * @var \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema|\PHPUnit_Framework_MockObject_MockObject.
+   * @var \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema|\PHPUnit_Framework_MockObject_MockObject
    */
   protected $storageSchema;
 
@@ -155,7 +155,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
         ],
         'domain' => [
           'type' => 'varchar',
-        ]
+        ],
       ],
       'unique keys' => [
         'email' => ['username', 'hostname', ['domain', 3]],
@@ -194,7 +194,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
         ],
         'city' => [
           'type' => 'varchar',
-        ]
+        ],
       ],
       'indexes' => [
         'country_state_city' => ['country', 'state', ['city', 10]],
@@ -370,6 +370,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
     $this->storage->expects($this->any())
       ->method('getTableMapping')
       ->will($this->returnValue($table_mapping));
+    $this->storage->expects($this->any())
+      ->method('getCustomTableMapping')
+      ->will($this->returnValue($table_mapping));
 
     $this->assertNull(
       $this->storageSchema->onEntityTypeCreate($this->entityType)
@@ -389,13 +392,22 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
    * @covers ::processIdentifierSchema
    */
   public function testGetSchemaRevisionable() {
-    $this->entityType = new ContentEntityType([
-      'id' => 'entity_test',
-      'entity_keys' => [
-        'id' => 'id',
-        'revision' => 'revision_id',
-      ],
-    ]);
+    $this->entityType = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityType')
+      ->setConstructorArgs([
+        [
+          'id' => 'entity_test',
+          'entity_keys' => [
+            'id' => 'id',
+            'revision' => 'revision_id',
+          ],
+        ],
+      ])
+      ->setMethods(['getRevisionMetadataKeys'])
+      ->getMock();
+
+    $this->entityType->expects($this->any())
+      ->method('getRevisionMetadataKeys')
+      ->will($this->returnValue([]));
 
     $this->storage->expects($this->exactly(2))
       ->method('getRevisionTable')
@@ -420,7 +432,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
           'revision_id' => [
             'type' => 'int',
             'not null' => FALSE,
-          ]
+          ],
         ],
         'primary key' => ['id'],
         'unique keys' => [
@@ -431,7 +443,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
           'entity_test__revision' => [
             'table' => 'entity_test_revision',
             'columns' => ['revision_id' => 'revision_id'],
-          ]
+          ],
         ],
       ],
       'entity_test_revision' => [
@@ -469,6 +481,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
     $this->storage->expects($this->any())
       ->method('getTableMapping')
       ->will($this->returnValue($table_mapping));
+    $this->storage->expects($this->any())
+      ->method('getCustomTableMapping')
+      ->will($this->returnValue($table_mapping));
 
     $this->storageSchema->onEntityTypeCreate($this->entityType);
   }
@@ -524,7 +539,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
           'langcode' => [
             'type' => 'varchar',
             'not null' => TRUE,
-          ]
+          ],
         ],
         'primary key' => ['id'],
         'unique keys' => [],
@@ -577,6 +592,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
     $this->storage->expects($this->any())
       ->method('getTableMapping')
       ->will($this->returnValue($table_mapping));
+    $this->storage->expects($this->any())
+      ->method('getCustomTableMapping')
+      ->will($this->returnValue($table_mapping));
 
     $this->assertNull(
       $this->storageSchema->onEntityTypeCreate($this->entityType)
@@ -595,14 +613,23 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
    * @covers ::processRevisionDataTable
    */
   public function testGetSchemaRevisionableTranslatable() {
-    $this->entityType = new ContentEntityType([
-      'id' => 'entity_test',
-      'entity_keys' => [
-        'id' => 'id',
-        'revision' => 'revision_id',
-        'langcode' => 'langcode',
-      ],
-    ]);
+    $this->entityType = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityType')
+      ->setConstructorArgs([
+        [
+          'id' => 'entity_test',
+          'entity_keys' => [
+            'id' => 'id',
+            'revision' => 'revision_id',
+            'langcode' => 'langcode',
+          ],
+        ],
+      ])
+      ->setMethods(['getRevisionMetadataKeys'])
+      ->getMock();
+
+    $this->entityType->expects($this->any())
+      ->method('getRevisionMetadataKeys')
+      ->will($this->returnValue([]));
 
     $this->storage->expects($this->exactly(3))
       ->method('getRevisionTable')
@@ -652,7 +679,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
           'langcode' => [
             'type' => 'varchar',
             'not null' => TRUE,
-          ]
+          ],
         ],
         'primary key' => ['id'],
         'unique keys' => [
@@ -788,6 +815,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
     $this->storage->expects($this->any())
       ->method('getTableMapping')
       ->will($this->returnValue($table_mapping));
+    $this->storage->expects($this->any())
+      ->method('getCustomTableMapping')
+      ->will($this->returnValue($table_mapping));
 
     $this->storageSchema->onEntityTypeCreate($this->entityType);
   }
@@ -835,7 +865,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
         'color' => [
           'table' => 'color',
           'columns' => [
-            'color' => 'id'
+            'color' => 'id',
           ],
         ],
       ],
@@ -1002,7 +1032,7 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
         'color' => [
           'table' => 'color',
           'columns' => [
-            'color' => 'id'
+            'color' => 'id',
           ],
         ],
       ],
@@ -1285,6 +1315,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
     $this->storage->expects($this->any())
       ->method('getTableMapping')
       ->will($this->returnValue($table_mapping));
+    $this->storage->expects($this->any())
+      ->method('getCustomTableMapping')
+      ->will($this->returnValue($table_mapping));
 
     // Setup storage schema.
     if ($change_schema) {
@@ -1469,6 +1502,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
     $this->storage->expects($this->any())
       ->method('getTableMapping')
       ->will($this->returnValue($table_mapping));
+    $this->storage->expects($this->any())
+      ->method('getCustomTableMapping')
+      ->will($this->returnValue($table_mapping));
 
     $this->storageSchema->expects($this->any())
       ->method('loadEntitySchemaData')