ILIAS  release_7 Revision v7.30-3-g800a261c036
TupleTransformationTest.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
11require_once ('./libs/composer/vendor/autoload.php');
12
14 const TUPLE_KEY = 'hello';
20 public function testTupleTransformation($originVal, $expectedVal) {
21 $transformation = new TupleTransformation(
22 [
25 ]
26 );
27 $transformedValue = $transformation->transform($originVal);
28 $this->assertIsArray($transformedValue);
29 $this->assertEquals($expectedVal, $transformedValue);
30 }
31
36 public function testNewTupleIsIncorrect($failingVal) {
37 $this->expectNotToPerformAssertions();
38 $transformation = new TupleTransformation(
39 [
41 self::TUPLE_KEY => new IntegerTransformation()
42 ]
43 );
44
45 try {
46 $result = $transformation->transform($failingVal);
47 } catch (ConstraintViolationException $exception) {
48 return;
49 }
50 $this->fail();
51 }
52
57 public function testTupleTooManyValues($tooManyValues) {
58 $this->expectNotToPerformAssertions();
59 $transformation = new TupleTransformation(
60 [
63 ]
64 );
65
66 try {
67 $result = $transformation->transform($tooManyValues);
68 } catch (ConstraintViolationException $exception) {
69 return;
70 }
71 $this->fail();
72 }
73
75 return [
76 'too_many_values' => [array(1,2,3)]
77 ];
78 }
79
81 return [
82 'incorrect_tuple' => [array(1, 2)]
83 ];
84 }
85
87 return [
88 'array_test01' => [array(1, 2), [1, 2]]
89 ];
90 }
91}
$result
An exception for terminatinating execution or to throw for unit testing.
testNewTupleIsIncorrect($failingVal)
@dataProvider TupleFailingTransformationDataProvider
testTupleTooManyValues($tooManyValues)
@dataProvider TupleTooManyValuesDataProvider
testTupleTransformation($originVal, $expectedVal)
@dataProvider TupleTransformationDataProvider