Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / migrate / tests / src / Kernel / MigrateStatusTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate\Kernel;
4
5 use Drupal\migrate\Plugin\MigrationInterface;
6
7 /**
8  * Tests migration status tracking.
9  *
10  * @group migrate
11  */
12 class MigrateStatusTest extends MigrateTestBase {
13
14   /**
15    * Tests different connection types.
16    */
17   public function testStatus() {
18     // Create a minimally valid migration.
19     $definition = [
20       'id' => 'migration_status_test',
21       'migration_tags' => ['Testing'],
22       'source' => ['plugin' => 'empty'],
23       'destination' => [
24         'plugin' => 'config',
25         'config_name' => 'migrate_test.settings',
26       ],
27       'process' => ['foo' => 'bar'],
28     ];
29     $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
30
31     // Default status is idle.
32     $status = $migration->getStatus();
33     $this->assertIdentical($status, MigrationInterface::STATUS_IDLE);
34
35     // Test setting and retrieving all known status values.
36     $status_list = [
37       MigrationInterface::STATUS_IDLE,
38       MigrationInterface::STATUS_IMPORTING,
39       MigrationInterface::STATUS_ROLLING_BACK,
40       MigrationInterface::STATUS_STOPPING,
41       MigrationInterface::STATUS_DISABLED,
42     ];
43     foreach ($status_list as $status) {
44       $migration->setStatus($status);
45       $this->assertIdentical($migration->getStatus(), $status);
46     }
47   }
48
49 }