This commit is contained in:
Alone
2024-09-14 15:10:43 +08:00
parent 6c64bbd82a
commit 610dee88cd
4241 changed files with 0 additions and 622695 deletions
-49
View File
@@ -1,49 +0,0 @@
<?php
namespace think\tests;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use think\Cache;
use think\cache\Driver;
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);
$store = m::mock(Driver::class);
$config->shouldReceive('get')->with('database.cache_store', null)->andReturn(null);
$cache->shouldReceive('store')->with(null)->andReturn($store);
$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');
}
}