Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractHttpControllerTestCase raises an "Error: Class 'Sympfony\Component\Console\Command\Command not found" #38

Closed
haclong opened this issue Jul 31, 2021 · 7 comments

Comments

@haclong
Copy link

haclong commented Jul 31, 2021

BC Break Report

Q A
Version 3.5

Summary

When testing my Laminas MVC application after upgrading the packages, i ran into this error :

"Error: Class 'Sympfony\Component\Console\Command\Command not found"

I have checked the current tutorial here : https://docs.laminas.dev/tutorials/unit-testing/#your-first-controller-test and here as well : https://docs.laminas.dev/laminas-test/phpunit/ and i couldn't find any reference to Symfony Component usage.

The error is raised when i use the $this->dispatch() method... which is quite blocking when using the AbstractHttpControllerTestCase...

Previous behavior

The previous behaviour :

  • Write a test case in module/MyModule/test/MyControllerTest
  • Extends with Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase
  • SetUp the tests
  • Create a test testMyController()
  • Run phpunit
    The test passes with success

Current behavior

  • Use the same test case module/MyModule/test/MyControllerTest
    of course, no changes have been applied to the MyControllerTest neither in the MyController class
  • Run phpunit
    The test runs with the errors afore mentioned

How to reproduce

@froschdesign
Copy link
Member

@haclong

I have checked the current tutorial here : https://docs.laminas.dev/tutorials/unit-testing/#your-first-controller-test and here as well : https://docs.laminas.dev/laminas-test/phpunit/ and i couldn't find any reference to Symfony Component usage.

This is correct because this component does not use symfony/console.

And if I install the skeleton application with test support then included test ApplicationTest\Controller\IndexControllerTest is successfully executed.

Please check your application if you use Sympfony\Component\Console\Command\Command somewhere.

@haclong
Copy link
Author

haclong commented Aug 1, 2021

I don't use Symfony/Console either... i'll check the other dependencies but i'll probably will need to (re)start from the skeleton application first and add up all the other dependencies... thanks anyway

@haclong haclong closed this as completed Aug 1, 2021
@haclong
Copy link
Author

haclong commented Aug 1, 2021

I'm sorry

Just installed a new project as recommended from this page : https://docs.laminas.dev/laminas-mvc/quick-start/

composer create-project -sdev laminas/laminas-mvc-skeleton my-application

I said Y to all optional packages proposed during the installation script

make sure all dependencies are installed by running composer install again (just in case)

developer mode enabled

NO OTHER dependencies

-> i still got the Symfony\Console error

it is the mvc skeleton application plain and simple... i don't understand.

Here are the trace :
/path/to/my-application/vendor/laminas/laminas-cache/src/Command/DeprecatedStorageFactoryConfigurationCheckCommand.php:19
/path/to/my-application/vendor/laminas/laminas-zendframework-bridge/src/Autoloader.php:106
/path/to/my-application/vendor/laminas/laminas-cache/src/ConfigProvider.php:67
/path/to/my-application/vendor/laminas/laminas-cache/src/Module.php:17
/path/to/my-application/vendor/laminas/laminas-modulemanager/src/Listener/ConfigListener.php:129
/path/to/my-application/vendor/laminas/laminas-eventmanager/src/EventManager.php:331
/path/to/my-application/vendor/laminas/laminas-eventmanager/src/EventManager.php:180
/path/to/my-application/vendor/laminas/laminas-modulemanager/src/ModuleManager.php:188
/path/to/my-application/vendor/laminas/laminas-modulemanager/src/ModuleManager.php:104
/path/to/my-application/vendor/laminas/laminas-eventmanager/src/EventManager.php:331
/path/to/my-application/vendor/laminas/laminas-eventmanager/src/EventManager.php:180
/path/to/my-application/vendor/laminas/laminas-modulemanager/src/ModuleManager.php:127
/path/to/my-application/vendor/laminas/laminas-mvc/src/Application.php:263
/path/to/my-application/vendor/laminas/laminas-test/src/PHPUnit/Controller/AbstractControllerTestCase.php:230
/path/to/my-application/vendor/laminas/laminas-test/src/PHPUnit/Controller/AbstractControllerTestCase.php:255
/path/to/my-application/vendor/laminas/laminas-test/src/PHPUnit/Controller/AbstractControllerTestCase.php:278
/path/to/my-application/vendor/laminas/laminas-test/src/PHPUnit/Controller/AbstractControllerTestCase.php:357
/path/to/my-application/module/Application/test/Controller/IndexControllerTest.php:47

@haclong haclong reopened this Aug 1, 2021
@froschdesign
Copy link
Member

@haclong

…i don't understand.

The stack trace contains the problem:

Here are the trace :
/path/to/my-application/vendor/laminas/laminas-cache/src/Command/DeprecatedStorageFactoryConfigurationCheckCommand.php:19

The problem is not laminas-test.

But I don't know why symfony/console is not installed when all packages are selected in the skeleton installer. laminas-cli also needs symfony/console. This must be checked.

/cc @boesing

@boesing
Copy link
Member

boesing commented Aug 1, 2021

laminas-cache provides a command to verify if a project contains deprecated configuration styles regarding cache.

However, the command is only added to the laminas-cli configuration along with the factory. It should not be used in any case until laminas-cli is installed and vendor/bin/laminas is executed.

I'll check this and see if I can provide a fix.
Creating an issue in laminas-cache for this and closing here.

@boesing
Copy link
Member

boesing commented Aug 1, 2021

@froschdesign @weierophinney I wonder if we should add the replace keyword for the laminas/laminas-zendframework-bridge in the skeleton app.

{
    "replace": {
        "laminas/laminas-zendframework-bridge": "*"
    }
}

Imho, no one should create a new laminas package along with modules which are still not migrated until now,
So the bridge won't have any meaning. This is also the root cause on why we're facing this issue.

Maybe something we want to consider in the TSC tomorrow. Gonna add an agenda item.

@boesing
Copy link
Member

boesing commented Aug 1, 2021

@haclong I've released laminas/laminas-cache in v2.12.1
Could you try updating that package to see if the error is gone? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants