Codeception: Laravel5 doesn't load configured `environment_file`

What are you trying to achieve?

Load in a testing env file when using the Laravel5 module.

What do you get instead?

Only the normal env file is loaded. If we update the bootstrap/app.php from Laravel with a check for testing and force a load of the testing env file things work as expected.

Details

  • Codeception version: 2.2.4
  • PHP Version: 7.0.10
  • Operating System: OSX and Ubuntu
  • Installation type: Composer
  • List of installed packages
atyagi/elasticache-laravel            2.1.0                          Elasticache Drivers for Laravel Cache and Session
aws/aws-sdk-php                       3.18.20                        AWS SDK for PHP - Use Amazon Web Services in your PHP project
barryvdh/laravel-ide-helper           v2.2.0                         Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
barryvdh/reflection-docblock          v2.0.4
behat/gherkin                         v4.4.1                         Gherkin DSL parser for PHP 5.3
bosnadev/database                     0.12                           Eloquent Extended, added some PostgreSql features
classpreloader/classpreloader         3.0.0                          Helps class loading performance by generating a single PHP file containing all of the autoloaded files fo...
cocur/slugify                         v2.1.1                         Converts a string into a slug.
codeception/c3                        2.0.6                          CodeCoverage collector for Codeception
codeception/codeception               2.2.4                          BDD-style testing framework
cviebrock/eloquent-sluggable          dev-master 37308ff             Easy creation of slugs for your Eloquent models in Laravel
danielstjules/stringy                 1.10.0                         A string manipulation library with multibyte support
davejamesmiller/laravel-breadcrumbs   3.0.0                          A simple Laravel-style way to create breadcrumbs in Laravel 4+.
dnoegel/php-xdg-base-dir              0.1                            implementation of xdg base directory specification for php
doctrine/annotations                  v1.2.7                         Docblock Annotations Parser
doctrine/cache                        v1.6.0                         Caching library offering an object-oriented API for many cache backends
doctrine/collections                  v1.3.0                         Collections Abstraction library
doctrine/common                       v2.5.3                         Common Library for Doctrine projects
doctrine/dbal                         v2.5.2                         Database Abstraction Layer
doctrine/inflector                    v1.1.0                         Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                 1.0.5                          A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                        v1.0.1                         Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
espadav8/closure-table                v5.1.4                         Adjacency List’ed Closure Table database design pattern implementation for Laravel
facebook/webdriver                    1.1.2                          A PHP client for WebDriver
fzaninotto/faker                      v1.6.0                         Faker is a PHP library that generates fake data for you.
guzzlehttp/guzzle                     6.2.0                          Guzzle is a PHP HTTP client library
guzzlehttp/promises                   1.2.0                          Guzzle promises library
guzzlehttp/psr7                       1.3.0                          PSR-7 message implementation
hamcrest/hamcrest-php                 v1.2.2                         This is the PHP port of Hamcrest Matchers
intellihr/laravel-validators          0.1.3                          Laravel extra validators
ircmaxell/random-lib                  v1.1.0                         A Library For Generating Secure Random Numbers
ircmaxell/security-lib                1.0.0                          A Base Security Library
itsgoingd/clockwork                   v1.12                          Server-side component of Clockwork, a Chrome extension for PHP development
jakub-onderka/php-console-color       0.1
jakub-onderka/php-console-highlighter v0.3.2
jeremeamia/SuperClosure               2.2.0                          Serialize Closure objects, including their context and binding
laracasts/generators                  1.1.3                          Extend Laravel 5's generators.
laravel/framework                     v5.1.35                        The Laravel Framework.
laravelcollective/html                v5.1.9
league/csv                            8.1.0                          Csv data manipulation made easy in PHP
league/flysystem                      1.0.24                         Filesystem abstraction: Many filesystems, one API.
league/flysystem-aws-s3-v3            1.0.13                         Flysystem adapter for the AWS S3 SDK v3.x
league/fractal                        0.13.0                         Handle the output of complex data structures ready for API output.
league/statsd                         1.4.0                          A simple library for working with StatsD in PHP.
mockery/mockery                       0.9.5                          Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec ...
monolog/monolog                       1.19.0                         Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/cron-expression             v1.1.0                         CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
mtdowling/jmespath.php                2.3.0                          Declaratively specify how to extract elements from a JSON document
mustangostang/spyc                    0.5.1                          A simple YAML loader/dumper class for PHP
nesbot/carbon                         1.21.0                         A simple API extension for DateTime.
nikic/php-parser                      v2.1.0                         A PHP parser written in PHP
pacuna/schemas                        dev-master be17b7f             Laravel package for managing postgresql schemas
paragonie/random_compat               v1.4.1                         PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
pdepend/pdepend                       2.2.4                          Official version of pdepend to be handled with Composer
phpdocumentor/reflection-common       1.0                            Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock     3.1.0                          With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve in...
phpdocumentor/type-resolver           0.2
phpmd/phpmd                           2.4.3                          PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.
phpspec/php-diff                      v1.0.2                         A comprehensive library for generating differences between two hashable objects (strings or arrays).
phpspec/phpspec                       2.5.0                          Specification-oriented BDD framework for PHP 5.3+
phpspec/prophecy                      v1.6.1                         Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage             2.2.4                          Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator             1.4.1                          FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template             1.2.1                          Simple template engine.
phpunit/php-timer                     1.0.8                          Utility class for timing
phpunit/php-token-stream              1.4.8                          Wrapper around PHP's tokenizer extension.
phpunit/phpunit                       4.8.26                         The PHP Unit Testing framework.
phpunit/phpunit-mock-objects          2.3.8                          Mock Object library for PHPUnit
piwik/device-detector                 3.7.0                          The Universal Device Detection library, that parses User Agents and detects devices (desktop, tablet, mob...
psr/http-message                      1.0                            Common interface for HTTP messages
psr/log                               1.0.0                          Common interface for logging libraries
psy/psysh                             v0.7.2                         An interactive shell for modern PHP.
ramsey/uuid                           2.9.0                          A PHP 5.3+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).
sbarre/eloquent-versioned             dev-feature/merged-prs f6ad876 Add transparent versioning to Laravel 5's Eloquent ORM
sebastian/comparator                  1.2.0                          Provides the functionality to compare PHP values for equality
sebastian/diff                        1.4.1                          Diff implementation
sebastian/environment                 1.3.7                          Provides functionality to handle HHVM/PHP environments
sebastian/exporter                    1.2.2                          Provides the functionality to export PHP variables for visualization
sebastian/finder-facade               1.2.1                          FinderFacade is a convenience wrapper for Symfony's Finder component.
sebastian/global-state                1.1.1                          Snapshotting of global state
sebastian/phpcpd                      2.0.4                          Copy/Paste Detector (CPD) for PHP code.
sebastian/recursion-context           1.0.2                          Provides functionality to recursively process PHP variables
sebastian/version                     1.0.6                          Library that helps with managing the version number of Git-hosted PHP projects
squizlabs/php_codesniffer             2.6.1                          PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding...
swiftmailer/swiftmailer               v5.4.2                         Swiftmailer, free feature-rich PHP mailer
symfony/browser-kit                   v2.8.7                         Symfony BrowserKit Component
symfony/class-loader                  v3.1.1                         Symfony ClassLoader Component
symfony/config                        v3.1.1                         Symfony Config Component
symfony/console                       v2.7.14                        Symfony Console Component
symfony/css-selector                  v2.7.14                        Symfony CssSelector Component
symfony/debug                         v2.7.14                        Symfony Debug Component
symfony/dependency-injection          v3.1.1                         Symfony DependencyInjection Component
symfony/dom-crawler                   v2.7.14                        Symfony DomCrawler Component
symfony/event-dispatcher              v2.8.7                         Symfony EventDispatcher Component
symfony/filesystem                    v3.1.1                         Symfony Filesystem Component
symfony/finder                        v2.7.14                        Symfony Finder Component
symfony/http-foundation               v2.7.14                        Symfony HttpFoundation Component
symfony/http-kernel                   v2.7.14                        Symfony HttpKernel Component
symfony/polyfill-mbstring             v1.2.0                         Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                v1.2.0                         Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-util                 v1.2.0                         Symfony utilities for portability of PHP codes
symfony/process                       v2.7.14                        Symfony Process Component
symfony/routing                       v2.7.14                        Symfony Routing Component
symfony/translation                   v2.7.14                        Symfony Translation Component
symfony/var-dumper                    v2.7.14                        Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                          v2.8.7                         Symfony Yaml Component
theseer/fdomdocument                  1.6.1                          The classes contained within this repository extend the standard DOM to use exceptions at all occasions o...
venturecraft/revisionable             1.27.0                         Keep a revision history for your models without thinking, created as a package for use with Laravel
vlucas/phpdotenv                      v1.1.1                         Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
webmozart/assert                      1.0.2                          Assertions to validate method input/output with nice error messages.
  • Suite configuration:
class_name: UnitTester
modules:
    enabled:
        - Asserts
        - \Helper\Unit
        - Laravel5:
            environment_file: .env.testing

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (12 by maintainers)

Most upvoted comments

If my previous comment does not work you can also try

class_name: CustomNameTester
modules:
    enabled:
        - \Helper\CustomName
        - Laravel5:
            environment_file: .env.testing
        - REST:
            depends: Laravel5

As for retrieving environment variables, try using getenv.

I could not figure out any differences so I rolled back everything and started again. It is functioning now, but I am not sure what fixed it. I will research more and inform you if I find anything.

One more question though along the same lines. Even on a brand new laravel project with codeception being first step, I cannot get run_database_migrations option to work. I didn’t see any issues listed. Is there more to this than simply adding the option in the config. Below is my config

# Codeception Test Suite Configuration
#
# Suite for functional (integration) tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it

class_name: FunctionalTester
modules:
    enabled:
        - Laravel5:
            environment_file: .env.testing
            run_database_migrations: true
        - \Helper\Functional