Jump to content


Photo

Symfony2 - problems Symfony2 specifically gives me with unit testing


  • Please log in to reply
1 reply to this topic

#1 johnsmith153

johnsmith153

    Advanced Member

  • Members
  • PipPipPip
  • 709 posts

Posted 05 September 2013 - 10:54 PM

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 by johnsmith153, 05 September 2013 - 10:54 PM.


#2 KevinM1

KevinM1

    Snarkimus Prime

  • Moderators
  • 5,151 posts
  • LocationNew Hampshire, USA

Posted 05 September 2013 - 11:01 PM

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com