Phpunit: Cygwin issue when trying to run phpunit within Yii2 (Windows)

Created on 19 Nov 2016  路  5Comments  路  Source: sebastianbergmann/phpunit

I'm trying to run phpunit within a Yii2 basic installation (following this guide) but whenever I run php vendor/bin/phpunit from the command line I get this output:

Note: I am on Windows 7.

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m "$dir");
        fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phpunit" "$@"

Can anyone advise what the issue is here? I haven't used phpunit before so unsure what is happening.

Most helpful comment

File vendor/bin/phpunit is not PHP script, but shell script.

Remove php from the start and simply run vendor/bin/phpunit.

All 5 comments

File vendor/bin/phpunit is not PHP script, but shell script.

Remove php from the start and simply run vendor/bin/phpunit.

Thank You!

run this : php "vendor/phpunit/phpunit/phpunit"

Hello,
Im trying to run MEQP in magento 1.9.x version , but whenever I run php vendor/bin/phpcs D:xampp\htdocs\projectname --standard=MEQP1 from the command line I get this output:
`dir=$(d=${0%[/\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)

See if we are running in Cygwin by checking for cygpath program

if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir");
fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phpunit" "$@"`

Please check the issues , let me know ur helpful comments .

Just a note for folks on Windows getting this Cygwin problem and trying to generate test file, e.g.:

php vendor/bin/codecept generate:cest acceptance Signin,

or run - as mentioned in this ticket

vendor/phpunit/phpunit/phpunit

and you drop

php ... and it still does not work and you get some error like:

'vendor' is not recognized as an internal or external command,

... try spinning these _darn slashes_ to back-facing, e.g.:

vendor\bin\codecept generate:cest acceptance Signin

and you may get lucky ....

Was this page helpful?
0 / 5 - 0 ratings