For testing I need to use another database than in a local
environment.
I use homestead and Laravel 5.2 + Behat3 + Mink in my development flow.
When I run behat from host machine than it's OK - variable is setting up to APP_ENV=testing
.
But I have a trouble with setting testing
environment when do the same inside homestead machine: the APP_ENV
is always local
.
For testing environment (APP_ENV
) I modified standard welcome.blade.php
next way:
- <div class="title">Laravel 5</div>
+ <div class="title">Laravel 5 ({!! app()->environment() !!})</div>
I've configured behat.yml
:
default:
extensions:
Laracasts\Behat:
env_path: .env.behat
Behat\MinkExtension:
default_session: laravel
laravel: ~
My testing environment variables in .env.behat
:
APP_ENV=testing
APP_DEBUG=true
DB_CONNECTION=sqlite
I made my home.feature:
Feature: Check home page
In order to verify home page
As a user
I need to see text Laravel and an environment name
@home
Scenario: Home Page
Given I am on the homepage
Then I should see "Laravel 5 (testing)"
So when I run behat I see Laravel 5 (local)
but not a Laravel 5 (testing)
text:
Feature: Check home page
In order to verify home page
As a user
I need to see Laravel text
@home
Scenario: Home Page # features/home.feature:7
Given I am on the homepage # FeatureContext::iAmOnHomepage()
Then I should see "Laravel 5 (testing)" # FeatureContext::assertPageContainsText()
The text "Laravel 5 (testing)" was not found anywhere in the text of the current page. (Behat\Mink\Exception\ResponseTextException)
--- Failed scenarios:
features/home.feature:7
1 scenario (1 failed)
What I missed in configuration or what I should know about custom setup Laravel configuration?
I don't know if it's the case, but make sure in your Homestead.yaml
you don't have:
variables:
- key: APP_ENV
value: local
If you do, remove it and then you can try provision your VM, but it's quite possible you will need to destroy it (you should first backup everything for example database etc.) and create again after removing this from file.