AtoumBundle icon indicating copy to clipboard operation
AtoumBundle copied to clipboard

Ability to lauch test from another SF2 env rather than "test"

Open omansour opened this issue 12 years ago • 10 comments

pointed by @KuiKui we sometimes uses another environment, like "CI"

but the bundle doesnt allow us to create a test kernel in such environment. We are stucked in "test"

omansour avatar Sep 09 '13 06:09 omansour

:+1:

KuiKui avatar Nov 06 '13 15:11 KuiKui

:+1:

jubianchi avatar Nov 06 '13 15:11 jubianchi

Here is an implementation of the request feature.

It cannot be merged as is : this patch depends on atoum/atoum#310

It allows to do:

$ app/console atoum AcmeBundle --kernel-env=ci

The default environment is testand if you do not provide the --kernel-env argument, the default will be used.

You will still be able to set the kernel environment at a test level if you want/need:

<?php

namespace vendor\FooBundle\Tests\Controller;

use atoum\AtoumBundle\Test\Units\WebTestCase;
use atoum\AtoumBundle\Test\Controller\ControllerTest;

class BarController extends ControllerTest
{
    public function testGet()
    {
        $this
            ->request(array('debug' => true, 'environment' => 'ci'))
                ->GET('/demo/' . uniqid())
                    ->hasStatus(404)
                    ->hasCharset('UTF-8')
                    ->hasVersion('1.1')
                    //...
        ;
    }
}

Here are how the environment is selected:

  • if the user provides nothing, the default value test is used
  • if the user provides a value with the --kernel-env CLI argument, its value is used
  • if the user provides a value with the environment option of the request method, its value is used. If the --kernel-env argument was used, its value is overridden by the environment option.

jubianchi avatar Nov 13 '13 22:11 jubianchi

excellent !

since then atoum/atoum#310 is merged ! :+1:

thanks to you

omansour avatar Nov 14 '13 21:11 omansour

:tada:

KuiKui avatar Nov 15 '13 07:11 KuiKui

@omansour @KuiKui seems good to me but I would like to get some reviews from others. I'll then merge everything ;)

jubianchi avatar Nov 15 '13 08:11 jubianchi

Good job @jubianchi ;)

stephpy avatar Nov 15 '13 09:11 stephpy

@KuiKui @omansour would you mind testing this branch with a real project to confirm that everything works as expected ?

Thanks :kiss:

jubianchi avatar Nov 19 '13 15:11 jubianchi

On va mettre ça en place oui :smile: Par contre, ça risque de prendre quelques jours (surtout avec le Forum PHP au milieu).

KuiKui avatar Nov 19 '13 15:11 KuiKui

@KuiKui aucun soucis ;) si ça vous va, ça me va aussi

jubianchi avatar Nov 19 '13 15:11 jubianchi