vendredi 18 décembre 2020

Symfony & Panther : Panther does'nt load - can't createPantherClient()

I have an issue with Panther in a Symfony 4.4 project. The project have LiipFunctionnalTestBundle on it, but for testing JS as well, i wanted to have Panther. I've installed Panther, in my composer i've "symfony/panther": "^0.8.0"," and i can extends my class with PantherTestCase or use PantherTestCaseTrait to have Panther and Liip (according to the documentation) https://github.com/symfony/panther But i'm not sure my project initialized Panther... If i do a simple test like :

<?php

namespace App\Tests\Controller\Social;

use Symfony\Component\Panther\PantherTestCase;

class PantherControllerTest extends PantherTestCase
{

    public function test1(): void
    {
        $client = static::createPantherClient(); // create your panther client

        $client->request('GET', '/login');
    }
}

I will have an error message when testing it :

  1. App\Tests\Controller\Social\PantherControllerTest::test1 Symfony\Component\Process\Exception\LogicException: Output has been disabled. and it target the line with "createPantherClient".

If i tried to use Liip with WebTestCase and Panther in a Trait : it's working until i want to use specific assert from Panther. And then my IDE say 'assertSelectorIsEnabled' not found in NewsControllerPantherTest'. The method createPantherClient is not recognize, so even if i tried to put a localhost and a port to it, it doesn't work...

So i think Panther is in my project but doesn't load ? I'm in a windows pc with Mamp, php 7.4.1 and Apache.

I've put the tag in phpunit.xml.dist as say in the doc.

<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="tests/bootstrap.php"
>
    <extensions>
        <extension class="Symfony\Component\Panther\ServerExtension" />
    </extensions>
    <php>
        <ini name="error_reporting" value="-1" />
        <server name="APP_ENV" value="test" force="true" />
        <server name="SHELL_VERBOSITY" value="-1" />
        <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
</phpunit>

Thanks a lot for your help =)

Aucun commentaire:

Enregistrer un commentaire