Hi, man.
Currently only PHPUnit < 5 is supported out-of-the-box.
My VERY DIRTY solution is the following script, executed after each composer install
and composer update
:
<?php
/**
* Zend_Test_PHPUnit fix for PHPUnit > 4
*
* This fix is required because PHPUnit > 4 uses namespaces.
*
* @author Francesco Zanoni
* @version 2020-01-05
*/
$basePath = realpath(__DIR__ . "/../vendor/shardj/zf1-future/library/Zend/Test/PHPUnit");
// ########################################################################
$filePath = $basePath . "/ControllerTestCase.php";
file_put_contents(
$filePath,
str_replace(
[
"/** @see Zend_Controller_Front */",
"require_once 'Zend/Controller/Front.php';",
"/** @see Zend_Controller_Action_HelperBroker */",
"require_once 'Zend/Controller/Action/HelperBroker.php';",
"/** @see Zend_Layout */",
"require_once 'Zend/Layout.php';",
"/** @see Zend_Session */",
"require_once 'Zend/Session.php';",
"/** @see Zend_Registry */",
"require_once 'Zend/Registry.php';",
"require_once 'Zend/Exception.php';",
"require_once 'Zend/Loader.php';",
"require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';",
"require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';",
"require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';",
"require_once 'Zend/Controller/Request/HttpTestCase.php';",
"require_once 'Zend/Dom/Query.php';",
],
'',
file_get_contents($filePath)
)
);
file_put_contents(
$filePath,
str_replace(
' extends PHPUnit_Framework_TestCase',
' extends \\PHPUnit\\Framework\\TestCase',
file_get_contents($filePath)
)
);
file_put_contents(
$filePath,
str_replace(
' instanceof PHPUnit_Framework_TestCase',
' instanceof \\PHPUnit\\Framework\\TestCase',
file_get_contents($filePath)
)
);
file_put_contents(
$filePath,
str_replace(
'PHPUnit_Runner_Version',
'\\PHPUnit\\Runner\\Version',
file_get_contents($filePath)
)
);
file_put_contents(
$filePath,
str_replace(
'new Zend_Test_PHPUnit_Constraint_DomQuery(',
'new Zend_Test_PHPUnit_Constraint_DomQuery41(',
file_get_contents($filePath)
)
);
file_put_contents(
$filePath,
str_replace(
'new Zend_Test_PHPUnit_Constraint_Redirect(',
'new Zend_Test_PHPUnit_Constraint_Redirect41(',
file_get_contents($filePath)
)
);
file_put_contents(
$filePath,
str_replace(
'new Zend_Test_PHPUnit_Constraint_ResponseHeader(',
'new Zend_Test_PHPUnit_Constraint_ResponseHeader41(',
file_get_contents($filePath)
)
);
// ########################################################################
$filePath = $basePath . "/Constraint/DomQuery41.php";
file_put_contents(
$filePath,
str_replace(
'extends PHPUnit_Framework_Constraint',
'extends \\PHPUnit\\Framework\\Constraint\\Constraint',
file_get_contents($filePath)
)
);
// ########################################################################
$filePath = $basePath . "/Constraint/Redirect41.php";
file_put_contents(
$filePath,
str_replace(
'extends PHPUnit_Framework_Constraint',
'extends \\PHPUnit\\Framework\\Constraint\\Constraint',
file_get_contents($filePath)
)
);
// ########################################################################
$filePath = $basePath . "/Constraint/ResponseHeader41.php";
file_put_contents(
$filePath,
str_replace(
'extends PHPUnit_Framework_Constraint',
'extends \\PHPUnit\\Framework\\Constraint\\Constraint',
file_get_contents($filePath)
)
);
// ########################################################################
$filePath = $basePath . "/Constraint/Exception.php";
file_put_contents(
$filePath,
str_replace(
'extends PHPUnit_Framework_ExpectationFailedException',
'extends \\PHPUnit\\Framework\\ExpectationFailedException',
file_get_contents($filePath)
)
);
Couldn't this be achieved in a more elegant and convenient way? Any advice is welcome.