为了账号安全,请及时绑定邮箱和手机立即绑定

Symfony 和 PHPUnit 与 Bitbucket 管道

Symfony 和 PHPUnit 与 Bitbucket 管道

PHP
元芳怎么了 2021-10-15 16:08:03
我正在尝试建立一个管道以使用 Bitbucket 自动执行我的测试套件。不幸的是,我对 Docker 和管道完全陌生。我读了这篇文章,经过大量的试验和错误,我想出了这个bitbucket-pipelines.yml配置:image: php:7.2.17pipelines:  default:    - step:        caches:          - composer        script:          - apt-get update && apt-get install -y unzip zlib1g-dev sqlite3 libsqlite3-dev          - docker-php-ext-install zip && docker-php-ext-install pdo_sqlite && docker-php-ext-install pdo_mysql          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer          - composer install          - vendor/bin/simple-phpunit问题是这个配置还是报错:  [RuntimeException]                                                                 An error occurred when executing the "'cache:clear --no-warmup'" command:          In ConnectionFactory.php line 79:                                                    An exception occured while establishing a connection to figure out your pla        tform version.                                                                     You can circumvent this by setting a 'server_version' configuration value          For further information have a look at:                                            https://github.com/doctrine/DoctrineBundle/issues/673                            In AbstractMySQLDriver.php line 93:                                                  An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused       In PDOConnection.php line 31:                                                        SQLSTATE[HY000] [2002] Connection refused                                        In PDOConnection.php line 27:                                                        SQLSTATE[HY000] [2002] Connection refused 为什么要尝试使用 MySQL 进行连接?它不应该只执行测试吗?我不需要运行的项目或可部署的版本,我只需要使用 SQLite 和单元测试执行的测试套件。
查看完整描述

2 回答

?
不负相思意

TA贡献1777条经验 获得超10个赞

Doctrine 尝试猜测您的 MySQL/PostgreSQL 版本。因此,它会在创建适配器时尝试建立与数据库的连接。


可以通过在配置中配置具体版本来规避此行为。


# config.yaml


doctrine:

  dbal:

    # [..]

    server_version: '5.7' # or mariadb-<version> for MariaDB

您可以在文档章节Doctrine DBAL Configuration的配置概述下方的通知中找到有关此“问题”的更多信息。


只需添加server_version到config_test.yaml即可解决您的问题。


查看完整回答
反对 回复 2021-10-15
  • 2 回答
  • 0 关注
  • 292 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信