What is:
Docker-container with PHP and a set of unit tests. You can run the container, and inside through the console to run any tests -
phpunit /test/test_1.phpPhpStorm 9 Host Machine
folder with the project, where are the unit tests. This folder is linked to the docker container.
Problem:
PhpStorm conveniently manages tests, and allows you to run local or remote tests (via SSH). But I don’t know how to work with the docker, I’m not able to explain the IDE how to run the docker tests.
What do you need:
How to tune the docker or PhpStorm, so that you can run tests through the GUI.
Additions:
on ssh works now, but I would like to do without it.
I tried to create a bash script that proxies all requests to the container. Here is such a
docker run --rm php:cli php $@script -docker run --rm php:cli php $@. Thus, thephp -vcommand started from the host machine starts working. But tests use file arguments. Complicated the bash script:#!/bin/sh args='' for arg do if [ -f $arg ]; then arg=/mnt$( realpath $arg ) fi args="$args $arg" done env > /tmp/docker-env sed -is/idekey=.*/idekey=PHPSTORM/ /tmp/docker-env docker run -e "PHP_IDE_CONFIG=serverName=phpunit-docker" \ --net=host --env-file /tmp/docker-env --rm \ -v /:/mnt -v /var/www:/var/www app php $argsThis solves several problems.
- You can create php.sh with this code, and put it in any place, for example in / usr / local / bin, and treat it like a real php
- phpstorm calling tests creates /tmp/ide-phpunit.php which accepts env variables that are configured in the ide itself, so I use / tmp / docker-env
- setting - net = host solves all problems with the network, for example, nslookup used to fail with an error
This does not solve the problem.
- explicitly specifying idekey = PHPSTORM and PHP_IDE_CONFIG
But still PHPUnit tests do not run, swears composer
PHP Fatal error: Cannot redeclare composerRequire7a368ac394ae1d2e857becf2a235ebaa () (previously read in [APP_ROOT] /vendor/composer/autoload_real.php:56) in [APP_ROOT] /vendor/composer/autolodentoff
I suspect that this happens because /tmp/ide-phpunit.php calls composer / autoload to find phpunit, and when running, the tests also run the same