From 509905bbe4f4d2c96913fa3359cd2cf1ff2122dd Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 31 Jan 2017 16:20:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E6=94=B9?= =?UTF-8?q?=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/dbTest.php | 52 ++++++++++++------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/thinkphp/library/think/dbTest.php b/tests/thinkphp/library/think/dbTest.php index 4d3d16d5..515f9424 100644 --- a/tests/thinkphp/library/think/dbTest.php +++ b/tests/thinkphp/library/think/dbTest.php @@ -140,7 +140,7 @@ EOF; public function testExecute() { $config = $this->getConfig(); - $sql = $this->getCreateTableSql(); + $sql = $this->getCreateTableSql(); foreach ($sql as $one) { Db::connect($config)->execute($one); } @@ -151,7 +151,7 @@ EOF; public function testQuery() { $config = $this->getConfig(); - $sql = $this->getCreateTableSql(); + $sql = $this->getCreateTableSql(); Db::connect($config)->batchQuery($sql); $tableQueryResult = Db::connect($config)->query("show tables;"); @@ -165,7 +165,7 @@ EOF; public function testBatchQuery() { $config = $this->getConfig(); - $sql = $this->getCreateTableSql(); + $sql = $this->getCreateTableSql(); Db::connect($config)->batchQuery($sql); $tableNum = Db::connect($config)->execute("show tables;"); @@ -174,28 +174,28 @@ EOF; public function testTable() { - $config = $this->getConfig(); + $config = $this->getConfig(); $tableName = 'tp_user'; - $result = Db::connect($config)->table($tableName); + $result = Db::connect($config)->table($tableName); $this->assertEquals($tableName, $result->getOptions()['table']); } public function testName() { - $config = $this->getConfig(); + $config = $this->getConfig(); $tableName = 'user'; - $result = Db::connect($config)->name($tableName); + $result = Db::connect($config)->name($tableName); $this->assertEquals($config['prefix'] . $tableName, $result->getOptions()['table']); } public function testInsert() { $config = $this->getConfig(); - $data = [ + $data = [ 'username' => 'chunice', 'password' => md5('chunice'), 'status' => 1, - 'create_time' => time() + 'create_time' => time(), ]; $result = Db::connect($config)->name('user')->insert($data); $this->assertEquals(1, $result); @@ -204,11 +204,11 @@ EOF; public function testUpdate() { $config = $this->getConfig(); - $data = [ + $data = [ 'username' => 'chunice_update', 'password' => md5('chunice'), 'status' => 1, - 'create_time' => time() + 'create_time' => time(), ]; $result = Db::connect($config)->name('user')->where('username', 'chunice')->update($data); $this->assertEquals(1, $result); @@ -216,7 +216,7 @@ EOF; public function testFind() { - $config = $this->getConfig(); + $config = $this->getConfig(); $mustFind = Db::connect($config)->name('user')->where('username', 'chunice_update')->find(); $this->assertNotEmpty($mustFind); $mustNotFind = Db::connect($config)->name('user')->where('username', 'chunice')->find(); @@ -229,7 +229,7 @@ EOF; $data = [ ['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); @@ -238,7 +238,7 @@ EOF; public function testSelect() { - $config = $this->getConfig(); + $config = $this->getConfig(); $mustFound = Db::connect($config)->name('user')->where('status', 1)->select(); $this->assertNotEmpty($mustFound); $mustNotFound = Db::connect($config)->name('user')->where('status', 0)->select(); @@ -247,7 +247,7 @@ EOF; public function testValue() { - $config = $this->getConfig(); + $config = $this->getConfig(); $username = Db::connect($config)->name('user')->where('id', 1)->value('username'); $this->assertEquals('chunice_update', $username); $usernameNull = Db::connect($config)->name('user')->where('id', 0)->value('username'); @@ -256,7 +256,7 @@ EOF; public function testColumn() { - $config = $this->getConfig(); + $config = $this->getConfig(); $username = Db::connect($config)->name('user')->where('status', 1)->column('username'); $this->assertNotEmpty($username); $usernameNull = Db::connect($config)->name('user')->where('status', 0)->column('username'); @@ -267,13 +267,13 @@ EOF; public function testInsertGetId() { $config = $this->getConfig(); - $id = Db::connect($config)->name('user')->order('id', 'desc')->value('id'); + $id = Db::connect($config)->name('user')->order('id', 'desc')->value('id'); $data = [ 'username' => uniqid(), 'password' => md5('chunice'), 'status' => 1, - 'create_time' => time() + 'create_time' => time(), ]; $lastId = Db::connect($config)->name('user')->insertGetId($data); $this->assertEquals($id + 1, $lastId); @@ -283,11 +283,11 @@ EOF; public function testGetLastInsId() { $config = $this->getConfig(); - $data = [ + $data = [ 'username' => uniqid(), 'password' => md5('chunice'), 'status' => 1, - 'create_time' => time() + 'create_time' => time(), ]; $lastId = Db::connect($config)->name('user')->insertGetId($data); @@ -308,7 +308,7 @@ EOF; public function testSetInc() { - $config = $this->getConfig(); + $config = $this->getConfig(); $originCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); Db::connect($config)->name('user')->where('id', 1)->setInc('create_time'); $newCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); @@ -318,7 +318,7 @@ EOF; public function testSetDec() { - $config = $this->getConfig(); + $config = $this->getConfig(); $originCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); Db::connect($config)->name('user')->where('id', 1)->setDec('create_time'); $newCreateTime = Db::connect($config)->name('user')->where('id', 1)->value('create_time'); @@ -341,12 +341,12 @@ EOF; public function testCache() { $config = $this->getConfig(); - $result = Db::connect($config)->name('user')->where('id', 1)->cache('key', 60)->select(); - $cache = \think\Cache::get('key'); + $result = Db::connect($config)->name('user')->where('id', 1)->cache('key', 60)->find(); + $cache = \think\Cache::get('key'); $this->assertEquals($result, $cache); - $updateCache = Db::connect($config)->name('user')->cache('key')->find(2); - $this->assertNotEquals($cache, $updateCache); + $updateCache = Db::connect($config)->name('user')->cache('key')->find(1); + $this->assertEquals($cache, $updateCache); } }