Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / file / tests / src / Kernel / Migrate / d7 / MigrateFileTest.php
index 88d7c79e554288505d38e3ceb35469c452fbb56a..ea32df5e3483eeeb1ad5e074be17252bc53cfc75 100644 (file)
@@ -3,7 +3,6 @@
 namespace Drupal\Tests\file\Kernel\Migrate\d7;
 
 use Drupal\file\Entity\File;
-use Drupal\file\FileInterface;
 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
 
 /**
@@ -15,6 +14,9 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
 
   use FileMigrationSetupTrait;
 
+  /**
+   * {@inheritdoc}
+   */
   public static $modules = ['file'];
 
   /**
@@ -22,44 +24,19 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
    */
   protected function setUp() {
     parent::setUp();
-
     $this->fileMigrationSetup();
   }
 
   /**
-   * Tests a single file entity.
-   *
-   * @param int $id
-   *   The file ID.
-   * @param string $name
-   *   The expected file name.
-   * @param string $uri
-   *   The expected URI.
-   * @param string $mime
-   *   The expected MIME type.
-   * @param int $size
-   *   The expected file size.
-   * @param int $created
-   *   The expected creation time.
-   * @param int $changed
-   *   The expected modification time.
-   * @param int $uid
-   *   The expected owner ID.
+   * {@inheritdoc}
    */
-  protected function assertEntity($id, $name, $uri, $mime, $size, $created, $changed, $uid) {
-    /** @var \Drupal\file\FileInterface $file */
-    $file = File::load($id);
-    $this->assertTrue($file instanceof FileInterface);
-    $this->assertIdentical($name, $file->getFilename());
-    $this->assertIdentical($uri, $file->getFileUri());
-    $this->assertTrue(file_exists($uri));
-    $this->assertIdentical($mime, $file->getMimeType());
-    $this->assertIdentical($size, $file->getSize());
-    // isPermanent(), isTemporary(), etc. are determined by the status column.
-    $this->assertTrue($file->isPermanent());
-    $this->assertIdentical($created, $file->getCreatedTime());
-    $this->assertIdentical($changed, $file->getChangedTime());
-    $this->assertIdentical($uid, $file->getOwnerId());
+  protected function getFileMigrationInfo() {
+    return [
+      'path' => 'public://sites/default/files/cube.jpeg',
+      'size' => '3620',
+      'base_path' => 'public://',
+      'plugin_id' => 'd7_file',
+    ];
   }
 
   /**
@@ -67,6 +44,8 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
    */
   public function testFileMigration() {
     $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', '3620', '1421727515', '1421727515', '1');
+    // Ensure temporary file was not migrated.
+    $this->assertNull(File::load(4));
   }
 
 }