本文整理汇总了PHP中UnitTester::seeInDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitTester::seeInDatabase方法的具体用法?PHP UnitTester::seeInDatabase怎么用?PHP UnitTester::seeInDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTester
的用法示例。
在下文中一共展示了UnitTester::seeInDatabase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLiking
public function testLiking()
{
$idUser1 = 1;
$idUser2 = 2;
$idUser3 = 3;
$idUser4 = 4;
$photoidUser1 = 1;
$photoidUser2 = 4;
$photoidUser3 = 8;
$photoidUser4 = 11;
// User should be able to like photos they don't own
list($result_code, $result) = User::likePhoto($idUser1, $photoidUser2);
$this->assertEquals(200, $result_code);
$this->assertTrue($result['success'] == true);
$this->assertTrue($result['likes'] == true);
$this->tester->seeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => $photoidUser2]);
// User should be able to unlike photos they don't own
list($result_code, $result) = User::likePhoto($idUser1, $photoidUser2);
$this->assertEquals(200, $result_code);
$this->assertTrue($result['success'] == true);
$this->assertTrue($result['likes'] == false);
$this->tester->dontSeeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => $photoidUser2]);
// User should not be be able to like photos they own
list($result_code, $result) = User::likePhoto($idUser1, $photoidUser1);
$this->assertEquals(403, $result_code);
$this->assertTrue($result['success'] == false);
$this->tester->dontSeeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => $photoidUser1]);
// User should not be be able to like photos that don't exist
list($result_code, $result) = User::likePhoto($idUser1, 0);
$this->assertEquals(404, $result_code);
$this->assertTrue($result['success'] == false);
$this->tester->dontSeeInDatabase('UserPhotoLikes', ['userid' => $idUser1, 'photoid' => 0]);
}
示例2: testSaveLink
public function testSaveLink()
{
$link = new Link();
$link->email = "test@test.ru";
$link->generateToken();
$token = $link->token;
$this->assertTrue($link->save());
$this->tester->seeInDatabase('links', ['email' => 'test@test.ru', 'token' => $token]);
}
示例3: testRegUser
public function testRegUser()
{
$user = new User();
$user->email = 'test@test.ru';
$user->name = 'test';
$user->setPassword('password');
$user->generateAuthKey();
$this->assertTrue($user->validate());
$this->assertTrue($user->save());
$this->tester->seeInDatabase('users', ['email' => 'test@test.ru', 'name' => 'test']);
}
示例4: testEditUser
public function testEditUser()
{
$this->userRegister();
$username = $this->faker->userName;
$password = $this->faker->password;
$email = $this->faker->email;
//正确修改
$return = $this->ucenter->uc_user_edit($this->username, $this->password, $password, $email);
$this->assertEquals(1, $return);
$this->tester->seeInDatabase('uc_members', ['username' => $this->username, 'email' => $email]);
//未作任何修改
$return = $this->ucenter->uc_user_edit($this->username, $password, $password, $email);
$this->assertEquals(0, $return);
//旧密码不正确
$return = $this->ucenter->uc_user_edit($this->username, $this->password, $password, $email);
$this->assertEquals(-1, $return);
}
示例5: testTokenVerify
/**
* tests token verification
*/
public function testTokenVerify()
{
$this->token = $this->createToken();
$this->specifyConfig()->cloneOnly('token');
$this->specify('vk component configured', function () {
$this->assertInternalType('string', $this->vk->clientId);
$this->assertInternalType('string', $this->vk->clientSecret);
$this->assertInternalType('string', $this->vk->accessToken);
});
$this->specify('check token', function () {
$this->assertTrue($this->vk->checkToken($this->token));
});
$this->specify('token is vk-valid', function () {
$this->assertTrue($this->token->verify());
$this->tester->seeInDatabase('vk_auth_token', ['id' => $this->token->id, 'status' => VkAuthToken::STATUS_VERIFIED]);
});
}
示例6: testBlocking
public function testBlocking()
{
$skeyUser1 = 'a9225230920079405293a280a508c91d';
$skeyUser2 = '8ba048289a159a36d581ddf452f4baa0';
$skeyUser3 = 'd097a3a21df75f96b1f6745e5dbaa5c6';
$skeyUser4 = '2e975abd0ffa5df70fcee71bfef481bb';
$idUser1 = 1;
$idUser2 = 2;
$idUser3 = 3;
$idUser4 = 4;
$photoidUser1 = 1;
$photoidUser2 = 4;
$photoidUser3 = 8;
$photoidUser4 = 11;
// Sanity check for session values from fixtures
//$res = User::sessionIsValid($idUser1, $skeyUser1);
//$this->assertTrue($res);
// User should be able to block photos they don't own when logged in
$res = User::blockPhoto($idUser1, $skeyUser1, $photoidUser2);
$this->assertEquals(200, $res);
$this->tester->seeInDatabase('UserPhotoBlocks', ['userid' => $idUser1, 'photoid' => $photoidUser2]);
// Re-blocking should succeed without complaint
$res = User::blockPhoto($idUser1, $skeyUser1, $photoidUser2);
$this->assertEquals(200, $res);
// Users shouldn't be able to block their own photos
$res = User::blockPhoto($idUser1, $skeyUser1, $photoidUser1);
$this->assertEquals(401, $res);
// Users who aren't passing an skey shouldn't be able to block photos
$res = User::blockPhoto($idUser1, '', $photoidUser2);
$this->assertEquals(401, $res);
// Users with bad credentials shouldn't be able to block photos
$res = User::blockPhoto($idUser1, 'not valid', $photoidUser2);
$this->assertEquals(401, $res);
// No such photo? Access denied.
$res = User::blockPhoto($idUser1, $skeyUser1, 0);
$this->assertEquals(404, $res);
// A user should not see a photo they have blocked when listing everyone
$res = UserList::getPhotosList($idUser1);
$this->assertNotEquals(null, $res);
$photo_ids = array_map(function ($x) {
return $x['itemid'];
}, $res);
$this->assertFalse(in_array($photoidUser2, $photo_ids));
// Buts hsould see photos by other users
$this->assertTrue(in_array($photoidUser3, $photo_ids));
// A user should not see a photo they have blocked when listing a user
$res = UserList::getPhotosList($idUser1, 20, 1, $idUser2);
$this->assertNotEquals(null, $res);
$photo_ids = array_map(function ($x) {
return $x["itemid"];
}, $res);
$this->assertFalse(in_array($photoidUser2, $photo_ids));
// Buts hsould see photos by other users
$this->assertTrue(in_array($photoidUser2 + 1, $photo_ids));
// When three users block a photo...
$res = User::blockPhoto($idUser3, $skeyUser3, $photoidUser2);
$this->assertEquals(200, $res);
$res = User::blockPhoto($idUser4, $skeyUser4, $photoidUser2);
$this->assertEquals(200, $res);
// Nobody (exept the uploader) should see it in the global list
$res = UserList::getPhotosList($idUser1);
$photo_ids = array_map(function ($x) {
return $x["itemid"];
}, $res);
$this->assertFalse(in_array($photoidUser2, $photo_ids));
// The uploader should see it in the global list
$res = UserList::getPhotosList($idUser2);
$photo_ids = array_map(function ($x) {
return $x["itemid"];
}, $res);
$this->assertTrue(in_array($photoidUser2, $photo_ids));
// Nobody (exept the uploader) should see it in that user's list
$res = UserList::getPhotosList($idUser1, 20, 1, $idUser2);
$photo_ids = array_map(function ($x) {
return $x["itemid"];
}, $res);
$this->assertFalse(in_array($photoidUser2, $photo_ids));
// The uploader should see it in their userid's list
$res = UserList::getPhotosList($idUser2, 20, 1, $idUser2);
$photo_ids = array_map(function ($x) {
return $x["itemid"];
}, $res);
$this->assertTrue(in_array($photoidUser2 + 1, $photo_ids));
}