mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-22 06:47:19 +00:00
Cake shell 'test' works - prints help info.
This commit is contained in:
parent
58e843e981
commit
deb8c8b305
6 changed files with 49 additions and 14 deletions
|
@ -37,3 +37,12 @@ It means that composer will look at `master` branch of repository configured und
|
||||||
### 2021-02-24
|
### 2021-02-24
|
||||||
|
|
||||||
- Fixed ErrorHandler accordingly to PHP8 migration guide. Otherwise, error handler is logging too much and doesn't respect configured `error_reporting`.
|
- Fixed ErrorHandler accordingly to PHP8 migration guide. Otherwise, error handler is logging too much and doesn't respect configured `error_reporting`.
|
||||||
|
|
||||||
|
## Debugging cake console in PHPStorm
|
||||||
|
|
||||||
|
Make sure PHP and XDebug extension are installed.
|
||||||
|
|
||||||
|
1. Find `cake.php` in `lib/Cake/Console`.
|
||||||
|
2. Click with right mouse button and choose "Debug".
|
||||||
|
3. Go to debug configurations and edit this configuration.
|
||||||
|
4. Add argument e.g. `test`.
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
"ext-mcrypt": "You need to install ext-openssl or ext-mcrypt to use AES-256 encryption"
|
"ext-mcrypt": "You need to install ext-openssl or ext-mcrypt to use AES-256 encryption"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^3.7",
|
"phpunit/phpunit": "^8.0",
|
||||||
"cakephp/cakephp-codesniffer": "^1.0.0"
|
"cakephp/cakephp-codesniffer": "^1.0.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|
|
@ -355,6 +355,10 @@ class Shell extends CakeObject {
|
||||||
*/
|
*/
|
||||||
public function hasMethod($name) {
|
public function hasMethod($name) {
|
||||||
try {
|
try {
|
||||||
|
if ($name === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$method = new ReflectionMethod($this, $name);
|
$method = new ReflectionMethod($this, $name);
|
||||||
if (!$method->isPublic() || substr($name, 0, 1) === '_') {
|
if (!$method->isPublic() || substr($name, 0, 1) === '_') {
|
||||||
return false;
|
return false;
|
||||||
|
@ -983,7 +987,7 @@ class Shell extends CakeObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the stdout logger
|
* Configure the stdout logger
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _configureStdOutLogger() {
|
protected function _configureStdOutLogger() {
|
||||||
|
@ -996,7 +1000,7 @@ class Shell extends CakeObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the stderr logger
|
* Configure the stderr logger
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _configureStdErrLogger() {
|
protected function _configureStdErrLogger() {
|
||||||
|
@ -1009,8 +1013,8 @@ class Shell extends CakeObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given logger is configured
|
* Checks if the given logger is configured
|
||||||
*
|
*
|
||||||
* @param string $logger The name of the logger to check
|
* @param string $logger The name of the logger to check
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _loggerIsConfigured($logger) {
|
protected function _loggerIsConfigured($logger) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ App::uses('CakeTestFixture', 'TestSuite/Fixture');
|
||||||
*
|
*
|
||||||
* @package Cake.TestSuite
|
* @package Cake.TestSuite
|
||||||
*/
|
*/
|
||||||
abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
abstract class CakeTestCase extends \PHPUnit\Framework\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class responsible for managing the creation, loading and removing of fixtures
|
* The class responsible for managing the creation, loading and removing of fixtures
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
* @package Cake.TestSuite
|
* @package Cake.TestSuite
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Runner\StandardTestSuiteLoader;
|
||||||
|
use PHPUnit\Runner\TestSuiteLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestLoader for CakePHP Test suite.
|
* TestLoader for CakePHP Test suite.
|
||||||
*
|
*
|
||||||
|
@ -25,21 +28,34 @@
|
||||||
*
|
*
|
||||||
* @package Cake.TestSuite
|
* @package Cake.TestSuite
|
||||||
*/
|
*/
|
||||||
class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
|
class CakeTestLoader implements TestSuiteLoader {
|
||||||
|
|
||||||
/**
|
|
||||||
|
private TestSuiteLoader $testSuiteLoader;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->testSuiteLoader = new StandardTestSuiteLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Load a file and find the first test case / suite in that file.
|
* Load a file and find the first test case / suite in that file.
|
||||||
*
|
*
|
||||||
* @param string $filePath The file path to load
|
* @param string $filePath The file path to load
|
||||||
* @param string $params Additional parameters
|
* @param string $params Additional parameters
|
||||||
* @return ReflectionClass
|
* @return ReflectionClass
|
||||||
*/
|
*/
|
||||||
public function load($filePath, $params = '') {
|
public function load(string $filePath, string $params = '') : ReflectionClass {
|
||||||
$file = $this->_resolveTestFile($filePath, $params);
|
$file = $this->_resolveTestFile($filePath, $params);
|
||||||
return parent::load('', $file);
|
return $this->testSuiteLoader->load('', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function reload(ReflectionClass $aClass) : ReflectionClass
|
||||||
|
{
|
||||||
|
return $this->testSuiteLoader->reload($aClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Convert path fragments used by CakePHP's test runner to absolute paths that can be fed to PHPUnit.
|
* Convert path fragments used by CakePHP's test runner to absolute paths that can be fed to PHPUnit.
|
||||||
*
|
*
|
||||||
* @param string $filePath The file path to load.
|
* @param string $filePath The file path to load.
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
/**
|
/**
|
||||||
* Path to the tests directory of the app.
|
* Path to the tests directory of the app.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
if (!defined('TESTS')) {
|
if (!defined('TESTS')) {
|
||||||
define('TESTS', APP . 'Test' . DS);
|
define('TESTS', APP . 'Test' . DS);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,7 @@ class CakeTestSuiteDispatcher {
|
||||||
* @return bool true if found, false otherwise
|
* @return bool true if found, false otherwise
|
||||||
*/
|
*/
|
||||||
public function loadTestFramework() {
|
public function loadTestFramework() {
|
||||||
if (class_exists('PHPUnit_Framework_TestCase')) {
|
if (class_exists(TestCase::class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$phpunitPath = 'phpunit' . DS . 'phpunit';
|
$phpunitPath = 'phpunit' . DS . 'phpunit';
|
||||||
|
@ -177,8 +180,11 @@ class CakeTestSuiteDispatcher {
|
||||||
return $included;
|
return $included;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
include 'PHPUnit' . DS . 'Autoload.php';
|
|
||||||
return class_exists('PHPUnit_Framework_TestCase');
|
//TODO: Remove code above. It should be enough to go directly to composer directory and get php unit.
|
||||||
|
include $vendor . DS . "autoload.php";
|
||||||
|
|
||||||
|
return class_exists(TestCase::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue