connection = new Connection($config); DbManager::getInstance()->addConnection($this->connection); $connection = DbManager::getInstance()->getConnection(); $this->assertTrue($connection === $this->connection); } public function testAdd() { $testUserModel = new TestUserModel(); $testUserModel->state = 1; $testUserModel->name = 'Siam'; $testUserModel->age = 100; $testUserModel->addTime = date('Y-m-d H:i:s'); $data = $testUserModel->save(); $this->assertIsInt($data); $testUserModel = new TestUserModel(); $testUserModel->state = 1; $testUserModel->name = 'Siam222'; $testUserModel->age = 100; $testUserModel->addTime = date('Y-m-d H:i:s'); $data = $testUserModel->save(); $this->assertIsInt($data); $testUserModel = new TestUserListModel(); $testUserModel->state = 2; $testUserModel->name = 'Siam'; $testUserModel->age = 18; $testUserModel->addTime = date('Y-m-d H:i:s'); $data = $testUserModel->save(); $this->assertIsInt($data); } public function testJoin() { $userModel = TestUserModel::create(); $res = $userModel->alias('u')->join('user_test_list as u_list', 'u_list.name = u.name')->where([ 'u.name' => 'Siam' ])->all(); $this->assertNotEmpty($res); } public function testDeleteAll() { $res = TestUserListModel::create()->destroy(null, true); $this->assertIsInt($res); $test = TestUserModel::create()->destroy(null, true); $this->assertIsInt($test); } }