From 62c94225823ba4fc50b10717938dc672df8c3f73 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Sat, 15 Oct 2016 06:39:27 +0100
Subject: [PATCH] Issue #2807855 by phenaproxima, maijs, svendecabooter:
 Convert Block's Migrate source tests to new base class

---
 .../Plugin/migrate/source/BlockTest.php       | 127 +++++++++++++++
 .../Unit/Plugin/migrate/source/BlockTest.php  | 144 ------------------
 2 files changed, 127 insertions(+), 144 deletions(-)
 create mode 100644 core/modules/block/tests/src/Kernel/Plugin/migrate/source/BlockTest.php
 delete mode 100644 core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php

diff --git a/core/modules/block/tests/src/Kernel/Plugin/migrate/source/BlockTest.php b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/BlockTest.php
new file mode 100644
index 000000000000..d37f8c796426
--- /dev/null
+++ b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/BlockTest.php
@@ -0,0 +1,127 @@
+<?php
+
+namespace Drupal\Tests\block\Kernel\Plugin\migrate\source;
+
+use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
+
+/**
+ * Tests block source plugin.
+ *
+ * @covers \Drupal\block\Plugin\migrate\source\Block
+ * @group block
+ */
+class BlockTest extends MigrateSqlSourceTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['block', 'migrate_drupal'];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function providerSource() {
+    $tests = [];
+
+    // The source data.
+    $tests[0]['source_data']['blocks'] = [
+      [
+        'bid' => 1,
+        'module' => 'block',
+        'delta' => '1',
+        'theme' => 'garland',
+        'status' => 1,
+        'weight' => 0,
+        'region' => 'left',
+        'visibility' => 0,
+        'pages' => '',
+        'title' => 'Test Title 01',
+        'cache' => -1,
+      ],
+      [
+        'bid' => 2,
+        'module' => 'block',
+        'delta' => '2',
+        'theme' => 'garland',
+        'status' => 1,
+        'weight' => 5,
+        'region' => 'right',
+        'visibility' => 0,
+        'pages' => '<front>',
+        'title' => 'Test Title 02',
+        'cache' => -1,
+      ],
+    ];
+    $tests[0]['source_data']['blocks_roles'] = [
+      [
+        'module' => 'block',
+        'delta' => 1,
+        'rid' => 2,
+      ],
+      [
+        'module' => 'block',
+        'delta' => 2,
+        'rid' => 2,
+      ],
+      [
+        'module' => 'block',
+        'delta' => 2,
+        'rid' => 100,
+      ],
+    ];
+    $tests[0]['source_data']['role'] = [
+      [
+        'rid' => 2,
+        'name' => 'authenticated user',
+      ],
+    ];
+    $tests[0]['source_data']['system'] = [
+      [
+        'filename' => 'modules/system/system.module',
+        'name' => 'system',
+        'type' => 'module',
+        'owner' => '',
+        'status' => '1',
+        'throttle' => '0',
+        'bootstrap' => '0',
+        'schema_version' => '6055',
+        'weight' => '0',
+        'info' => 'a:0:{}',
+      ]
+    ];
+
+    // The expected results.
+    $tests[0]['expected_data'] = [
+      [
+        'bid' => 1,
+        'module' => 'block',
+        'delta' => '1',
+        'theme' => 'garland',
+        'status' => 1,
+        'weight' => 0,
+        'region' => 'left',
+        'visibility' => 0,
+        'pages' => '',
+        'title' => 'Test Title 01',
+        'cache' => -1,
+        'roles' => [2]
+      ],
+      [
+        'bid' => 2,
+        'module' => 'block',
+        'delta' => '2',
+        'theme' => 'garland',
+        'status' => 1,
+        'weight' => 5,
+        'region' => 'right',
+        'visibility' => 0,
+        'pages' => '<front>',
+        'title' => 'Test Title 02',
+        'cache' => -1,
+        'roles' => [2]
+      ],
+    ];
+    return $tests;
+  }
+
+}
diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php
deleted file mode 100644
index 4a60bd19a225..000000000000
--- a/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php
+++ /dev/null
@@ -1,144 +0,0 @@
-<?php
-
-namespace Drupal\Tests\block\Unit\Plugin\migrate\source;
-
-use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
-
-/**
- * Tests block source plugin.
- *
- * @coversDefaultClass \Drupal\block\Plugin\migrate\source\Block
- * @group block
- */
-class BlockTest extends MigrateSqlSourceTestCase {
-
-  const PLUGIN_CLASS = 'Drupal\block\Plugin\migrate\source\Block';
-
-  protected $migrationConfiguration = array(
-    'id' => 'test',
-    'source' => array(
-      'plugin' => 'block',
-    ),
-  );
-
-  /**
-   * Sample block instance query results from the source.
-   */
-  protected $expectedResults = array(
-    array(
-      'bid' => 1,
-      'module' => 'block',
-      'delta' => '1',
-      'theme' => 'garland',
-      'status' => 1,
-      'weight' => 0,
-      'region' => 'left',
-      'visibility' => 0,
-      'pages' => '',
-      'title' => 'Test Title 01',
-      'cache' => -1,
-      'roles' => [2]
-    ),
-    array(
-      'bid' => 2,
-      'module' => 'block',
-      'delta' => '2',
-      'theme' => 'garland',
-      'status' => 1,
-      'weight' => 5,
-      'region' => 'right',
-      'visibility' => 0,
-      'pages' => '<front>',
-      'title' => 'Test Title 02',
-      'cache' => -1,
-      'roles' => [2]
-    ),
-  );
-  /**
-   * Sample block table.
-   */
-  protected $expectedBlocks = array(
-    array(
-      'bid' => 1,
-      'module' => 'block',
-      'delta' => '1',
-      'theme' => 'garland',
-      'status' => 1,
-      'weight' => 0,
-      'region' => 'left',
-      'visibility' => 0,
-      'pages' => '',
-      'title' => 'Test Title 01',
-      'cache' => -1,
-    ),
-    array(
-      'bid' => 2,
-      'module' => 'block',
-      'delta' => '2',
-      'theme' => 'garland',
-      'status' => 1,
-      'weight' => 5,
-      'region' => 'right',
-      'visibility' => 0,
-      'pages' => '<front>',
-      'title' => 'Test Title 02',
-      'cache' => -1,
-    ),
-  );
-
-  /**
-   * Sample block roles table.
-   */
-  protected $expectedBlocksRoles = array(
-    array(
-      'module' => 'block',
-      'delta' => 1,
-      'rid' => 2,
-    ),
-    array(
-      'module' => 'block',
-      'delta' => 2,
-      'rid' => 2,
-    ),
-    array(
-      'module' => 'block',
-      'delta' => 2,
-      'rid' => 100,
-    ),
-  );
-
-  /**
-   * Sample role table.
-   */
-  protected $expectedRole = array(
-    array(
-      'rid' => 2,
-      'name' => 'authenticated user',
-    ),
-  );
-
-  /**
-   * Prepopulate database contents.
-   */
-  protected function setUp() {
-    $this->databaseContents['blocks'] = $this->expectedBlocks;
-    $this->databaseContents['blocks_roles'] = $this->expectedBlocksRoles;
-    $this->databaseContents['role'] = $this->expectedRole;
-    $this->databaseContents['system'] = array(
-      array(
-        'filename' => 'modules/system/system.module',
-        'name' => 'system',
-        'type' => 'module',
-        'owner' => '',
-        'status' => '1',
-        'throttle' => '0',
-        'bootstrap' => '0',
-        'schema_version' => '6055',
-        'weight' => '0',
-        'info' => 'a:0:{}',
-      )
-    );
-    parent::setUp();
-  }
-
-}
-- 
GitLab