Tag: phpunit

PhpStorm只运行本地PHPUnitconfiguration。 如何强制它使用远程(Docker)?

ENV: Ubuntu 16.04 PhpStorm 2017.1 PHPUnit 5.5.4(远程) PhpStorm设置:语言和框架> PHP> PHPUnit 解释器:远程Docker 映射:<project root> – > /var/www/html Docker容器:<project root> – > /var/www/html 使用composer php自动加载器: /var/www/html/vendor/autoload.php (检测PHPUnit版本5.5.4) 默认configuration文件: /var/www/html/tests/phpunit.xml 默认引导文件: /var/www/html/tests/bootstrap.php 我也configuration了本地configuration。 本地configuration指向相同的autoload.php ,config和bootstrap文件。 本地configuration工作正常,但我需要在Docker容器上运行testing。 当我从PhpStorm运行testing,它使用本地configuration,我不知道如何告诉PhpStorm使用远程。 重要的提醒: configuration了远程Docker解释器的XDebug,运行良好。

GitlabCi使用docker和mysql服务缓慢构build

我正在使用gitlab-ci-multirunner 9.3.0和GitLab Community Edition 9.3.5 当我在我的本地虚拟环境中运行我的php-unittesting时,总testing(30)只需要大概: Time: 5 minutes, Memory: 96.00MB 在我的gitlab主机上运行相同的testing,它总共需要 Time: 41.68 minutes, Memory: 97.75MB testing需要mysql,并在每个testing上做一个数据库创build和夹具加载。 我的DockerFile: FROM tetraweb/php:5.6 # Install additional packages RUN apt-get clean && apt-get -qq update RUN apt-get -qq upgrade -y RUN apt-get install -qq -y apt-utils RUN apt-get install -qq -y mysql-client libmagickwand-dev libgeoip-dev -y –no-install-recommends RUN pecl […]

如何在PHP中单击tearDown()mockObjects

我必须在php中testing一个控制器,它使用超过20个模型。 当我试图用预言模型创build模型时,它会失败 致命错误:允许的内存大小用尽 我试图增加php.ini中的memory_limit,它不是解决问题。 我无法find一种方法来清除mockModels将用来解决问题的内存。

如何在主机上访问docker容器内运行的unit testing的xdebug会话?

我有一个PHP应用程序使用hhvm在Docker容器中运行。 我的IDE是在本地主机上运行的phpstorm,我设置了xdebug。 我的/etc/hhvm/php.ini部分看起来像: ; xdebug hhvm.debug.server_error_message = true xdebug.enable=1 xdebug.remote_enable=1 xdebug.idekey="PHPSTORM" xdebug.remote_port = 9999 xdebug.remote_autostart=1 xdebug.remote_connect_back=1 xdebug.remote_handler=dbgp xdebug.remote_log="/var/log/xdebug/xdebug.log" 而在我的nginx conf中,我不得不添加指定服务器名称以匹配我的反向代理。 反向代理在我的本地主机上运行,​​并将容器的IP(例如127.0.0.1:8080映射到可读的http://my_app.local 。 nginx conf条目看起来像这样: cat nginx/conf.d/my_app.conf server { listen 80 default_server; server_name my_app.local; root /var/www/my_app/web; index index.php index.html index.htm; include hhvm.conf; error_log /var/log/nginx/sandbox/error.log; access_log /var/log/nginx/sandbox/access.log main; location /status { return 200; access_log off; } location […]

在Docker容器中,php(unit)不显示错误输出

我认识到这可能是一个PHP的configuration问题,而不是docker或phpunit,但我想清楚不同的移动件。 我有一个docker容器与下面的Dockerfile FROM php:5.6-cli COPY . /spider WORKDIR /spider RUN pecl install xdebug RUN docker-php-ext-enable xdebug RUN curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/bin/ –filename=composer 当我使用( docker run -it my_php bash ) docker run -it my_php bash bash的容器时,我可以validationphp和xdebug是否正确安装。 当我尝试运行vendor/bin/phpunit ,testing开始,遇到一个错误,然后进程简单地死亡,没有错误输出。 失败的testing显示失败并通过testing显示绿色。 以下为什么phpunit不能在控制台中显示任何错误 ,我已经添加了 ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); 到testingbootstrap.php文件中 <ini name="display_errors" […]

拒绝连接:Docker中的PHPUnitselenium

