Ask your Symfony questions! Pay money and get answers fast! (more info)

Can someone post a full working example of Lime 2 annotations? Symfony


I just upgraded to [[LINK href=""]]Lime 2[[/LINK]] and I'm trying to write a functional test that uses annotations. I'm doing something wrong - its as if the annotations never get called. Can someone please post a working example, so I can see how its done?

<strong>Update</strong>: So, maybe this feature isn't used much? Can anyone post an actual example that they've written?

Answers (4)


Gordon Franke answers:

i think it is not a good idea to use lime 2. Symfony 2 will use phpunit as test framework see and Symfony 2 will came at the end of the year 2010 see [[LINK]][[/LINK]] slide 130.

You can also use PHPUnit in your symfony 1 projects see
[[LINK href=""]][[/LINK]]

Lawrence Krubner comments:

Ah, that is frustrating. I initially resisted using Lime because I didn't want to learn another testing framework. Then, finally, 6 months ago, I decided I should use it because using it was the official Symfony way of doing things. Now it is going away?

At least PHPUnit is solid.


Bernhard Schussek answers:

Hi Lawrence,

First of all, I never tested Lime 2 with functional tests and annotations (yet). So I cannot tell you exactly whether that will work.

To get Lime 2 working correctly with annotations, you need to do three things:

1) Load the LimeAutoloader
2) Register it
3) Enable annotation support

Then you are able to use annotations. Again, this is for unit tests, I'm not sure whether functional tests work out of the box with annotations. This was never tested by me.


require_once dirname(__FILE__).'/../../lib/LimeAutoloader.php';


$t = new LimeTest(2);

// @Before

$fixture = new SomeClass();

// @Test: SomeClass behaves correctly if 1 == 1

$t->is($fixture->one(), 1, "1 is definitely 1");

// @Test: If 1 is not 1, SomeClass throws a WeirdMathsException



Christian Schaefer answers:

I have to second Gordon. Latest rumours show that Lime2 is dropped in favour of PHPUnit.
However I have to point out that lime and Lime2 are both for unit testing not functions tests!

For functional Tests you should use sfTestBrowser which has nothing to do with lime.

More can be read here:
[[LINK href=""]][[/LINK]]
[[LINK href=""]][[/LINK]]


szemian answers:

Just a guess, did you enable the annotation?

require_once dirname(__FILE__).'/../boostrap/functional.php';