debug = $debug; // 兼容高版本的PHPUnit if (!class_exists('PHPUnit_Framework_TestCase')) { class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase { } } //日记纪录 - Explorer if (!$isRelease) { \PhalApi\DI()->logger = new ExplorerLogger( Logger::LOG_LEVEL_DEBUG | Logger::LOG_LEVEL_INFO | Logger::LOG_LEVEL_ERROR); } $di->config = new FileConfig(dirname(__FILE__) . '/config'); // 数据操作 - 基于NotORM $di->notorm = new NotORMDatabase($di->config->get('dbs'), $di->debug); $di->cache = new \PhalApi\Cache\FileCache(array('path' => dirname(__FILE__) . '/runtime')); class TestFilter extends \Base\Common\Filter { protected function checkNamespace() { // 管理员允许调用Admin服务 } } $di->filter = new TestFilter(); // 导入数据库 if (empty($_ENV['not_sql'])) { echo "正在重建数据库……\n"; $sqlFile = API_ROOT . '/data/phalapi_pro.sql'; $sqlContent = file_get_contents($sqlFile); $sqlArr = explode(";\n", $sqlContent); foreach ($sqlArr as $sql) { $sql = trim($sql); if (empty($sqlArr)) { continue; } // echo $sql, PHP_EOL; \PhalApi\DI()->notorm->demo->executeSql($sql); } }