Skip to content

Commit

Permalink
At Zend_Test_PHPUnit_ControllerTestCase, added a class alias for Yoas…
Browse files Browse the repository at this point in the history
…t\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.
  • Loading branch information
boenrobot committed Feb 2, 2024
1 parent dbdd481 commit 836303b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions library/Zend/Test/PHPUnit/ControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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
{
Expand Down Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/Layout/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Zend/Test/PHPUnit/ControllerTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 836303b

Please sign in to comment.