@@ 64-87 (lines=24) @@ | ||
61 | /** |
|
62 | * @expectedException \Abacaphiliac\Zend\Transformer\Exception\TransformationException |
|
63 | */ |
|
64 | public function testNotTransformDueToInvalidInputClass() |
|
65 | { |
|
66 | $this->container->setService('config', [ |
|
67 | 'abacaphiliac/zend-transformer' => [ |
|
68 | 'transformers' => [ |
|
69 | 'FooBarToFizBuz' => [ |
|
70 | 'inputClass' => FizBuz::class, |
|
71 | 'keyMap' => [ |
|
72 | 'foo' => 'fiz', |
|
73 | 'bar' => 'buz', |
|
74 | ], |
|
75 | 'outputClass' => FooBar::class, |
|
76 | ], |
|
77 | ], |
|
78 | ], |
|
79 | ]); |
|
80 | ||
81 | self::assertTrue($this->sut->canCreateServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz')); |
|
82 | ||
83 | $transformer = $this->sut->createServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz'); |
|
84 | self::assertInstanceOf(TransformerInterface::class, $transformer); |
|
85 | ||
86 | $transformer->transform(new FooBar('Alice', 'Bob'), new FizBuz()); |
|
87 | } |
|
88 | ||
89 | /** |
|
90 | * @expectedException \Abacaphiliac\Zend\Transformer\Exception\TransformationException |
|
@@ 92-115 (lines=24) @@ | ||
89 | /** |
|
90 | * @expectedException \Abacaphiliac\Zend\Transformer\Exception\TransformationException |
|
91 | */ |
|
92 | public function testNotTransformDueToInvalidOutputClass() |
|
93 | { |
|
94 | $this->container->setService('config', [ |
|
95 | 'abacaphiliac/zend-transformer' => [ |
|
96 | 'transformers' => [ |
|
97 | 'FooBarToFizBuz' => [ |
|
98 | 'inputClass' => FooBar::class, |
|
99 | 'keyMap' => [ |
|
100 | 'foo' => 'fiz', |
|
101 | 'bar' => 'buz', |
|
102 | ], |
|
103 | 'outputClass' => FooBar::class, |
|
104 | ], |
|
105 | ], |
|
106 | ], |
|
107 | ]); |
|
108 | ||
109 | self::assertTrue($this->sut->canCreateServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz')); |
|
110 | ||
111 | $transformer = $this->sut->createServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz'); |
|
112 | self::assertInstanceOf(TransformerInterface::class, $transformer); |
|
113 | ||
114 | $transformer->transform(new FooBar('Alice', 'Bob'), new FizBuz()); |
|
115 | } |
|
116 | ||
117 | public function testTransformCustomExtractor() |
|
118 | { |