初始化代码

This commit is contained in:
2025-12-22 14:34:25 +08:00
parent c2c5ae2fdd
commit a77dbc743f
1510 changed files with 213008 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace think\tests;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use think\Cache;
use think\Config;
use think\Db;
use think\Event;
use think\Log;
class DbTest extends TestCase
{
protected function tearDown(): void
{
m::close();
}
public function testMake()
{
$event = m::mock(Event::class);
$config = m::mock(Config::class);
$log = m::mock(Log::class);
$cache = m::mock(Cache::class);
$db = Db::__make($event, $config, $log, $cache);
$config->shouldReceive('get')->with('database.foo', null)->andReturn('foo');
$this->assertEquals('foo', $db->getConfig('foo'));
$config->shouldReceive('get')->with('database', [])->andReturn([]);
$this->assertEquals([], $db->getConfig());
$callback = function () {
};
$event->shouldReceive('listen')->with('db.some', $callback);
$db->event('some', $callback);
$event->shouldReceive('trigger')->with('db.some', null, false);
$db->trigger('some');
}
}