kamilwylegala / cakephp2-php8

CakePHP 2 fork that supports PHP 8
116 stars 51 forks source link

Undefined TESTS constants cause the "cake bake project" command to exit with an error #37

Closed tenkoma closed 1 year ago

tenkoma commented 1 year ago

Description

The command cake bake project, which creates a project for a CakePHP 2 app, fails in PHP 8.0+ due to an undefined TESTS constant. < PHP 8.0, it worked with a warning.

This bug occurs when executing the command before the project is generated:

vendor/bin/cake bake project …

but not when executing the command after it is generated:

app/Console/cake bake project …

Currently, there is almost no opportunity to create a new CakePHP 2 project. However, I would like to fix this command because I use it in the following situations.

How to reproduce the defect

$ mkdir new_project && cd new_project
$ composer init -n --name=acme/example --type=project  
Writing ./composer.json
$ composer config repositories.cakephp/cakephp vcs https://github.com/kamilwylegala/cakephp2-php8
$ composer require "cakephp/cakephp":"dev-master as 2.10.24"
$ yes y | vendor/bin/cake bake project test_app 
Error: Undefined constant "TESTS"
#0 /var/www/new_project/vendor/cakephp/cakephp/lib/Cake/Console/Shell.php(508): TaskCollection->load('Test', Array)
#1 /var/www/new_project/vendor/cakephp/cakephp/lib/Cake/Console/Command/BakeShell.php(242): Shell->__get('Test')
#2 /var/www/new_project/vendor/cakephp/cakephp/lib/Cake/Console/Shell.php(430): BakeShell->getOptionParser()
#3 /var/www/new_project/vendor/cakephp/cakephp/lib/Cake/Console/ShellDispatcher.php(222): Shell->runCommand('project', Array)
#4 /var/www/new_project/vendor/cakephp/cakephp/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()
#5 /var/www/new_project/vendor/cakephp/cakephp/lib/Cake/Console/cake.php(54): ShellDispatcher::run(Array)
#6 {main}

PHP Version

Temporary workaround

Create temporary TESTS const in TestTask in the vendor directory.