Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / migrate_plus / tests / src / Kernel / Plugin / migrate_plus / data_fetcher / HttpTest.php
diff --git a/web/modules/contrib/migrate_plus/tests/src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php b/web/modules/contrib/migrate_plus/tests/src/Kernel/Plugin/migrate_plus/data_fetcher/HttpTest.php
new file mode 100644 (file)
index 0000000..76a5c18
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\Tests\migrate_plus\Kernel\Plugin\migrate_plus\data_fetcher;
+
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http;
+
+/**
+ * Class HttpTest.
+ *
+ * @group migrate_plus
+ * @package Drupal\Tests\migrate_plus\Unit\migrate_plus\data_fetcher
+ */
+class HttpTest extends KernelTestBase {
+
+  /**
+   * Test http headers option.
+   *
+   * @dataProvider headerDataProvider
+   */
+  public function testHttpHeaders(array $definition, array $expected, array $preSeed = []) {
+    $http = new Http($definition, 'http', []);
+    $this->assertEquals($expected, $http->getRequestHeaders());
+  }
+
+  /**
+   * Provides multiple test cases for the testHttpHeaders method.
+   *
+   * @return array
+   *   The test cases
+   */
+  public function headerDataProvider() {
+    return [
+      'dummy headers specified' => [
+        'definition' => [
+          'headers' => [
+            'Accept' => 'application/json',
+            'User-Agent' => 'Internet Explorer 6',
+            'Authorization-Key' => 'secret',
+            'Arbitrary-Header' => 'foobarbaz',
+          ],
+        ],
+        'expected' => [
+          'Accept' => 'application/json',
+          'User-Agent' => 'Internet Explorer 6',
+          'Authorization-Key' => 'secret',
+          'Arbitrary-Header' => 'foobarbaz',
+        ],
+      ],
+      'no headers specified' => [
+        'definition' => [
+          'no_headers_here' => 'foo',
+        ],
+        'expected' => [],
+      ],
+    ];
+  }
+
+}