phingofficial / phing

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.
https://www.phing.info
GNU Lesser General Public License v3.0
1.16k stars 319 forks source link

PhpUnit task fails, while calling phpunit directly or via ExecTask succeeds #1766

Open tfedor opened 11 months ago

tfedor commented 11 months ago

Describe the bug I have few tests that handle utf8 strings. When I run phpunit from IDE, or from command like ./vendor/bin/phpunit tests, tests succeeds.

If I run it via phing, the tests will fail. I'm not sure if encoding is the issue, but it looks like it - when I add echo to the testcase, it prints incorrectly when called from phing.

Steps To Reproduce Minimal test case:

public function testMinimal(): void {
        $input = "○ △ □";

        $result = $input;
        $result = (string)preg_replace("#[^-_a-z\d]+#", "-", $result);
        $result = (string)preg_replace("#^[\s-]+|[\s-]+$#", "", $result);

        $this->assertEquals("", $result);
    }

Phing tasks:

    <target name="tests">
        <phpunit haltondefect="true" haltonrisky="true" haltonwarning="true">
            <formatter type="summary" />
            <batchtest>
                <fileset dir="tests">
                    <include name="**/*Test.php"/>
                </fileset>
            </batchtest>
        </phpunit>
    </target>

    <target name="tests2">
        <exec executable="vendor/bin/phpunit" passthru="true" checkreturn="true">
            <arg value="tests" />
        </exec>
    </target>

When run, target tests fails with

Test(s) failed: Test FAILURE (testMinimal in class [...]phpunit\src\Framework\Constraint\Equality\IsEqual.php on line 96): Failed asserting that two strings are equal.

--- Expected
+++ Actual
@@ @@
-''
+''

While target tests2 succeeds.

Expected behavior PhpUnit task should behave in the same way as if it was run directly from command line

Additional context Add any other context about the problem here. Windows, PHP 8.1.9, PHPUnit 9.5, Phing 3.0 RC6

mrook commented 8 months ago

I can't reproduce this unfortunately. PHP 8.3.1 on a Mac. I don't have access to a Windows environment.