[BUGFIX] Allow running only EXT:form subset of unit tests 09/47509/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 1 Apr 2016 11:06:02 +0000 (13:06 +0200)
committerBenni Mack <benni@typo3.org>
Tue, 5 Apr 2016 10:35:50 +0000 (12:35 +0200)
Mock the humanReadableDate() method to avoid a call to
LocalizationUtility::translate() which require a CachingBackend
to be set up.

Change-Id: I425da7a1ad815620e04e4cd9645d45dd528d672b
Releases: master, 7.6
Resolves: #75360
Reviewed-on: https://review.typo3.org/47509
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/form/Tests/Unit/Validator/AbstractValidatorTest.php
typo3/sysext/form/Tests/Unit/Validator/DateValidatorTest.php

index 57f5491..ea64c37 100644 (file)
@@ -37,11 +37,16 @@ abstract class AbstractValidatorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     protected function createSubject(array $options)
     {
         /** @var AbstractValidator $subject */
-        $subject = $this->getMock($this->subjectClassName, ['getLocalLanguageLabel'], ['options' => $options]);
+        $subject = $this->getMock(
+            $this->subjectClassName,
+            ['getLocalLanguageLabel', 'humanReadableDateFormat'],
+            ['options' => $options]
+        );
 
         /** @var FormUtility $formUtilityMock */
-        $formUtilityMock = $this->getMock(FormUtility::class, array(), array(), '', false);
+        $formUtilityMock = $this->getMock(FormUtility::class, [], [], '', false);
         $subject->setFormUtility($formUtilityMock);
+
         return $subject;
     }
 }
index 11eca91..89b68dc 100644 (file)
@@ -51,8 +51,9 @@ class DateValidatorTest extends AbstractValidatorTest
     /**
      * @test
      * @dataProvider validDateProvider
+     * @param array $input
      */
-    public function validateForValidInputHasEmptyErrorResult($input)
+    public function validateForValidInputHasEmptyErrorResult(array $input)
     {
         $options = array('element' => uniqid('test'), 'errorMessage' => uniqid('error'));
         $options['format'] = $input[0];
@@ -66,13 +67,18 @@ class DateValidatorTest extends AbstractValidatorTest
     /**
      * @test
      * @dataProvider invalidDateProvider
+     * @param array $input
      */
-    public function validateForInvalidInputHasNotEmptyErrorResult($input)
+    public function validateForInvalidInputHasNotEmptyErrorResult(array $input)
     {
         $options = array('element' => uniqid('test'), 'errorMessage' => uniqid('error'));
         $options['format'] = $input[0];
         $subject = $this->createSubject($options);
 
+        $subject->expects($this->once())
+            ->method('humanReadableDateFormat')
+            ->willReturnArgument(0);
+
         $this->assertNotEmpty(
             $subject->validate($input[1])->getErrors()
         );