[BUGFIX] Incomplete mocking in ext:frontend getImgResourceHook test 87/23487/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 30 Aug 2013 12:23:27 +0000 (14:23 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 30 Aug 2013 12:30:57 +0000 (14:30 +0200)
A global variable is reset to not call a sub section of the method
under test that may trigger errors.

Change-Id: If486523f231c7463804ac03a663834a820cdd3f1
Releases: 6.2
Resolves: #51581
Reviewed-on: https://review.typo3.org/23487
Reviewed-by: Sascha Egerer
Tested-by: Sascha Egerer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 0221d50..45ac75b 100644 (file)
@@ -89,10 +89,19 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function getImgResourceHookGetsCalled() {
-               $this->template->expects($this->atLeastOnce())->method('getFileName')->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
+               $this->template
+                       ->expects($this->atLeastOnce())
+                       ->method('getFileName')
+                       ->with('typo3/clear.gif')
+                       ->will($this->returnValue('typo3/clear.gif'));
+               // Reset some global variable to not trigger unrelated method code parts
+               $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] = '';
                $className = uniqid('tx_coretest');
                $getImgResourceHookMock = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetImageResourceHookInterface', array('getImgResourcePostProcess'), array(), $className);
-               $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
+               $getImgResourceHookMock
+                       ->expects($this->once())
+                       ->method('getImgResourcePostProcess')
+                       ->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
                $getImgResourceHookObjects = array($getImgResourceHookMock);
                $this->cObj->_setRef('getImgResourceHookObjects', $getImgResourceHookObjects);
                $this->cObj->IMAGE(array('file' => 'typo3/clear.gif'));