MigratePrivateFileTest.php 1.37 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

namespace Drupal\Tests\file\Kernel\Migrate\d7;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;

/**
 * Tests private files migration.
 *
 * @group file
 */
class MigratePrivateFileTest extends MigrateDrupal7TestBase {

15
16
  use FileMigrationSetupTrait;

17
18
19
  /**
   * {@inheritdoc}
   */
20
  protected static $modules = ['file'];
21
22
23
24

  /**
   * {@inheritdoc}
   */
25
  protected function setUp(): void {
26
    parent::setUp();
27
    $this->setSetting('file_private_path', $this->container->getParameter('site.path') . '/private');
28
29
    $this->fileMigrationSetup();
  }
30

31
32
33
34
35
36
37
38
39
40
  /**
   * {@inheritdoc}
   */
  protected function getFileMigrationInfo() {
    return [
      'path' => 'private://sites/default/private/Babylon5.txt',
      'size' => '3',
      'base_path' => 'private://',
      'plugin_id' => 'd7_file_private',
    ];
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  }

  /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container) {
    parent::register($container);
    $container->register('stream_wrapper.private', 'Drupal\Core\StreamWrapper\PrivateStream')
      ->addTag('stream_wrapper', ['scheme' => 'private']);
  }

  /**
   * Tests that all expected files are migrated.
   */
  public function testFileMigration() {
    $this->assertEntity(3, 'Babylon5.txt', 'private://Babylon5.txt', 'text/plain', '3', '1486104045', '1486104045', '1');
  }

}