Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Situation

I am using phpunit (4.1.10) and phpunitBundle (4.1.*) in order to unit test my symfony2 (2.4.4) application. I am using phpwamp (alias for php of wamp) version 5.4.10, php installed on computer being rather old (version 5.3.28).

Testing usually works fine.

Issue

When using router->generate(a_route), it returns an error.

public function setUp()
{
    static::$kernel = static::createKernel();
    static::$kernel->boot();
    $this->em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
    $this->container = static::$kernel->getContainer();
}

public function testFoo(){

    /*temp*/
    $x = $this->container->get('router')->generate('my_route');
}

ERROR:

F.PHP Parse error:  parse error in /path_to_project/project/src/Foo/FooBundle   /Controller/FooController.php on line xx

Solution:

I observe that the parse error occurs in FooController.php, whereas I am not at all testing a controller (its an entityRepo test). however, php line hint is usually useless when it comes to parse error, so ..

In the same time, this does not come form a real parse error, as the same generation works perfectly well when tested manually.

Any hint about this phpunit issue / ways to bypass it ? Many thanks in advance for your help

share|improve this question

1 Answer 1

I was able to solve my issue. It came from installing the phpunit.phar as executable file. It gets automatically executed by php built in, not php wamp.

Keeping the phar as is, putting it in the root of the project, and executing (in command console):

phpwamp phpunit.phpar --version

works well.

Cheers,

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.