Skip to content

Instantly share code, notes, and snippets.

@leavyli
Last active January 6, 2018 11:55
Show Gist options
  • Save leavyli/a3dc174e8415074197d9e4e5d714f1aa to your computer and use it in GitHub Desktop.
Save leavyli/a3dc174e8415074197d9e4e5d714f1aa to your computer and use it in GitHub Desktop.
Yii2:unit:_bootstrap.php:用于单元测试的时候配置命名空间,从而可以加载对应的类
<?php
// add unit testing specific bootstrap code here
$classLoader = new \Composer\Autoload\ClassLoader();
$classLoader->addPsr4("tests\\components\\", __DIR__ . "/components", false);
$classLoader->addPsr4("tests\\models\\", __DIR__ . "/models", false);
$classLoader->register();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment