Skip to content
Advertisement

Having issue with Symfony 3 Unit testing that has session enabled

I am new in unit testing. I have Symfony 3 console command application which is using symfony session for temporary data store.

In my unit test class I extend KernelTestCase which give me error while I tested it but if I extend SymfonyComponentHttpKernelEventListenerTestSessionListener class then the error gone and passed the test.

After some time I realize that it always passed test no mater what I write inside the test case.

My Console class

JavaScript

My test case

JavaScript

After that I also tried to extend SymfonyBundleFrameworkBundleTestsFunctionalSessionTest

JavaScript

but it give me the following error

JavaScript

My expected output from console is the following that needs to be tested

JavaScript

Advertisement

Answer

Try removing

JavaScript

and add:

JavaScript

see: http://www.inanzzz.com/index.php/post/c7jb/testing-symfony-console-command-with-phpunit

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement