Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / tests / src / Kernel / Migrate / d7 / MigrateFileTest.php
1 <?php
2
3 namespace Drupal\Tests\file\Kernel\Migrate\d7;
4
5 use Drupal\file\Entity\File;
6 use Drupal\file\FileInterface;
7 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
8
9 /**
10  * Migrates all files in the file_managed table.
11  *
12  * @group file
13  */
14 class MigrateFileTest extends MigrateDrupal7TestBase {
15
16   use FileMigrationSetupTrait;
17
18   public static $modules = ['file'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25
26     $this->fileMigrationSetup();
27   }
28
29   /**
30    * Tests a single file entity.
31    *
32    * @param int $id
33    *   The file ID.
34    * @param string $name
35    *   The expected file name.
36    * @param string $uri
37    *   The expected URI.
38    * @param string $mime
39    *   The expected MIME type.
40    * @param int $size
41    *   The expected file size.
42    * @param int $created
43    *   The expected creation time.
44    * @param int $changed
45    *   The expected modification time.
46    * @param int $uid
47    *   The expected owner ID.
48    */
49   protected function assertEntity($id, $name, $uri, $mime, $size, $created, $changed, $uid) {
50     /** @var \Drupal\file\FileInterface $file */
51     $file = File::load($id);
52     $this->assertTrue($file instanceof FileInterface);
53     $this->assertIdentical($name, $file->getFilename());
54     $this->assertIdentical($uri, $file->getFileUri());
55     $this->assertTrue(file_exists($uri));
56     $this->assertIdentical($mime, $file->getMimeType());
57     $this->assertIdentical($size, $file->getSize());
58     // isPermanent(), isTemporary(), etc. are determined by the status column.
59     $this->assertTrue($file->isPermanent());
60     $this->assertIdentical($created, $file->getCreatedTime());
61     $this->assertIdentical($changed, $file->getChangedTime());
62     $this->assertIdentical($uid, $file->getOwnerId());
63   }
64
65   /**
66    * Tests that all expected files are migrated.
67    */
68   public function testFileMigration() {
69     $this->assertEntity(1, 'cube.jpeg', 'public://cube.jpeg', 'image/jpeg', '3620', '1421727515', '1421727515', '1');
70   }
71
72 }