当前位置: 首页>>代码示例>>PHP>>正文


PHP UnitTester::seeInDatabase方法代码示例

本文整理汇总了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]);
 }
开发者ID:tom2320x,项目名称:list,代码行数:33,代码来源:UserPhotosLikeTest.php

示例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]);
 }
开发者ID:andrey3,项目名称:yii,代码行数:9,代码来源:LinkTest.php

示例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']);
 }
开发者ID:andrey3,项目名称:yii,代码行数:11,代码来源:UserTest.php

示例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);
 }
开发者ID:mvpydq,项目名称:ucenter,代码行数:17,代码来源:UcenterTest.php

示例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]);
     });
 }
开发者ID:chervand,项目名称:yii-vk-auth,代码行数:20,代码来源:VkAuthTest.php

示例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));
 }
开发者ID:tom2320x,项目名称:list,代码行数:84,代码来源:BlockPhotoTest.php


注:本文中的UnitTester::seeInDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。