问题描述:

FeatureContext.php

/**

* @Then I can do something with Laravel

*/

public function iCanDoSomethingWithLaravel()

{

PHPUnit::assertEquals('.env.behat', app()->environmentFile());

PHPUnit::assertEquals('acceptance', env('APP_ENV'));

}

Console output after running behat

Scenario: Dashboard is locked to guests

 And I can do something with Laravel # FeatureContext::iCanDoSomethingWithLaravel()

Failed asserting that two strings are equal.

--- Expected

+++ Actual

@@ @@

-'acceptance'

+'local'

behat.yml

default:

extensions:

Laracasts\Behat:

env_path: .env.behat

Laracasts\Behat\ServiceContainer\BehatExtension: ~

Behat\MinkExtension\ServiceContainer\MinkExtension:

default_session: laravel

laravel: ~

.env

APP_ENV=local

APP_DEBUG=true

.env.behat

APP_ENV=acceptance

APP_DEBUG=true

网友答案:

If you are using Laravel Homestead, the issue isn't with it reading the .env file, more that it is reading it from the default APP_ENV set in your homestead.yaml file. Take the APP_ENV variable out of your homestead.yaml file and then re-provision your homestead box and it should work fine.

These are the offending lines in your homestead.yaml:

- key: APP_ENV
  value: local

I have literally just encountered the same issue and this is what fixed it for me.

相关阅读:
Top