From 836303ba9473595fe2bb7b1db8af77d03bbf46ce Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Fri, 2 Feb 2024 16:53:18 +0200 Subject: [PATCH] At Zend_Test_PHPUnit_ControllerTestCase, added a class alias for Yoast\PHPUnitPolyfills\TestCases\TestCase or PHPUnit\Framework\TestCase, thus enabling the use of this class in any PHPUnit version, and thus any PHP version. Also added property-read annotations. --- .../Zend/Test/PHPUnit/ControllerTestCase.php | 24 +++++++++++++++++++ tests/Zend/Layout/AllTests.php | 2 +- .../Test/PHPUnit/ControllerTestCaseTest.php | 5 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/library/Zend/Test/PHPUnit/ControllerTestCase.php b/library/Zend/Test/PHPUnit/ControllerTestCase.php index a2ff0d2de5..40cd4e22ca 100644 --- a/library/Zend/Test/PHPUnit/ControllerTestCase.php +++ b/library/Zend/Test/PHPUnit/ControllerTestCase.php @@ -34,6 +34,14 @@ /** @see Zend_Registry */ require_once 'Zend/Registry.php'; +if (!class_exists('PHPUnit_Framework_TestCase')) { + if (class_exists('Yoast\PHPUnitPolyfills\TestCases\TestCase')) { + class_alias('Yoast\PHPUnitPolyfills\TestCases\TestCase', 'PHPUnit_Framework_TestCase'); + } elseif (class_exists('PHPUnit\Framework\TestCase')) { + class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); + } +} + /** * Functional testing scaffold for MVC applications * @@ -43,6 +51,10 @@ * @subpackage PHPUnit * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * + * @property-read Zend_Controller_Request_HttpTestCase $request + * @property-read Zend_Controller_Response_HttpTestCase $response + * @property-read Zend_Controller_Front $frontController */ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_TestCase { @@ -125,6 +137,18 @@ protected function setUp(): void $this->bootstrap(); } + /** + * Set up MVC app + * + * Calls {@link bootstrap()} by default + * + * Version intended for use when extending from Yoast\PHPUnitPolyfills\TestCases\TestCase + */ + protected function set_up() + { + $this->bootstrap(); + } + /** * Bootstrap the front controller * diff --git a/tests/Zend/Layout/AllTests.php b/tests/Zend/Layout/AllTests.php index a17daf59a5..54472f4f5f 100644 --- a/tests/Zend/Layout/AllTests.php +++ b/tests/Zend/Layout/AllTests.php @@ -55,7 +55,7 @@ public static function suite() $suite->addTestSuite('Zend_Layout_LayoutTest'); $suite->addTestSuite('Zend_Layout_HelperTest'); $suite->addTestSuite('Zend_Layout_PluginTest'); - // $suite->addTestSuite('Zend_Layout_FunctionalTest'); + $suite->addTestSuite('Zend_Layout_FunctionalTest'); return $suite; } diff --git a/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php b/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php index 1fe55cc9af..8b5a604d4d 100644 --- a/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php +++ b/tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php @@ -885,6 +885,11 @@ public function providerRedirectWorksAsExpectedFromHookMethodsInFrontControllerP // Concrete test case class for testing purposes class Zend_Test_PHPUnit_ControllerTestCaseTest_Concrete extends Zend_Test_PHPUnit_ControllerTestCase { + // Added to elevate the otherwise protected method to a public one + public function set_up() + { + parent::set_up(); + } } // Call Zend_Test_PHPUnit_ControllerTestCaseTest::main() if this source file is executed directly.