[TASK] Replace @expectedException annotation in sysext:frontend 00/48500/2
authorNadir Sunar <dernadir@gmail.com>
Wed, 8 Jun 2016 10:50:32 +0000 (12:50 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 8 Jun 2016 17:37:27 +0000 (19:37 +0200)
Use expectException() instead of @expectedException in unit tests and
add expectedExceptionCode() where possible.
This patch handles occurences in sysext:frontend.

Releases: master
Resolves: #76498

Change-Id: I7ad3759918267cf9c368c593d3fe4c4a6c3af258
Reviewed-on: https://review.typo3.org/48500
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentDataProcessorTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/MenuContentObjectFactoryTest.php
typo3/sysext/frontend/Tests/Unit/Processor/GalleryProcessorTest.php
typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php

index 4396f29..83c93d8 100755 (executable)
@@ -14,9 +14,11 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatchi
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Configuration\TypoScript\Exception\InvalidTypoScriptConditionException;
 use TYPO3\CMS\Core\Tests\UnitTestCase;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
+use TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\Fixtures\TestConditionException;
 
 /**
  * Test case
@@ -650,19 +652,21 @@ class ConditionMatcherTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \TYPO3\CMS\Core\Configuration\TypoScript\Exception\InvalidTypoScriptConditionException
      */
     public function matchThrowsExceptionIfConditionClassDoesNotInheritFromAbstractCondition()
     {
+        $this->expectException(InvalidTypoScriptConditionException::class);
+        $this->expectExceptionCode(1410286153);
         $this->matchCondition->match('[stdClass = foo]');
     }
 
     /**
      * @test
-     * @expectedException \TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\Fixtures\TestConditionException
      */
     public function matchCallsTestConditionAndHandsOverParameters()
     {
+        $this->expectException(TestConditionException::class);
+        $this->expectExceptionCode(1411581139);
         $this->matchCondition->match('[TYPO3\\CMS\\Frontend\\Tests\\Unit\\Configuration\\TypoScript\\ConditionMatching\\Fixtures\\TestCondition = 7, != 6]');
     }
 }
index d4c933c..cc3624e 100644 (file)
@@ -38,11 +38,11 @@ class ContentDataProcessorTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \UnexpectedValueException
-     * @expectedExceptionCode 1427455378
      */
     public function throwsExceptionIfProcessorClassDoesNotExist()
     {
+        $this->expectException(\UnexpectedValueException::class);
+        $this->expectExceptionCode(1427455378);
         $contentObjectRendererStub = new ContentObjectRenderer();
         $config = [
             'dataProcessing.' => [
@@ -55,11 +55,11 @@ class ContentDataProcessorTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \UnexpectedValueException
-     * @expectedExceptionCode 1427455377
      */
     public function throwsExceptionIfProcessorClassDoesNotImplementInterface()
     {
+        $this->expectException(\UnexpectedValueException::class);
+        $this->expectExceptionCode(1427455377);
         $contentObjectRendererStub = new ContentObjectRenderer();
         $config = [
             'dataProcessing.' => [
index b4c70fc..21a6d37 100755 (executable)
@@ -3897,11 +3897,11 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
     /**
      * @test
-     * @expectedException \LogicException
-     * @expectedExceptionCode 1414513947
      */
     public function renderingContentObjectThrowsException()
     {
+        $this->expectException(\LogicException::class);
+        $this->expectExceptionCode(1414513947);
         $contentObjectFixture = $this->createContentObjectThrowingExceptionFixture();
         $this->subject->render($contentObjectFixture, array());
     }
@@ -3946,13 +3946,12 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
     /**
      * @test
-     * @expectedException \LogicException
-     * @expectedExceptionCode 1414513947
      */
     public function globalExceptionHandlerConfigurationCanBeOverriddenByLocalConfiguration()
     {
         $contentObjectFixture = $this->createContentObjectThrowingExceptionFixture();
-
+        $this->expectException(\LogicException::class);
+        $this->expectExceptionCode(1414513947);
         $this->typoScriptFrontendControllerMock->config['config']['contentObjectExceptionHandler'] = '1';
         $configuration = array(
             'exceptionHandler' => '0'
@@ -4000,8 +3999,6 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
     /**
      * @test
-     * @expectedException \LogicException
-     * @expectedExceptionCode 1414513947
      */
     public function specificExceptionsCanBeIgnoredByExceptionHandler()
     {
@@ -4013,7 +4010,8 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                 'ignoreCodes.' => array('10.' => '1414513947'),
             )
         );
-
+        $this->expectException(\LogicException::class);
+        $this->expectExceptionCode(1414513947);
         $this->subject->render($contentObjectFixture, $configuration);
     }
 
index 479a0d8..90c19d3 100644 (file)
@@ -648,7 +648,6 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
     /**
      * @test
-     * @expectedException \InvalidArgumentException
      */
     public function renderThrowsExceptionForNotAllowedVariableData()
     {
@@ -661,12 +660,13 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                 ),
             ),
         );
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1288095720);
         $this->subject->render($configuration);
     }
 
     /**
      * @test
-     * @expectedException \InvalidArgumentException
      */
     public function renderThrowsExceptionForNotAllowedVariableCurrent()
     {
@@ -679,6 +679,8 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                 ),
             ),
         );
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1288095720);
         $this->subject->render($configuration);
     }
 
