mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-22 14:57:20 +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;
|
||||||
|
|
|
@ -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,7 +28,15 @@
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
|
@ -34,9 +45,14 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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