Project

General

Profile

Actions

Bug #88397

closed

PHPUnit Test fails with TYPO3 8.7.25: AbstractController -> getContentObject() on null

Added by Julian Stock almost 5 years ago. Updated almost 5 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2019-05-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hi,

we're using our own redirect extension, which tests throw some errors like the following when updating to something newer than TYPO3 8.7.24.

1) Vendor\VendorRedirect\Tests\Unit\Controller\RedirectControllerTest::testAddRedirectAction
Failed asserting that exception of type "Error" matches expected exception "TYPO3\CMS\Extbase\Mvc\Exception\StopActionException". Message was: "Call to a member function getContentObject() on null" at
/current/public/typo3conf/ext/vendor_redirect/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php:359
/current/public/typo3conf/ext/vendor_redirect/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php:326
/current/public/typo3conf/ext/vendor_redirect/Classes/Controller/RedirectController.php:145
/current/public/typo3conf/ext/vendor_redirect/Tests/Unit/Controller/RedirectControllerTest.php:263
.

/current/public/typo3conf/ext/vendor_redirect/vendor/phpunit/phpunit/phpunit:53

On older versions it's working fine. I think the problem occurred with these changes: https://github.com/TYPO3/TYPO3.CMS/commit/e855f9cf674002e8137802997d6daebf3b3778dc#diff-e866bf1ab1a87cc4bc5b9b9c963d6823

Thanks for reading, have a nice day!
- Julian

Actions #1

Updated by Anja Leichsenring almost 5 years ago

  • Status changed from New to Rejected

you will have to adjust your tests to the core change, in this case make sure the configurationManager is created and initialized in a useful way.

Mocking might be an option.

But there is nothing the TYPO3 core can do in terms of not breaking third party application / extension tests, that is something the authors have to take care of.

Actions #2

Updated by Julian Stock almost 5 years ago

Thanks for the heads up, Anja!

Using the following code helped:

            $settings = new class() {
                public function getUserObjectType() {
                    return FALSE;
                }
            };
            $this->configurationManager->method("getContentObject")
                ->willReturn($settings);

            $this->inject($this->redirectControllerSUT, "configurationManager", $this->configurationManager);

Have a nice day!

Actions

Also available in: Atom PDF