我将这两个容器连接起来(docker-compose.yml): test: container_name: test image: test ports: – "7761:80" links: – webdriver webdriver: container_name: webdriver image: webdriver “testing”包含一个正在运行的symfony网站。 'Webdriver'是一个定制的Ubuntu镜像,Selenium服务器在端口4444上使用ChromeDriver运行。 我在testing容器内的这个文件上运行PHPunit: class SeleniumTest extends PHPUnit_Extensions_Selenium2TestCase { public function setUp() { $this->setHost('webdriver'); $this->setPort(4444); $this->setBrowserUrl('http://localhost:7761'); $this->setBrowser('chrome'); } protected function login() { $this->url('/'); $content = $this->byTag('body')->text(); print $content; #…do tests… } } composer php: "phpunit/phpunit": "~4", "phpunit/phpunit-selenium": "~1" 无论BrowserUrl的价值是什么,我都无法获得连接。 […]

stream明:PHPUnit失败,但testing通过Gitlab CI亚军

这是我第一次在我的项目中使用testing。 我使用Gitlab CI和gitlab runner来执行testing。 但有些奇怪的事情发生时,当phpunit执行输出失败,但在gitlab的testing结果被传递 。 Gitlab应该显示失败的结果。 我使用stream明5.1。 和使用docker工人的Gitlab赛跑者。 这是我的.gitlab-ci.yml文件 image: dragoncapital/comic:1.0.0 stages: – test cache: paths: – vendor/ before_script: – bash .gitlab-ci.sh > /dev/null test:7.0: script: – phpunit 这是我的.gitlab-sh.sh文件 #!/bin/bash # We need to install dependencies only for Docker [[ ! -e /.dockerenv ]] && exit 0 set -xe composer install cp .env.testing .env […]

在带有PhpStorm的Docker容器中运行PHPUnit

我想configuration我的PhpStorm IDE以在我的Docker容器中运行PHPUnittesting。 似乎我只能使用本地PHP可执行文件,或通过SSH作为testing的解释器。 我可以在我的PHP容器上安装一个SSH服务,但这看起来有点像一个黑客解决scheme,在线文章阻止在容器上安装SSH服务。 为了尝试让本地解释器工作,我尝试创build一个bash脚本来代理对容器中的PHP调用,如下所示: #!/usr/bin/env bash # Run PHP through Docker docker exec -t mycontainer_php_1 php "$@" 当我自己运行它时,这是完美的,但是当我将PhpStorm指向本地PHP解释器时,它不会将其识别为有效的PHP可执行文件。 那么获得这个工作的好方法是什么?

PHPUnit覆盖:允许内存大小536870912字节用尽

我试图用PHPUnit和phpdbg使用下面的命令为我的PHP项目生成代码testing覆盖: phpdbg -dmemory_limit=512M -qrr ./bin/phpunit -c .phpunit.cover.xml 这工作得很好: PHPUnit 6.2.4 by Sebastian Bergmann and contributors. …….. 8 / 8 (100%) Time: 114 ms, Memory: 14.00MB OK (8 tests, 13 assertions) Generating code coverage report in HTML format … done 但是,当我在docker容器中使用完全相同的命令时: docker run -it –name YM4UPltmiPMjObaVULwsIPIkPL2bGL0T -e USER=sasan -v "/home/sasan/Project/phpredmin:/phpredmin" -w "/phpredmin" –user "1000:www-data" php:7.0-apache phpdbg […]

PHPUnit Seleniumtesting在Docker本地主机上失败,并使用公共IP传递

我正在尝试使用Docker和Selenium Grid来设置自动testing平台。 在下面的图中,您可以看到我正在使用的结构。 最上面是在Compute Engine上运行的Ubuntu服务器。 左边是一个运行Ubuntu 14.04的docker容器。 容器使用Google App Engine在localhost:8080上运行我们的项目。 在右边是Selenium Hub,两个节点在4444端口上运行。 从主机到docker以及selenium轮毂都有前进的动力。 分别在32772和32768。 在运行我的Seleniumtesting时,我将它们发送到集线器,集线器依次运行docker本地主机上的testing。 我的问题是,当我告诉集线器在172.17.0.2:8080上运行testing时,它会打开启动屏幕,但不能提交任何表单。 当我提交表格的文本区域被清除。 就像页面以某种方式刷新一样。 奇怪的是,当我告诉集线器使用主机的外部IP和docker的端口像这个xx.xx.xx.xx:32772,它的工作。 它具有所有的function。 但是出于性能和自动化的原因,我想在内部的IP地址上运行它。 任何帮助,将不胜感激。 Tijn