无法在代码中从_bootstrap.php访问变量

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

I don't see any error here. If you use variable $user inside class, you should then add global $user; and then use this variable because it will be a global variable.

However using global variables is not a best solution. It's probably better add new base class for example BaseCest and extend it in your test classes and then in your BaseClass you can define such variable in _before method.