eZ Community » Forums » eZ Publish 5 Platform » Behat functionnal tests
expandshrink

Behat functionnal tests

Behat functionnal tests

Tuesday 18 March 2014 9:34:55 am - 5 replies

Hello

 

I'm trying to launch PHPUnit functionnal tests with eZ 5.

Tried with a fresh eZ 5, and created a demo bundle using Symfony command line tool.
This bundle comes with a defaut unit test for the route /hello/
Site works fine so far. 

 

When lauching PHPUnit :
phpunit web/phpunit.xml -c ezpublish/

The received response from the crawler is a redirect response pointing to /ezsetup

So the test failed, as the expected response should be the result of the /hello route...

 

Does someone have any idea why PHPUnit is redirected to /ezsetup ?

 

Thanks

Modified on Thursday 10 April 2014 11:26:00 am by Jeremy B.

Tuesday 18 March 2014 10:31:06 am

It is because you need to either configure eZ Publish first a bit, or reuse the "behat" environment we are using for this.

Tuesday 18 March 2014 11:55:48 am

This is how I'm using PHPUnit:

  • In ezpublish/phpunit.xml.dist I added this env variable: 
    <env name="DATABASE" value="mysql://user@hostname/dbname" />
  • Launch the tests with the following command:
    phpunit -c ezpublish 

In order to test the default controller you do not need to add the env variabile. Just launch PHPUnit with the command above.

Tuesday 18 March 2014 3:23:02 pm

The reply has been removed because of violation of forum rules.

Tuesday 18 March 2014 7:18:27 pm

Ok.
To rephrase what I implied in earlier post you'll need to set the env variable ENVIRONMENT = "behat", that should in your case be it.

In functional testing frameworks like Behat which tests over http as opposed to initiate request directly against the symfony container at hand, you'll also need to make sure the server uses same ENVIRONMENT, but I don't think this applies to your case.

The reason for this is you need to test against a configured instance of eZ Publish, cause out of the box eZ Publish is supposed to ask you to do setup wizard (/ezsetup) so from eZ Publish point of view the response is correct. 

Modified on Tuesday 18 March 2014 7:22:21 pm by André R

Thursday 10 April 2014 11:23:01 am

Sorry for late reply blunk.gif Emoticon

 

We finally managed to launch Behat unit tests :

- Installed latest BehatBundle from eZ github
- Checked config_behat.yml and ezpublish_behat.yml
- Add a context in behat.yml
- Write some tests features
- Launch tests in command line with : php bin/behat @Namespace\OurBundle

Additonnaly, the tests are automaticaly launched via Jenkins when packaging. Cool !
http://shaneauckland.co.uk/2013/0...ating-behat-and-mink-with-jenkinsci/ 

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from