php - Can we use Symfony\Bundle\FrameworkBundle\Test\WebTestCase for symfony 2 console commands testing? -


using symfony\bundle\frameworkbundle\test\webtestcase, easy access container, entity manager etc. can use functional testing automatic manual http requests.

can use test symfony2 console commands can have easy access container , services?

i want test costum symfony2 console commands uses many services in turn uses doctrine entity manager access data.

phpunit documentation suggest extend test class phpunit_extensions_database_testcase,

can extend webtestcase instead of test instead test console commands ?

i have refereed

webtestcase meant functional testing web applications. nothing stop using test commands, doesn't feel right (hence question).

testing commands

remember, command tests (as controller tests) shouldn't complex, code you're putting in there shouldn't complex either.

treat commands controllers, make them slim , put business logic belongs - model.

accessing container

having said that, can implement own kernelawaretestcase (or containerawaretestcase) yourself. here's base class i'm using occasionally: jakzal / kernelawaretest.php gist

also, note next symfony\component\console\application there's symfony\bundle\frameworkbundle\console\application can work symfony kernel.

final note

remember, extensive testing should done on unit level.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -