Hello,

I'm having an issue configuring phpunit in VS Code. The path to the phpunit.xml file is always set to -c phpunit.xml and the output is always Could not read XML from file "phpunit.xml".

    "php.executablePath": "/usr/local/bin/php",
    "phpunit.phpunit": "/data/sites/html/www/current/vendor/bin/phpunit",
    "phpunit.command": "\"${php}\" ${phpargs} \"${phpunit}\" ${phpunitargs}",
    "phpunit.enableAutomaticRefresh": true,
    "phpunit.postTask": ""

and the output is

"/usr/local/bin/php" -d display_errors=on "/data/sites/html/www/current/vendor/bin/phpunit" -c phpunit.xml --teamcity --colors=never --filter "(^(Specs_Module_Helper_Test::test_getNewFileName(\s.*)?)$)" 

I don't want to remove the ${phpunitargs} from the command cause I want all the args except -c phpunit.xml
I just want the -c phpunit.xml path to correctly point to my phpunit.xml configuration.

My phpunit.xml file is located at ./tests/php/phpunit.xml relative to my working directory.

Any help is greatly appreciated.

Thanks

    dex0id Thank you for the question.

    The path to phpunit.xml should be determined automatically.

    Is it a multi-folder workspace? The workspace root is at /data/sites/html/www/current ?

    Note: the current working directory is set to the directory with phpunit.xml (PHPUnit expects that). We'll add more logging so it's clear what it does.

      JakubMisek
      Yes its multi-folder. /data/sites/html/www/current is the path inside my docker container where php is running. The Testing Explorer right now is picking up on all phpunit.xml files in any /lib or /vendor folder that is within that workspace. But regardless of which package I try and run, or which single test I want to run the output is always -c phpunit.xml.

      also by copying the output when running a test if I put the correct path to phpunit.xml everything runs correctly.

        dex0id Thank you. We may pick-up the wrong folder in this environment. I'll look at that.

        It will be -c phpunit.xml always , because the cwd is changed to the folder with phpunit.xml.

          Am I able to update the cwd property to better map to that file?

            dex0id you don't have to, CWD is set to the phpunit.xml that we have found. You should not even need to set "phpunit.phpunit", "php.executablePath", and "phpunit.command".

            In the OUTPUT / PHP (PHPUnit) - do you see the correct path at the following line?

            Discovered PHPUnit configurations: file:///data/sites/html/www/current/tests/php/phpunit.xml

              Yes the paths to the phpunit.xml files seem to be correct on my local filesystem.

              Discovered PHPUnit configurations:
              file:///Users/me/Sites/site/vendor/Gene/Braintree/extras/lib_vendor/Gene/Braintree/braintree/braintree_php/phpunit.xml.dist,
              file:///Users/me/Sites/site/vendor/quickbooks/v3-php-sdk/src/XSD2PHP/test/phpunit.xml,
              file:///Users/me/Sites/site/vendor/quickbooks/v3-php-sdk/phpunit.xml,
              file:///Users/me/Sites/site/.tests/test-reports/phpunit-junit.xml,
              file:///Users/me/Sites/site/.tests/php/phpunit.xml,
              file:///Users/me/Sites/site/lib/Picqer/Barcode/phpunit.xml,
              file:///Users/me/Sites/site/lib/Ebizmarts/lib/google-sdk/phpunit.xml.dist,
              file:///Users/me/Sites/site/lib/Credis/phpunit.xml,
              file:///Users/me/Sites/site/lib_vendor/Meanbee/RoyalmailPHPLibrary/phpunit.xml,
              file:///Users/me/Sites/site/lib_vendor/Gene/Braintree/braintree/braintree_php/phpunit.xml.dist,

              The local file path to my files on my computer are:

              /Users/me/Sites/site/

              The path to the webroot in my php docker container are

              /data/sites/html/www/current/

              and is volume mounted in docker.

                dex0id Thanks. I'm not sure (yet), why it loads tests under vendor folder. They suppose to be ignored.

                We'll do more testing on OSX.

                  Write a Reply...