Bug #88397
closedPHPUnit Test fails with TYPO3 8.7.25: AbstractController -> getContentObject() on null
0%
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
Updated by Anja Leichsenring over 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.
Updated by Julian Stock over 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!