4

I'm trying to make unit tests in Symfony 3 framework. Here are my configurations; Run/Debug Configirations

PHPUnit Preferences

and here is the error that I'm facing.

/Applications/MAMP/bin/php/php7.0.0/bin/php /private/var/folders/w9/cmwlplqx53x3slxkm4c1chx00000gn/T/ide-phpunit.php --bootstrap /Users/muhammetergenc/code/kampweb/phpunit.xml.dist --configuration /Users/muhammetergenc/code/kampweb/phpunit.xml.dist Tests\AppBundle\Controller\PersonTest /Users/muhammetergenc/code/kampweb/tests/AppBundle/Controller/PersonTest.php
Testing started at 3:04 PM ...
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="app/autoload.php">

    <!-- <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
             backupGlobals="false"
             colors="true"
             bootstrap="web/app_test.php">-->
    <php>
        <ini name="error_reporting" value="-1" />
        <server name="KERNEL_DIR" value="app/" />
    </php>

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

    <filter>
        <whitelist>
            <directory>src</directory>
            <exclude>
                <directory>src/*Bundle/Resources</directory>
                <directory>src/*/*Bundle/Resources</directory>
                <directory>src/*/Bundle/*Bundle/Resources</directory>
            </exclude>
        </whitelist>
    </filter>
</phpunit>

Process finished with exit code 255

I do have the same configuration on my other desktop and it works just fine.

3
  • 1
    You have set it to use the XML file as the bootstrap file, it then tries to run the XML as PHP and fails. Commented Apr 4, 2016 at 20:14
  • @JimL wouldn't it be ignored it if wasn't a PHP class that extends the PHPUnit framework though? Commented Apr 4, 2016 at 20:18
  • I unchecked the default bootstrap file option and still getting the same error. @JimL Commented Apr 4, 2016 at 20:21

3 Answers 3

3

Today I had the same error - 255. in my case I hadn't declared CONSTANTS in the setUp method.

I think that you have something similar. Try to find it by using xdebug - it helped me out.

Sign up to request clarification or add additional context in comments.

Comments

1

In my case, It was a php error setting issue.

I set display_startup_errors to "1". and phpunit reported error.

Specifically, in my bootstrap script, I wrote below.

ini_set('display_startup_errors', 1);

And phpunit report my require_once runtime error.

Comments

0

In my case, it was a memory issue.

In the setUp() method I initialize multiple class properties.

The fix for me was defining (override) the tearDown() method to unset the properties after each test.

protected function tearDown(): void
{
    // clean memory
    unset($this->foo);
    unset($this->bar);

    parent::tearDown();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.