35 $this->result = new \TYPO3\CMS\Extbase\Error\Result();
43 array(
'Error',
'Errors'),
44 array(
'Warning',
'Warnings'),
45 array(
'Notice',
'Notices')
54 return $this->getMock(
'Tx_Extbase_Error_' . $type, array(), array(),
'', FALSE);
66 $addMethodName =
'add' . $dataTypeInSingular;
67 $this->result->{$addMethodName}($message);
68 $getterMethodName =
'get' . $dataTypeInPlural;
69 $this->assertEquals(array($message), $this->result->{$getterMethodName}());
81 $addMethodName =
'add' . $dataTypeInSingular;
82 $this->result->forProperty(
'foo')->{$addMethodName}($message);
83 $getterMethodName =
'get' . $dataTypeInPlural;
84 $this->assertEquals(array(), $this->result->{$getterMethodName}());
97 $addMethodName =
'add' . $dataTypeInSingular;
98 $this->result->{$addMethodName}($message1);
99 $this->result->{$addMethodName}($message2);
100 $getterMethodName =
'getFirst' . $dataTypeInSingular;
101 $this->assertSame($message1, $this->result->{$getterMethodName}());
109 $container2 = $this->result->forProperty(
'foo.bar');
110 $this->assertInstanceOf(
'TYPO3\\CMS\\Extbase\\Error\\Result', $container2);
111 $this->assertSame($container2, $this->result->forProperty(
'foo')->forProperty(
'bar'));
119 $container2 = $this->result->forProperty(
'');
120 $this->assertSame($container2, $this->result);
128 $container2 = $this->result->forProperty(NULL);
129 $this->assertSame($container2, $this->result);
141 $addMethodName =
'add' . $dataTypeInSingular;
142 $this->result->{$addMethodName}($message);
143 $methodName =
'has' . $dataTypeInPlural;
144 $this->assertTrue($this->result->{$methodName}());
155 $addMethodName =
'add' . $dataTypeInSingular;
156 $methodName =
'has' . $dataTypeInPlural;
158 $this->result->forProperty(
'foo.bar')->{$addMethodName}($message);
159 $this->assertTrue($this->result->{$methodName}());
170 $methodName =
'has' . $dataTypeInPlural;
171 $this->result->forProperty(
'foo.baz');
172 $this->result->forProperty(
'foo.bar');
173 $this->assertFalse($this->result->{$methodName}());
189 $addMethodName =
'add' . $dataTypeInSingular;
190 $this->result->forProperty(
'foo.bar')->{$addMethodName}($message1);
191 $this->result->forProperty(
'foo.baz')->{$addMethodName}($message2);
192 $this->result->forProperty(
'foo')->{$addMethodName}($message3);
193 $this->result->{$addMethodName}($message4);
194 $this->result->{$addMethodName}($message5);
195 $getMethodName =
'getFlattened' . $dataTypeInPlural;
197 '' => array($message4, $message5),
198 'foo' => array($message3),
199 'foo.bar' => array($message1),
200 'foo.baz' => array($message2)
202 $this->assertEquals($expected, $this->result->{$getMethodName}());
215 $addMethodName =
'add' . $dataTypeInSingular;
216 $this->result->forProperty(
'foo.bar')->{$addMethodName}($message1);
217 $this->result->forProperty(
'foo.baz')->{$addMethodName}($message2);
218 $getMethodName =
'getFlattened' . $dataTypeInPlural;
220 'foo.bar' => array($message1),
221 'foo.baz' => array($message2)
223 $this->assertEquals($expected, $this->result->{$getMethodName}());
240 $otherResult = new \TYPO3\CMS\Extbase\Error\Result();
241 $otherResult->addNotice($notice1);
242 $otherResult->forProperty(
'foo.bar')->addNotice($notice2);
243 $this->result->forProperty(
'foo')->addNotice($notice3);
244 $otherResult->addWarning($warning1);
245 $this->result->addWarning($warning2);
246 $this->result->addWarning($warning3);
247 $otherResult->forProperty(
'foo')->addError($error1);
248 $otherResult->forProperty(
'foo')->addError($error2);
249 $otherResult->addError($error3);
250 $this->result->merge($otherResult);
251 $this->assertSame(array($notice1), $this->result->getNotices(),
'Notices are not merged correctly without recursion');
252 $this->assertSame(array($notice3), $this->result->forProperty(
'foo')->getNotices(),
'Original sub-notices are overridden.');
253 $this->assertSame(array($notice2), $this->result->forProperty(
'foo')->forProperty(
'bar')->getNotices(),
'Sub-notices are not copied.');
254 $this->assertSame(array($warning2, $warning3, $warning1), $this->result->getWarnings());
255 $this->assertSame(array($error3), $this->result->getErrors());
256 $this->assertSame(array($error1, $error2), $this->result->forProperty(
'foo')->getErrors());
getFlattenedMessagesShouldReturnAllSubMessages($dataTypeInSingular, $dataTypeInPlural)
getMessageShouldNotBeRecursive($dataTypeInSingular, $dataTypeInPlural)
getFlattenedMessagesShouldNotContainEmptyResults($dataTypeInSingular, $dataTypeInPlural)
addedMessagesShouldBeRetrievableAgain($dataTypeInSingular, $dataTypeInPlural)
hasMessagesShouldReturnTrueIfTopLevelObjectHasMessages($dataTypeInSingular, $dataTypeInPlural)
mergeShouldMergeTwoResults()
hasMessagesShouldReturnTrueIfSubObjectHasErrors($dataTypeInSingular, $dataTypeInPlural)
getFirstMessageShouldReturnFirstMessage($dataTypeInSingular, $dataTypeInPlural)
forPropertyShouldReturnSubResult()
forPropertyWithEmptyStringShouldReturnSelf()
hasMessagesShouldReturnFalseIfSubObjectHasNoErrors($dataTypeInSingular, $dataTypeInPlural)
forPropertyWithNullShouldReturnSelf()