ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
TupleTransformationTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
27 
29 {
30  private const TUPLE_KEY = 'hello';
31 
37  public function testTupleTransformation(array $originVal, array $expectedVal): void
38  {
39  $transformation = new TupleTransformation(
40  [
43  ]
44  );
45  $transformedValue = $transformation->transform($originVal);
46  $this->assertIsArray($transformedValue);
47  $this->assertEquals($expectedVal, $transformedValue);
48  }
49 
54  public function testNewTupleIsIncorrect(array $failingVal): void
55  {
56  $this->expectNotToPerformAssertions();
57  $transformation = new TupleTransformation(
58  [
60  self::TUPLE_KEY => new IntegerTransformation()
61  ]
62  );
63 
64  try {
65  $result = $transformation->transform($failingVal);
66  } catch (ConstraintViolationException $exception) {
67  return;
68  }
69  $this->fail();
70  }
71 
76  public function testTupleTooManyValues(array $tooManyValues): void
77  {
78  $this->expectNotToPerformAssertions();
79  $transformation = new TupleTransformation(
80  [
83  ]
84  );
85 
86  try {
87  $result = $transformation->transform($tooManyValues);
88  } catch (ConstraintViolationException $exception) {
89  return;
90  }
91  $this->fail();
92  }
93 
94  public function TupleTooManyValuesDataProvider(): array
95  {
96  return [
97  'too_many_values' => [[1,2,3]]
98  ];
99  }
100 
101  public function TupleFailingTransformationDataProvider(): array
102  {
103  return [
104  'incorrect_tuple' => [[1, 2]]
105  ];
106  }
107 
108  public function TupleTransformationDataProvider(): array
109  {
110  return [
111  'array_test01' => [[1, 2], [1, 2]]
112  ];
113  }
114 }
testTupleTooManyValues(array $tooManyValues)
TupleTooManyValuesDataProvider
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testTupleTransformation(array $originVal, array $expectedVal)
TupleTransformationDataProvider
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testNewTupleIsIncorrect(array $failingVal)
TupleFailingTransformationDataProvider
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...