You are here

FileBlobTest.php in Migrate Plus 8.4

Same filename and directory in other branches
  1. 8.5 tests/src/Kernel/Plugin/migrate/process/FileBlobTest.php

File

tests/src/Kernel/Plugin/migrate/process/FileBlobTest.php
View source
<?php

namespace Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process;

use Drupal\Core\File\FileSystemInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\user\Traits\UserCreationTrait;

/**
 * Tests the file_blob plugin.
 *
 * @coversDefaultClass \Drupal\migrate_plus\Plugin\migrate\process\FileBlob
 * @group migrate_plus
 */
class FileBlobTest extends KernelTestBase {
  use UserCreationTrait;

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'migrate',
    'migrate_plus',
    'system',
  ];

  /**
   * The process plugin manager.
   *
   * @var \Drupal\migrate\Plugin\MigratePluginManagerInterface
   */
  protected $pluginManager;

  /**
   * The blob representation of a cat image.
   *
   * @var string
   */
  protected $blob;

  /**
   * The sha1sum of the blob.
   *
   * @var string
   */
  protected $sha1sum;

  /**
   * The filesystem interface.
   *
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $filesystem;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->pluginManager = $this->container
      ->get('plugin.manager.migrate.process');
    $this->filesystem = $this->container
      ->get('file_system');
    $this->sha1sum = 'a8eb2b9a987cfda507356d884f0498289bd0f620';
    $this->blob = <<<EOT
/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcg
SlBFRyB2NjIpLCBxdWFsaXR5ID0gNjUK/9sAQwALCAgKCAcLCgkKDQwLDREcEhEPDxEiGRoUHCkk
KyooJCcnLTJANy0wPTAnJzhMOT1DRUhJSCs2T1VORlRAR0hF/9sAQwEMDQ0RDxEhEhIhRS4nLkVF
RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVF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VZt49sdVIYy75PSr24IuKF3ArSPtkxmrCEbM1Sk+aXNSSTBI8UIBs0wV6VT5gzWdJJ5k
vWr8K4SpTuBaTAXioZB81Kj84pzjvVMCP+GmgmnjnigrikAeXkVA67Wq0rcYqF13PRYBuNy0VOI8
LRRYDirCLbLtxxWnNbkICo5qS3tlVskVPcLheCMVCjoO+pHp8DM2XXGKuTKQwxTdNJVTuORVwojv
watR0FfUW1Qqd1SXLZXipSoSPioFIc1TXQRLb8RVXlyZcCpy2wYqNcFs0MESKQgzUM8oYU+RuKp4
Lvik30GT29LKxzgVJHGEWmlNzZosBNbphc1HM2Gp4kCjFVpSXbjpQwHds1RuJTnFXQQFxWfOu6Ti
k0AkS/Pk1qRsPLqlHFhcmpo2ycUJWAkXO+rJGUqIJjmn7vlxVCGLwae3So+hqQHNIZCzbadF8xps
g5p8QxQgLIA20Um8AUVQjKeDapqj5hMojrUmPyVlooN4D71EhoveV5SjbxmnQM3mcmi6YhRSW3Iy
afURoSSDy8VFbLlzUUh+WpLPjmq6h0JbgbRmoEYnkVYuv9XUFsPkND3Aaz80sQBfNQyH5zU0HrUo
B8r7TUsWGXNVputWLc/JTQEE7bTSxruXNMuhlqWIkLR1AguHCGq0bh5Kde1Bb9anqM0mYeXxUMDZ
kprsdtFt96qYkaZHy0wdaUE7aYDzQA9uKZvxT3+7Vcnmkxjt25qlHAqJRUjH5aADfzRUGfmooA//
2Q==
EOT;
  }

  /**
   * Tests file creation.
   *
   * @covers ::transform
   */
  public function testFileCreation() {

    /** @var \Drupal\migrate\MigrateExecutableInterface $executable */
    $executable = $this
      ->prophesize(MigrateExecutableInterface::class)
      ->reveal();
    $row = new Row([], []);
    $value = [
      'public://cat.jpeg',
      base64_decode($this->blob, TRUE),
    ];

    /** @var \Drupal\migrate_plus\Plugin\migrate\process\FileBlob $file_blob */
    $file_blob = $this->pluginManager
      ->createInstance('file_blob');
    $file = $file_blob
      ->transform($value, $executable, $row, 'destination_property');
    $this
      ->assertEquals('public://cat.jpeg', $file);
    $this
      ->assertEquals($this->sha1sum, sha1_file($file));

    // TODO: remove after 8.6 is no longer supported in
    // https://www.drupal.org/project/migrate_plus/issues/3035587
    if (version_compare(\Drupal::VERSION, '8.7', '>=')) {
      $configuration = [
        'reuse' => FileSystemInterface::EXISTS_ERROR,
      ];
    }
    else {
      $configuration = [
        'reuse' => FILE_EXISTS_ERROR,
      ];
    }

    /** @var \Drupal\migrate_plus\Plugin\migrate\process\FileBlob $file_blob */
    $file_blob = $this->pluginManager
      ->createInstance('file_blob', $configuration);

    /** @var \Drupal\migrate\MigrateExecutableInterface $executable */
    $file = $file_blob
      ->transform($value, $executable, $row, 'destination_property');
    $this
      ->assertEquals('public://cat.jpeg', $file);
    $this
      ->assertEquals($this->sha1sum, sha1_file($file));
  }

}

Classes

Namesort descending Description
FileBlobTest Tests the file_blob plugin.