В настоящее время я разрабатываю REST Api с использованием Symfony 4.2 и развертываю с помощью Docker (php-fpm
).
При попытке запустить тесты с phpunit во встроенном контейнере (настройка для ci)потерпеть неудачу, выдав следующий вывод:
$ docker run api:latest bin/phpunit
PHP Warning: require(/srv/api/bin/.phpunit/phpunit-6.5/vendor/composer/../symfony/phpunit-bridge/bootstrap.php): failed to open stream: No such file or directory in /srv/api/bin/.phpunit/phpunit-6.5/vendor/composer/autoload_real.php on line 66
PHP Stack trace:
PHP 1. {main}() /srv/api/bin/phpunit:0
PHP 2. require() /srv/api/bin/phpunit:19
PHP 3. include() /srv/api/vendor/symfony/phpunit-bridge/bin/simple-phpunit:244
PHP 4. require() /srv/api/bin/.phpunit/phpunit-6.5/phpunit:4
PHP 5. ComposerAutoloaderInitfa3eadee0e53d49c951bc803cfc74f21::getLoader() /srv/api/bin/.phpunit/phpunit-6.5/vendor/autoload.php:7
PHP 6. composerRequirefa3eadee0e53d49c951bc803cfc74f21() /srv/api/bin/.phpunit/phpunit-6.5/vendor/composer/autoload_real.php:56
PHP Fatal error: require(): Failed opening required '/srv/api/bin/.phpunit/phpunit-6.5/vendor/composer/../symfony/phpunit-bridge/bootstrap.php' (include_path='.:/usr/local/lib/php') in /srv/api/bin/.phpunit/phpunit-6.5/vendor/composer/autoload_real.php on line 66
PHP Stack trace:
PHP 1. {main}() /srv/api/bin/phpunit:0
PHP 2. require() /srv/api/bin/phpunit:19
PHP 3. include() /srv/api/vendor/symfony/phpunit-bridge/bin/simple-phpunit:244
PHP 4. require() /srv/api/bin/.phpunit/phpunit-6.5/phpunit:4
PHP 5. ComposerAutoloaderInitfa3eadee0e53d49c951bc803cfc74f21::getLoader() /srv/api/bin/.phpunit/phpunit-6.5/vendor/autoload.php:7
PHP 6. composerRequirefa3eadee0e53d49c951bc803cfc74f21() /srv/api/bin/.phpunit/phpunit-6.5/vendor/composer/autoload_real.php:56
Composer устанавливает все необходимые пакеты, включая dev-пакеты.Это выходные данные композитора:
Package operations: 94 installs, 0 updates, 0 removals
[...]
You are using the deprecated option "dev". Dev packages are installed by default now.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Prefetching 10 packages � �
- Downloading (100%)
Package operations: 10 installs, 0 updates, 0 removals
- Installing doctrine/data-fixtures (v1.3.1): Loading from cache
- Installing doctrine/doctrine-fixtures-bundle (3.1.0): Loading from cache
- Installing symfony/process (v4.2.3): Loading from cache
- Installing symfony/polyfill-php72 (v1.10.0): Loading from cache
- Installing php-cs-fixer/diff (v1.3.0): Loading from cache
- Installing composer/xdebug-handler (1.3.2): Loading from cache
- Installing composer/semver (1.4.2): Loading from cache
- Installing friendsofphp/php-cs-fixer (v2.14.2): Loading from cache
- Installing fzaninotto/faker (v1.8.0): Loading from cache
- Installing symfony/phpunit-bridge (v4.2.3): Loading from cache
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [OK]
Executing script assets:install public [OK]
Generated autoload files containing 50 classes
Файлы, указанные в сообщении об ошибке, существуют:
$ ls -al vendor/composer/../symfony/phpunit-bridge
total 88
drwxr-xr-x 6 root root 4096 Feb 21 12:59 .
drwxr-xr-x 1 root root 4096 Feb 21 12:59 ..
-rw-r--r-- 1 root root 34 Feb 21 12:59 .gitignore
-rw-r--r-- 1 root root 1296 Feb 21 12:59 CHANGELOG.md
-rw-r--r-- 1 root root 2687 Feb 21 12:59 ClockMock.php
-rw-r--r-- 1 root root 868 Feb 21 12:59 CoverageListener.php
-rw-r--r-- 1 root root 13954 Feb 21 12:59 DeprecationErrorHandler.php
-rw-r--r-- 1 root root 6013 Feb 21 12:59 DnsMock.php
-rw-r--r-- 1 root root 1065 Feb 21 12:59 LICENSE
drwxrwxrwx 2 root root 4096 Feb 21 12:59 Legacy
-rw-r--r-- 1 root root 500 Feb 21 12:59 README.md
-rw-r--r-- 1 root root 896 Feb 21 12:59 SymfonyTestsListener.php
drwxrwxrwx 4 root root 4096 Feb 21 12:59 Tests
drwxrwxrwx 2 root root 4096 Feb 21 12:59 TextUI
drwxrwxrwx 2 root root 4096 Feb 21 12:59 bin
-rw-r--r-- 1 root root 1330 Feb 21 12:59 bootstrap.php # <-----
-rw-r--r-- 1 root root 1400 Feb 21 12:59 composer.json
-rw-r--r-- 1 root root 914 Feb 21 12:59 phpunit.xml.dist
$ ls -al bin/.phpunit/phpunit-6.5/vendor/composer
total 268
drwxr-xr-x 2 root root 4096 Feb 10 12:03 .
drwxr-xr-x 14 root root 4096 Feb 10 12:03 ..
-rwxr-xr-x 1 root root 13459 Feb 10 12:03 ClassLoader.php
-rwxr-xr-x 1 root root 1070 Feb 10 12:03 LICENSE
-rwxr-xr-x 1 root root 83087 Feb 10 12:03 autoload_classmap.php
-rwxr-xr-x 1 root root 440 Feb 10 12:03 autoload_files.php
-rwxr-xr-x 1 root root 214 Feb 10 12:03 autoload_namespaces.php
-rwxr-xr-x 1 root root 765 Feb 10 12:03 autoload_psr4.php
-rwxr-xr-x 1 root root 2414 Feb 10 12:03 autoload_real.php # <-----
-rwxr-xr-x 1 root root 93179 Feb 10 12:03 autoload_static.php
-rwxr-xr-x 1 root root 48783 Feb 10 12:03 installed.json
При выполнении тестов в моей (windows) среде разработки (где src/
каталог монтируется на srv/api/
, выполняется через docker-compose exec php bin/phpunit
), все работает как положено.
РЕДАКТИРОВАТЬ:
# Run from where i ran ls -al vendor/composer/../symfony/phpunit-bridge
$ pwd
/srv/api
$ ls -la /srv
total 12
drwxr-xr-x 1 root root 4096 Feb 21 13:16 .
drwxr-xr-x 1 root root 4096 Feb 21 13:17 ..
drwxr-xr-x 1 root root 4096 Feb 21 13:17 api