I test my laravel5 application using codeception and because I need a user for most of my unit tests I tried to create one in my unit/_bootstrap.php
file:
$user = \App\User::register($credentials);
But it seems like this file is not getting loaded into my tests since I cant access the $user
variable. The test always fails with the following error:
[PHPUnit_Framework_Exception] Undefined variable: user
I use the default codeception configuration and just added the laravel5 module. Also I know for sure that the bootstrap file gets executed since I can break the tests by throwing an exception in there.
unit.suit.yml:
class_name: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
- Laravel5:
enviroment_file: .env.testing
codeception.yml
actor: Tester
coverage:
enabled: true
include:
- app/Services/*
- app/Http/*
- app/Token.php
- app/User.php
exclude:
- app/Http/routes.php
- app/Http/Kernel.php
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql