mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
单元测试改进
This commit is contained in:
@@ -195,7 +195,7 @@ EOF;
|
|||||||
'username' => 'chunice',
|
'username' => 'chunice',
|
||||||
'password' => md5('chunice'),
|
'password' => md5('chunice'),
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'create_time' => time()
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
$result = Db::connect($config)->name('user')->insert($data);
|
$result = Db::connect($config)->name('user')->insert($data);
|
||||||
$this->assertEquals(1, $result);
|
$this->assertEquals(1, $result);
|
||||||
@@ -208,7 +208,7 @@ EOF;
|
|||||||
'username' => 'chunice_update',
|
'username' => 'chunice_update',
|
||||||
'password' => md5('chunice'),
|
'password' => md5('chunice'),
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'create_time' => time()
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
$result = Db::connect($config)->name('user')->where('username', 'chunice')->update($data);
|
$result = Db::connect($config)->name('user')->where('username', 'chunice')->update($data);
|
||||||
$this->assertEquals(1, $result);
|
$this->assertEquals(1, $result);
|
||||||
@@ -229,7 +229,7 @@ EOF;
|
|||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
['username' => 'foo', 'password' => md5('foo'), 'status' => 1, 'create_time' => time()],
|
['username' => 'foo', 'password' => md5('foo'), 'status' => 1, 'create_time' => time()],
|
||||||
['username' => 'bar', 'password' => md5('bar'), 'status' => 1, 'create_time' => time()]
|
['username' => 'bar', 'password' => md5('bar'), 'status' => 1, 'create_time' => time()],
|
||||||
];
|
];
|
||||||
|
|
||||||
$insertNum = Db::connect($config)->name('user')->insertAll($data);
|
$insertNum = Db::connect($config)->name('user')->insertAll($data);
|
||||||
@@ -273,7 +273,7 @@ EOF;
|
|||||||
'username' => uniqid(),
|
'username' => uniqid(),
|
||||||
'password' => md5('chunice'),
|
'password' => md5('chunice'),
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'create_time' => time()
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
$lastId = Db::connect($config)->name('user')->insertGetId($data);
|
$lastId = Db::connect($config)->name('user')->insertGetId($data);
|
||||||
$this->assertEquals($id + 1, $lastId);
|
$this->assertEquals($id + 1, $lastId);
|
||||||
@@ -287,7 +287,7 @@ EOF;
|
|||||||
'username' => uniqid(),
|
'username' => uniqid(),
|
||||||
'password' => md5('chunice'),
|
'password' => md5('chunice'),
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'create_time' => time()
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
$lastId = Db::connect($config)->name('user')->insertGetId($data);
|
$lastId = Db::connect($config)->name('user')->insertGetId($data);
|
||||||
|
|
||||||
@@ -341,12 +341,12 @@ EOF;
|
|||||||
public function testCache()
|
public function testCache()
|
||||||
{
|
{
|
||||||
$config = $this->getConfig();
|
$config = $this->getConfig();
|
||||||
$result = Db::connect($config)->name('user')->where('id', 1)->cache('key', 60)->select();
|
$result = Db::connect($config)->name('user')->where('id', 1)->cache('key', 60)->find();
|
||||||
$cache = \think\Cache::get('key');
|
$cache = \think\Cache::get('key');
|
||||||
$this->assertEquals($result, $cache);
|
$this->assertEquals($result, $cache);
|
||||||
|
|
||||||
$updateCache = Db::connect($config)->name('user')->cache('key')->find(2);
|
$updateCache = Db::connect($config)->name('user')->cache('key')->find(1);
|
||||||
$this->assertNotEquals($cache, $updateCache);
|
$this->assertEquals($cache, $updateCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user