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

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

  • SOLVED

I just upgraded to [[LINK href="http://www.symfony-project.org/blog/2009/11/10/lime-2-alpha-released"]]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)

2010-02-24

Gordon Franke answers:

i think it is not a good idea to use lime 2. Symfony 2 will use phpunit as test framework see https://gist.github.com/309820/59a86f8637e9ce85c17daf57317922f597c4569e and Symfony 2 will came at the end of the year 2010 see [[LINK http://www.slideshare.net/fabpot/symfony-20-revealed]]http://www.slideshare.net/fabpot/symfony-20-revealed[[/LINK]] slide 130.

You can also use PHPUnit in your symfony 1 projects see
[[LINK href="http://dev.esl.eu/blog/2010/02/25/testing-symfony-projects-with-phpunit/"]]http://dev.esl.eu/blog/2010/02/25/testing-symfony-projects-with-phpunit/[[/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.

2010-02-24

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.

Example:

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

LimeAutoloader::register();
LimeAnnotationSupport::enable();

$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

...

2010-02-24

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="http://webmozarts.com/2009/06/30/easy-unit-testing/"]]http://webmozarts.com/2009/06/30/easy-unit-testing/[[/LINK]]
[[LINK href="http://www.symfony-project.org/blog/2009/11/10/lime-2-alpha-released"]]http://www.symfony-project.org/blog/2009/11/10/lime-2-alpha-released[[/LINK]]

2010-02-24

szemian answers:

Just a guess, did you enable the annotation?


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