76a5c1847469f889ec1b175e2ff0827ba69107f5
[yaffs-website] / web / modules / contrib / migrate_plus / tests / src / Kernel / Plugin / migrate_plus / data_fetcher / HttpTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate_plus\Kernel\Plugin\migrate_plus\data_fetcher;
4
5 use Drupal\KernelTests\KernelTestBase;
6 use Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http;
7
8 /**
9  * Class HttpTest.
10  *
11  * @group migrate_plus
12  * @package Drupal\Tests\migrate_plus\Unit\migrate_plus\data_fetcher
13  */
14 class HttpTest extends KernelTestBase {
15
16   /**
17    * Test http headers option.
18    *
19    * @dataProvider headerDataProvider
20    */
21   public function testHttpHeaders(array $definition, array $expected, array $preSeed = []) {
22     $http = new Http($definition, 'http', []);
23     $this->assertEquals($expected, $http->getRequestHeaders());
24   }
25
26   /**
27    * Provides multiple test cases for the testHttpHeaders method.
28    *
29    * @return array
30    *   The test cases
31    */
32   public function headerDataProvider() {
33     return [
34       'dummy headers specified' => [
35         'definition' => [
36           'headers' => [
37             'Accept' => 'application/json',
38             'User-Agent' => 'Internet Explorer 6',
39             'Authorization-Key' => 'secret',
40             'Arbitrary-Header' => 'foobarbaz',
41           ],
42         ],
43         'expected' => [
44           'Accept' => 'application/json',
45           'User-Agent' => 'Internet Explorer 6',
46           'Authorization-Key' => 'secret',
47           'Arbitrary-Header' => 'foobarbaz',
48         ],
49       ],
50       'no headers specified' => [
51         'definition' => [
52           'no_headers_here' => 'foo',
53         ],
54         'expected' => [],
55       ],
56     ];
57   }
58
59 }