Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tfedor opened this issue Nov 15, 2023 · 1 comment
Open

Comments

@tfedor
Copy link

tfedor commented Nov 15, 2023

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
Copy link
Member

mrook commented Feb 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants