[TASK] Add missing unit test for enumeration 17/31817/2
authorSascha Egerer <sascha.egerer@dkd.de>
Fri, 25 Jul 2014 16:00:56 +0000 (18:00 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 25 Jul 2014 16:48:45 +0000 (18:48 +0200)
Add unit test that checks if the constructor throws
an exception if an invalid value is requested.

Resolves: #60572
Releases: 6.3, 6.2
Change-Id: I2179414f94bbd6465c5b780c71dfed3c91e71776
Reviewed-on: http://review.typo3.org/31817
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Type/Enumeration.php
typo3/sysext/core/Tests/Unit/Type/EnumerationTest.php

index 58813f3..f77f23e 100644 (file)
@@ -60,7 +60,8 @@ abstract class Enumeration implements TypeInterface {
        }
 
        /**
-        * @throws \Exception
+        * @throws Exception\InvalidEnumerationValueException
+        * @throws Exception\InvalidEnumerationDefinitionException
         * @internal param string $class
         */
        protected function loadValues() {
index c2fc11c..6784466 100644 (file)
@@ -18,7 +18,7 @@ use TYPO3\CMS\Core\Tests\Unit\Type\Fixture\Enumeration;
 use TYPO3\CMS\Core\Type;
 
 /**
- * Testcase for class \TYPO3\CMS\Core\Type\Enumeration
+ * Test case
  */
 class EnumerationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
@@ -26,7 +26,7 @@ class EnumerationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         * @expectedException \TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException
         */
-       public function constructThrowsExceptionIfNoConstantsAreDefined() {
+       public function constructorThrowsExceptionIfNoConstantsAreDefined() {
                new Enumeration\MissingConstantsEnumeration();
        }
 
@@ -34,6 +34,14 @@ class EnumerationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         * @expectedException \TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException
         */
+       public function constructorThrowsExceptionIfInvalidValueIsRequested() {
+               new Enumeration\CompleteEnumeration('bar');
+       }
+
+       /**
+        * @test
+        * @expectedException \TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException
+        */
        public function loadValuesThrowsExceptionIfGivenValueIsNotAvailableInEnumeration() {
                new Enumeration\MissingConstantsEnumeration(2);
        }
@@ -87,7 +95,7 @@ class EnumerationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
-       public function constructerSetsValue() {
+       public function constructorSetsValue() {
                $enumeration = $this->getAccessibleMock(
                        'TYPO3\\CMS\\Core\\Tests\\Unit\\Type\\Fixture\\Enumeration\\CompleteEnumeration',
                        array('dummy'),