0
votes

after the installation of phpunit-bridge with the composer require --dev symfoy/phpunit-bridge, the console send the following information:

*Write test cases in the test/folder
*Run php bin/phpunit

As I have good manners, I followed the rules and execute:

  • php bin/phpunit and I get no test but #!/usr/bin/env php
  • ./bin/phpunit(as sugested in the doc) and I get no test but #!/usr/bin/env php

Can anyone explain me what I am doing wrong ?

as asked I add the content of the PHPUnit.xml.dist file:

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

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="config/bootstrap.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
        <server name="APP_ENV" value="test" force="true" />
        <server name="SHELL_VERBOSITY" value="-1" />
    </php>

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

    <filter>
        <whitelist>
            <directory>src</directory>
        </whitelist>
    </filter>

    <listeners>
        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
    </listeners>
</phpunit>

and my test folder structure:

_ tests  
    |  
    |_ Controller  
        |  
        |_ BlogControllerTest.php 

EDIT :
I've reinstall everything from scratch and if I don't create the phpunit.xml file, I get the -help output of the phpunit command (normal behavior I imagine), So I think that the problem comes from my phpunit configuration.

1
What do you mean by 'I get no test' ? Show us the output, and your tests directory structure, and phpunit.xml filetchap
I add test directory structure and the PHPUnit.xml.dist file to the question. Concerning the output this is what I mean by I get no test. my only output is #!usr/bin/env phpPierrick Rambaud
Your php binary seems ... weird. #!usr/bin/env php is just the first line of the phpunit binary. What is php -v ?tchap
PHP 7.1.12 (cli) (built: Nov 27 2017 15:53:40) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend TechnologiesPierrick Rambaud
Can you try to modify the bin/phpunit file and replace the first line with #!/usr/bin/env php (notice the added slash) ?tchap

1 Answers

0
votes

Now it was realy impossible to continue working on my project without runnig some tests. I'm more experienced with php and find the error. There were a typo in my class definition

use PHPUnit\Framework\WebTestCase;

class BlogControllerTest extends WebTestCase
{
    public function firstTest()
    {
        $this->assertEquals(0,0);
    }
}

by changing it to :

use PHPUnit\Framework\TestCase;

which actually exist make everything just fine. So it was just a typo and saddly no error message was triggered. thx for your time and sorry for my mistake.