index b3427e6..ba38577 100644 (file)
@@ -77,10 +77,11 @@ class AbstractMenuContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
     /**
      * @test
-     * @expectedException UnexpectedValueException
      */
     public function sectionIndexThrowsAnExceptionIfTheInternalQueryFails()
     {
+        $this->expectException(\UnexpectedValueException::class);
+        $this->expectExceptionCode(1337334849);
         $this->prepareSectionIndexTest();
         $this->subject->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(array()));
         $this->subject->parent_cObj->expects($this->once())->method('exec_getQuery')->will($this->returnValue(0));
index 5c9bd7d..f2b2479 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu;
  */
 
 use TYPO3\CMS\Core\Tests\UnitTestCase;
+use TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException;
 use TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
 
 /**
@@ -24,10 +25,11 @@ class MenuContentObjectFactoryTest extends UnitTestCase
 {
     /**
      * @test
-     * @expectedException \TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException
      */
     public function getMenuObjectByTypeThrowsExceptionForUnknownType()
     {
+        $this->expectException(NoSuchMenuTypeException::class);
+        $this->expectExceptionCode(1363278130);
         $factory = new MenuContentObjectFactory;
         $factory->getMenuObjectByType($this->getUniqueId('foo_'));
     }
@@ -75,20 +77,22 @@ class MenuContentObjectFactoryTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \InvalidArgumentException
      */
     public function registerMenuTypeThrowsExceptionIfTypeIsNotOfTypeString()
     {
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1363429303);
         $factory = new MenuContentObjectFactory;
         $factory->registerMenuType(array(), 'foo');
     }
 
     /**
      * @test
-     * @expectedException \InvalidArgumentException
      */
     public function registerMenuTypeThrowsExceptionIfClassNameIsNotOfTypeString()
     {
+        $this->expectException(\InvalidArgumentException::class);
+        $this->expectExceptionCode(1363429303);
         $factory = new MenuContentObjectFactory;
         $factory->registerMenuType('foo', array());
     }
index fcce96b..80d6b19 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Processor;
 use TYPO3\CMS\Core\Resource\FileReference;
 use TYPO3\CMS\Core\Tests\UnitTestCase;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+use TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException;
 use TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor;
 
 /**
@@ -41,10 +42,11 @@ class GalleryProcessorTest extends UnitTestCase
 
     /**
      * @test
-     * @expectedException \TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException
      */
     public function processThrowsExceptionWhenFilesProcessedDataKeyIsNotFound()
     {
+        $this->expectException(ContentRenderingException::class);
+        $this->expectExceptionCode(1436809789);
         $processor = new GalleryProcessor();
         $processor->process(
             $this->contentObjectRenderer,
index 9e5e14a..9c7bcd0 100644 (file)
@@ -56,10 +56,11 @@ class AdminPanelViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
 
     /**
      * @test
-     * @expectedException \UnexpectedValueException
      */
     public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface()
     {
+        $this->expectException(\UnexpectedValueException::class);
+        $this->expectExceptionCode(1311942539);
         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = \TYPO3\CMS\Frontend\Tests\Unit\Fixtures\AdminPanelHookWithoutInterfaceFixture::class;
         /** @var $adminPanelMock \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\View\AdminPanelView */
         $adminPanelMock = $this->getMock(\TYPO3\CMS\Frontend\View\AdminPanelView::class, array('dummy'), array(), '', false);