Symfony 和 PHPUnit 与 Bitbucket 管道

我正在尝试建立一个管道以使用 Bitbucket 自动执行我的测试套件。


不幸的是,我对 Docker 和管道完全陌生。我读了这篇文章,经过大量的试验和错误,我想出了这个bitbucket-pipelines.yml配置:


image: php:7.2.17


pipelines:

  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 和单元测试执行的测试套件。


元芳怎么了
浏览 293回答 2
2回答

不负相思意

Doctrine 尝试猜测您的 MySQL/PostgreSQL 版本。因此,它会在创建适配器时尝试建立与数据库的连接。可以通过在配置中配置具体版本来规避此行为。# config.yamldoctrine:&nbsp; dbal:&nbsp; &nbsp; # [..]&nbsp; &nbsp; server_version: '5.7' # or mariadb-<version> for MariaDB您可以在文档章节Doctrine DBAL Configuration的配置概述下方的通知中找到有关此“问题”的更多信息。只需添加server_version到config_test.yaml即可解决您的问题。
打开App,查看更多内容
随时随地看视频慕课网APP