与Laravel包和Behat持续集成

时间:2016-04-09 12:17:31

标签: php laravel laravel-5 travis-ci behat

我正在为Laravel开发一个包,它实际上需要整个Laravel应用程序来运行我用Behat编写的测试。

我正在使用Travis作为CI服务,我想知道是否存在特定的JPopupMenu配置,以便为我的包创建测试,并使用新创建的Laravel应用程序运行。

基本上我的软件包包含一个控制台命令的特性,如果不安装Laravel本身就无法测试。

我知道我可以通过在.travis.yml中设置install挂钩来安装新的Laravel应用程序,但后来我不知道如何使用该应用程序集成和运行我的测试。

1 个答案:

答案 0 :(得分:3)

I'm gonna share with you my travis config file (I am using Laravel 5.1).

My file works with PHPUnit however just replace the line that runs PHPUnit with your Behat command, everything else is perfect.

.travis.yml

language: php

php:
  - 5.5.9
  - 5.6
  - 7.0
  - hhvm

matrix:
    allow_failures:
        - php: hhvm

before_script:
- cp .env.travis .env
- mysql -e 'create database homestead;'
- composer self-update
- composer install --prefer-source --no-interaction --dev
- php artisan migrate
- php artisan db:seed

script: vendor/bin/phpunit

You must include .env.travis as well, a sample file would look like this:

APP_ENV=testing
APP_DEBUG=true
APP_KEY=xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

you can of course use specific DB_CONNECTION that probably runs with sqlite in memory or so..