ILIAS  release_8 Revision v8.24
TupleTransformationTest.php
Go to the documentation of this file.
1<?php
2
3declare(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
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}
testTupleTransformation(array $originVal, array $expectedVal)
@dataProvider TupleTransformationDataProvider
testNewTupleIsIncorrect(array $failingVal)
@dataProvider TupleFailingTransformationDataProvider
testTupleTooManyValues(array $tooManyValues)
@dataProvider TupleTooManyValuesDataProvider
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...