简体   繁体   中英

Continuous integration with Laravel package and Behat

I'm developing a package for Laravel which actually needs the whole Laravel application to run the tests I wrote with Behat.

I'm using Travis as a CI service and I wonder if there is a specific .travis.yml configuration to let the tests created for my package run with a newly created Laravel application.

Basically my package consists in a trait for console commands that cannot be tested without installing Laravel itself.

I know I can install a new Laravel application by setting the install hook in .travis.yml but then I don't know how to integrate and run my tests with the app.

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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM