| Total Complexity | 4 | 
| Total Lines | 99 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 9 | class PackDataUnitTest extends TestCase | ||
| 10 | { | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Testing data provider | ||
| 14 | * | ||
| 15 | * @return array testing data | ||
| 16 | */ | ||
| 17 | public function packDataDataProvider(): array | ||
| 18 |     { | ||
| 19 | return [ | ||
| 20 | // #0, list of scalars | ||
| 21 | [ | ||
| 22 | [ | ||
| 23 | 'a' => 1, | ||
| 24 | 'b' => 2 | ||
| 25 | ], | ||
| 26 | 'a=1&b=2' | ||
| 27 | ], | ||
| 28 | // #1, nested array | ||
| 29 | [ | ||
| 30 | [ | ||
| 31 | 'arr' => [ | ||
| 32 | 'key' => 'value' | ||
| 33 | ] | ||
| 34 | ], | ||
| 35 | 'arr[key]=value' | ||
| 36 | ], | ||
| 37 | // #2, deeper nested arrays | ||
| 38 | [ | ||
| 39 | [ | ||
| 40 | 'field' => [ | ||
| 41 | [ | ||
| 42 | 'key' => 'value' | ||
| 43 | ] | ||
| 44 | ] | ||
| 45 | ], | ||
| 46 | 'field[0][key]=value' | ||
| 47 | ] | ||
| 48 | ]; | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * Testing method packData | ||
| 53 | * | ||
| 54 | * @param array $data | ||
| 55 | * data to be packed | ||
| 56 | * @param string $expected | ||
| 57 | * expected result | ||
| 58 | * @dataProvider packDataDataProvider | ||
| 59 | */ | ||
| 60 | public function testPackData(array $data, string $expected): void | ||
| 61 |     { | ||
| 62 | // test body | ||
| 63 | $result = CurlWrapper::packData($data); | ||
| 64 | |||
| 65 | // assertions | ||
| 66 | $this->assertEquals($expected, $result); | ||
| 67 | } | ||
| 68 | |||
| 69 | /** | ||
| 70 | * Data provider | ||
| 71 | * | ||
| 72 | * @return array Testing data | ||
| 73 | */ | ||
| 74 | public function packDataExceptionDataProvider(): array | ||
| 88 | ] | ||
| 89 | ] | ||
| 90 | ] | ||
| 91 | ]; | ||
| 92 | } | ||
| 93 | |||
| 94 | /** | ||
| 95 | * Testing exception throwing | ||
| 96 | * | ||
| 97 | * @param array $data | ||
| 98 | * test data | ||
| 99 | * @dataProvider packDataExceptionDataProvider | ||
| 100 | */ | ||
| 101 | public function testExceptionWhilePackingData(array $data): void | ||
| 110 |