ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
DictionaryTransformationTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2020 Luka K. A. Stocker, Extended GPL, see docs/LICENSE */
3 
5 
10 
12 {
18  public function testDictionaryTransformation($originVal, $expectedVal)
19  {
20  $transformation = new DictionaryTransformation(new StringTransformation());
21  $transformedValue = $transformation->transform($originVal);
22  $this->assertIsArray($transformedValue);
23  $this->assertEquals($expectedVal, $transformedValue);
24  }
25 
30  public function testTransformationFailures($failingVal)
31  {
32  $this->expectException(ConstraintViolationException::class);
33  $transformation = new DictionaryTransformation(new StringTransformation());
34  $result = $transformation->transform($failingVal);
35  }
36 
38  {
39  return [
40  'key_not_a_string' => ['hello'],
41  'value_not_a_string' => ['hello' => 1]
42  ];
43  }
44 
46  {
47  return [
48  'first_arr' => [['hello' => 'world'], ['hello' => 'world'] ],
49  'second_arr' => [['hi' => 'earth', 'goodbye' => 'world'], ['hi' => 'earth', 'goodbye' => 'world']],
50  'empty_array' => [[], []]
51  ];
52  }
53 }
$result
testDictionaryTransformation($originVal, $expectedVal)
DictionaryTransformationDataProvider