johnsmith153 Posted September 6, 2013 Share Posted September 6, 2013 (edited) Symfony2 specifically gives me problems because of its setup. I am getting this error: PHP Fatal error: Call to a member function get() on a non-object in /symfony-path/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php on line 252 I get this whenever I attempt to test a controller that returns either a rendered Twig template or when I use a controller that uses a service (and that doesn't return a rendered Twig template). So I'm trying to test controllers, but other than basic PHP it doesn't seem possible. Is there anything I can do? Is there a way of the controllers being able to access the services? Also, no doubt I'm going to have problems when I try running database queries. Unless I resolve this I see no point in Unit Testing. I'm sure there's an easy solution. Edited September 6, 2013 by johnsmith153 Quote Link to comment https://forums.phpfreaks.com/topic/281905-symfony2-problems-symfony2-specifically-gives-me-with-unit-testing/ Share on other sites More sharing options...
KevinM1 Posted September 6, 2013 Share Posted September 6, 2013 Can you show us how you're trying to test your controller? Symfony is supposed to be usable with PHPUnit out of the box, and there's a section on it in the official docs. Quote Link to comment https://forums.phpfreaks.com/topic/281905-symfony2-problems-symfony2-specifically-gives-me-with-unit-testing/#findComment-1448403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.