From f3774fa47112a01e5c5f54a4e4ef0b5553a4b325 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 31 Jul 2014 16:45:34 +0200 Subject: [PATCH 1/3] PHPUnit legacy: class_alias instead of include --- library/Zend/Test/PHPUnit/Constraint/DomQuery.php | 11 ++++++++--- library/Zend/Test/PHPUnit/Constraint/DomQuery34.php | 2 +- library/Zend/Test/PHPUnit/Constraint/DomQuery37.php | 2 +- library/Zend/Test/PHPUnit/Constraint/DomQuery41.php | 2 +- library/Zend/Test/PHPUnit/Constraint/Redirect.php | 11 ++++++++--- library/Zend/Test/PHPUnit/Constraint/Redirect34.php | 2 +- library/Zend/Test/PHPUnit/Constraint/Redirect37.php | 2 +- library/Zend/Test/PHPUnit/Constraint/Redirect41.php | 2 +- .../Zend/Test/PHPUnit/Constraint/ResponseHeader.php | 11 ++++++++--- .../Zend/Test/PHPUnit/Constraint/ResponseHeader34.php | 2 +- .../Zend/Test/PHPUnit/Constraint/ResponseHeader37.php | 2 +- .../Zend/Test/PHPUnit/Constraint/ResponseHeader41.php | 2 +- 12 files changed, 33 insertions(+), 18 deletions(-) diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php index 9b035afeac..a0f534de4f 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php @@ -21,9 +21,14 @@ */ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery41.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery41'; } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery37.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery37'; } else { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery34.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery34'; } + +class_alias( + $alias, + 'Zend_Test_PHPUnit_Constraint_DomQuery' +); diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery34.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery34.php index ae3eb07a3c..99b277a4c9 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery34.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery34.php @@ -33,7 +33,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_DomQuery34 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery37.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery37.php index 045f52b849..5826111cb1 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery37.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery37.php @@ -33,7 +33,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_DomQuery37 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery41.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery41.php index 91f6ef69d4..4ca252e574 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery41.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery41.php @@ -33,7 +33,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_DomQuery41 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect.php b/library/Zend/Test/PHPUnit/Constraint/Redirect.php index b7451a3238..453efa556d 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect.php @@ -21,9 +21,14 @@ */ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect41.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_Redirect41'; } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect37.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_Redirect37'; } else { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect34.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_Redirect34'; } + +class_alias( + $alias, + 'Zend_Test_PHPUnit_Constraint_Redirect' +); diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect34.php b/library/Zend/Test/PHPUnit/Constraint/Redirect34.php index d0f80ff2c7..fbff07de3f 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect34.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect34.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_Redirect34 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect37.php b/library/Zend/Test/PHPUnit/Constraint/Redirect37.php index a6cd1aca88..063f1800ee 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect37.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect37.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_Redirect37 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect41.php b/library/Zend/Test/PHPUnit/Constraint/Redirect41.php index c471b274ef..9d921bf393 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect41.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect41.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_Redirect extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_Redirect41 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php index 636700acff..b13aa939b9 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php @@ -21,9 +21,14 @@ */ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader41.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader41'; } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader37.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader37'; } else { - include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader34.php'); + $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader34'; } + +class_alias( + $alias, + 'Zend_Test_PHPUnit_Constraint_ResponseHeader' +); diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader34.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader34.php index 3b0545d4ca..cb9eb64b47 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader34.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader34.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_ResponseHeader34 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader37.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader37.php index 3f7738d965..5c81ca7681 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader37.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader37.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_ResponseHeader37 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader41.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader41.php index efacefa93c..05c2f921b3 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader41.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader41.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Test_PHPUnit_Constraint_ResponseHeader extends PHPUnit_Framework_Constraint +class Zend_Test_PHPUnit_Constraint_ResponseHeader41 extends PHPUnit_Framework_Constraint { /**#@+ * Assertion type constants From 25a5e24eb6ba32fa341661421a0541d84e27fa32 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 31 Jul 2014 16:50:33 +0200 Subject: [PATCH 2/3] Includes are still necessary --- library/Zend/Test/PHPUnit/Constraint/DomQuery.php | 3 +++ library/Zend/Test/PHPUnit/Constraint/Redirect.php | 3 +++ library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php index a0f534de4f..a6aa4d1a74 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php @@ -21,10 +21,13 @@ */ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery41.php'); $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery41'; } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery37.php'); $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery37'; } else { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery34.php'); $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery34'; } diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect.php b/library/Zend/Test/PHPUnit/Constraint/Redirect.php index 453efa556d..4f7d34f73a 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect.php @@ -21,10 +21,13 @@ */ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect41.php'); $alias = 'Zend_Test_PHPUnit_Constraint_Redirect41'; } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect37.php'); $alias = 'Zend_Test_PHPUnit_Constraint_Redirect37'; } else { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect34.php'); $alias = 'Zend_Test_PHPUnit_Constraint_Redirect34'; } diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php index b13aa939b9..61e22e1f18 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php @@ -21,10 +21,13 @@ */ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader41.php'); $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader41'; } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader37.php'); $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader37'; } else { + include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader34.php'); $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader34'; } From b8c0c33c9ffaa9725a1c7fdfa7ffe92e3a66ce0b Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 31 Jul 2014 17:20:46 +0200 Subject: [PATCH 3/3] class_alias not present in PHP 5.2; down to subclassing --- .../Zend/Test/PHPUnit/Constraint/DomQuery.php | 17 +++++++++-------- .../Zend/Test/PHPUnit/Constraint/Redirect.php | 17 +++++++++-------- .../Test/PHPUnit/Constraint/ResponseHeader.php | 17 +++++++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php index a6aa4d1a74..cbd99ae444 100644 --- a/library/Zend/Test/PHPUnit/Constraint/DomQuery.php +++ b/library/Zend/Test/PHPUnit/Constraint/DomQuery.php @@ -22,16 +22,17 @@ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery41.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery41'; + + class Zend_Test_PHPUnit_Constraint_DomQuery extends Zend_Test_PHPUnit_Constraint_DomQuery41 + {} } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery37.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery37'; + + class Zend_Test_PHPUnit_Constraint_DomQuery extends Zend_Test_PHPUnit_Constraint_DomQuery37 + {} } else { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery34.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_DomQuery34'; -} -class_alias( - $alias, - 'Zend_Test_PHPUnit_Constraint_DomQuery' -); + class Zend_Test_PHPUnit_Constraint_DomQuery extends Zend_Test_PHPUnit_Constraint_DomQuery34 + {} +} diff --git a/library/Zend/Test/PHPUnit/Constraint/Redirect.php b/library/Zend/Test/PHPUnit/Constraint/Redirect.php index 4f7d34f73a..1eb9bb77bf 100644 --- a/library/Zend/Test/PHPUnit/Constraint/Redirect.php +++ b/library/Zend/Test/PHPUnit/Constraint/Redirect.php @@ -22,16 +22,17 @@ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect41.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_Redirect41'; + + class Zend_Test_PHPUnit_Constraint_Redirect extends Zend_Test_PHPUnit_Constraint_Redirect41 + {} } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect37.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_Redirect37'; + + class Zend_Test_PHPUnit_Constraint_Redirect extends Zend_Test_PHPUnit_Constraint_Redirect37 + {} } else { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Redirect34.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_Redirect34'; -} -class_alias( - $alias, - 'Zend_Test_PHPUnit_Constraint_Redirect' -); + class Zend_Test_PHPUnit_Constraint_Redirect extends Zend_Test_PHPUnit_Constraint_Redirect34 + {} +} diff --git a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php index 61e22e1f18..3d8c2efaff 100644 --- a/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php +++ b/library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php @@ -22,16 +22,17 @@ if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader41.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader41'; + + class Zend_Test_PHPUnit_Constraint_ResponseHeader extends Zend_Test_PHPUnit_Constraint_ResponseHeader41 + {} } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader37.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader37'; + + class Zend_Test_PHPUnit_Constraint_ResponseHeader extends Zend_Test_PHPUnit_Constraint_ResponseHeader37 + {} } else { include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ResponseHeader34.php'); - $alias = 'Zend_Test_PHPUnit_Constraint_ResponseHeader34'; -} -class_alias( - $alias, - 'Zend_Test_PHPUnit_Constraint_ResponseHeader' -); + class Zend_Test_PHPUnit_Constraint_ResponseHeader extends Zend_Test_PHPUnit_Constraint_ResponseHeader34 + {} +}