| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | require_once dirname(__FILE__) . '/SpecCommon.php'; |
|---|
| 14 | require_once 'Phwittr/Config.php'; |
|---|
| 15 | require_once 'Phwittr/Account.php'; |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | class Describeアカウント情報 extends SpecCommon |
|---|
| 28 | { |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | public function it基本情報が更新できる() |
|---|
| 55 | { |
|---|
| 56 | $this->_createUserRecord($this->_foo); |
|---|
| 57 | |
|---|
| 58 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 59 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 60 | |
|---|
| 61 | $userId = $user->id; |
|---|
| 62 | $user->userName = $this->_bar->userName; |
|---|
| 63 | $user->email = $this->_bar->email; |
|---|
| 64 | $user->privateFlag = $this->_bar->flag; |
|---|
| 65 | |
|---|
| 66 | $account = new Phwittr_Account(); |
|---|
| 67 | $account->update($user); |
|---|
| 68 | |
|---|
| 69 | $newUser = $mapper->findById($userId); |
|---|
| 70 | |
|---|
| 71 | $this->spec($newUser->userName)->should->be($this->_bar->userName); |
|---|
| 72 | $this->spec($newUser->email)->should->be($this->_bar->email); |
|---|
| 73 | $this->spec($newUser->privateFlag)->should->be($this->_bar->flag); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | public function it情報更新の際、変更後のユーザ名が重複しないかを事前に確認する() |
|---|
| 77 | { |
|---|
| 78 | $this->_createUserRecord($this->_foo); |
|---|
| 79 | |
|---|
| 80 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 81 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 82 | |
|---|
| 83 | $this->spec(Phwittr_Account::confirmNewUserName($user->id, 'NewUserName') |
|---|
| 84 | )->should->beTrue(); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | public function it事前確認における変更後のユーザ名が重複していれば例外発生() |
|---|
| 88 | { |
|---|
| 89 | $this->_createUserRecord($this->_foo); |
|---|
| 90 | $this->_createUserRecord($this->_bar); |
|---|
| 91 | |
|---|
| 92 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 93 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 94 | |
|---|
| 95 | try { |
|---|
| 96 | Phwittr_Account::confirmNewUserName($user->id, $this->_bar->userName); |
|---|
| 97 | } catch (Phwittr_Account_Exception $e) { |
|---|
| 98 | return; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | $this->fail(); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | public function it情報更新の際、変更後のメールアドレスが重複しないかを事前に確認する() |
|---|
| 105 | { |
|---|
| 106 | $this->_createUserRecord($this->_foo); |
|---|
| 107 | |
|---|
| 108 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 109 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 110 | |
|---|
| 111 | $this->spec(Phwittr_Account::confirmNewEmail($user->id, 'new@example.com') |
|---|
| 112 | )->should->beTrue(); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | public function it事前確認における変更後のメールアドレスが重複していれば例外発生() |
|---|
| 116 | { |
|---|
| 117 | $this->_createUserRecord($this->_foo); |
|---|
| 118 | $this->_createUserRecord($this->_bar); |
|---|
| 119 | |
|---|
| 120 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 121 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 122 | |
|---|
| 123 | try { |
|---|
| 124 | Phwittr_Account::confirmNewEmail($user->id, $this->_bar->email); |
|---|
| 125 | } catch (Phwittr_Account_Exception $e) { |
|---|
| 126 | return; |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | $this->fail(); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | public function itユーザ名が他レコードのものと重複している状態では更新できない() |
|---|
| 133 | { |
|---|
| 134 | $this->_createUserRecord($this->_foo); |
|---|
| 135 | $this->_createUserRecord($this->_bar); |
|---|
| 136 | |
|---|
| 137 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 138 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 139 | |
|---|
| 140 | $user->userName = $this->_bar->userName; |
|---|
| 141 | |
|---|
| 142 | try { |
|---|
| 143 | $account = new Phwittr_Account(); |
|---|
| 144 | $account->update($user); |
|---|
| 145 | } catch (Phwittr_Account_Exception $e) { |
|---|
| 146 | return; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | $this->fail(); |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | public function itメールアドレスが他レコードのものと重複している状態では更新できない() |
|---|
| 153 | { |
|---|
| 154 | $this->_createUserRecord($this->_foo); |
|---|
| 155 | $this->_createUserRecord($this->_bar); |
|---|
| 156 | |
|---|
| 157 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 158 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 159 | |
|---|
| 160 | $user->email = $this->_bar->email; |
|---|
| 161 | |
|---|
| 162 | try { |
|---|
| 163 | $account = new Phwittr_Account(); |
|---|
| 164 | $account->update($user); |
|---|
| 165 | } catch (Phwittr_Account_Exception $e) { |
|---|
| 166 | return; |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | $this->fail(); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | public function itパスワードは個別で更新() |
|---|
| 173 | { |
|---|
| 174 | $this->_createUserRecord($this->_foo); |
|---|
| 175 | |
|---|
| 176 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 177 | $user = $mapper->findByUserName($this->_foo->userName); |
|---|
| 178 | |
|---|
| 179 | $userId = $user->id; |
|---|
| 180 | $password = 'newpassword'; |
|---|
| 181 | |
|---|
| 182 | $account = new Phwittr_Account(); |
|---|
| 183 | $account->updatePassword($userId, $password); |
|---|
| 184 | |
|---|
| 185 | $newUser = $mapper->findById($userId); |
|---|
| 186 | |
|---|
| 187 | $this->spec($newUser->password)->should->be(sha1($password)); |
|---|
| 188 | $this->spec($newUser->userName)->should->be($this->_foo->userName); |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | public function itユーザ画像も個別で更新() |
|---|
| 192 | { |
|---|
| 193 | $this->pending(); |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | ?> |
|---|