如何在测试单元测试中使用供应商类? (在测试中通过LaravelLocalization设置Locale)

时间:2015-10-14 08:42:21

标签: php unit-testing phpunit codeception

在单元测试中,我需要在测试之前设置一个语言环境

use Mcamara\LaravelLocalization;
...
class FormatHelperTest extends \Codeception\TestCase\Test
{

protected function _before(){
        LaravelLocalization::setLocale('el');

然而,

PHP Fatal error:  Class 'Mcamara\LaravelLocalization' not found in
/vagrant/project1/tests/unit/FormatHelperTest.php on line 40

如何在单元测试中通过LaravelLocalization设置Locale?

修改

codeception.yml

actor: Tester
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

修改

测试/ _bootstrap.php

<?php
// This is global bootstrap for autoloading

测试/单元/ _boootstrap.php

<?php
// Here you can initialize variables that will be available to your tests

0 个答案:

没有答案
相关问题