PHPUnit tests within docker for WordPress development

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I just want to add
when running on Windows 10

docker run --rm -v $(pwd):/opt --link mysql frozzare/wptest:7.0 vendor/bin/phpunit


you can replace $(pwd), with your plugin's current directory ..
for example

docker run --rm -v --link mysql frozzare/wptest:7.0 vendor/bin/phpunit

kevinflorenzdaus
Автор

Hey man, this video is very awesome! it helps me a lot.
Just a question, how do you test interaction with database without mess up the real dev env database? Is this possible?
Thank for your video!

Cheng
Автор

If you get an error with text

Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.

Use %cd% instead $(pwd) when run test. It should work on Windows

TheGrantalan
Автор

If anyone encountered an error on with this message


Fatal error: Uncaught Error: Class 'PHP_Timer' not found in /opt/vendor/phpunit/phpunit/



The solution is to go to :
composer.json

Edit phpunit , bump up the phpunit version into 5.6.3
Save it and run

composer update

Thats it ..

kevinflorenzdaus
welcome to shbcf.ru