ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ListTransformationTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
28 class ListTransformationTest extends TestCase
29 {
35  public function testListTransformation($originValue, $expectedValue): void
36  {
37  $transformList = new ListTransformation(new StringTransformation());
38  $transformedValue = $transformList->transform($originValue);
39  $this->assertIsArray($transformedValue);
40  $this->assertEquals($expectedValue, $transformedValue);
41  }
42 
47  public function testFailingTransformations($origValue): void
48  {
49  $this->expectException(UnexpectedValueException::class);
50  $transformList = new ListTransformation(new StringTransformation());
51  $transformList->transform($origValue);
52  }
53 
54  public static function ArrayToListTransformationDataProvider(): array
55  {
56  return [
57  'first_arr' => [['hello', 'world'], ['hello', 'world']],
58  'second_arr' => [['hello2', 'world2'], ['hello2', 'world2']],
59  'string_val' => ['hello world', ['hello world']],
60  'empty_array' => [[], []]
61  ];
62  }
63 
64  public static function ArrayFailureDataProvider(): array
65  {
66  return [
67  'null_array' => [[null]],
68  'value_is_no_string' => [['hello', 2]]
69  ];
70  }
71 }
testListTransformation($originValue, $expectedValue)
ArrayToListTransformationDataProvider
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null