| 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/Status.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自身のホームはFollowersと自身の発言リスト() |
|---|
| 55 | { |
|---|
| 56 | $this->_createUserRecord($this->_foo); |
|---|
| 57 | $this->_createUserRecord($this->_bar); |
|---|
| 58 | $this->_createUserRecord($this->_baz); |
|---|
| 59 | |
|---|
| 60 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 61 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 62 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 63 | $bazUser = $mapper->findByUserName($this->_baz->userName); |
|---|
| 64 | |
|---|
| 65 | $this->_createFollowerRecord($fooUser->id, $barUser->id); |
|---|
| 66 | $this->_createFollowerRecord($barUser->id, $fooUser->id); |
|---|
| 67 | $this->_createFollowerRecord($barUser->id, $bazUser->id); |
|---|
| 68 | |
|---|
| 69 | $this->_createStatusRecord($fooUser->id, null, 'foo1'); |
|---|
| 70 | $this->_createStatusRecord($fooUser->id, null, 'foo2'); |
|---|
| 71 | $this->_createStatusRecord($fooUser->id, null, 'foo3'); |
|---|
| 72 | $this->_createStatusRecord($fooUser->id, null, 'foo4'); |
|---|
| 73 | $this->_createStatusRecord($barUser->id, null, 'bar1'); |
|---|
| 74 | $this->_createStatusRecord($barUser->id, null, 'bar2'); |
|---|
| 75 | $this->_createStatusRecord($barUser->id, null, 'bar3'); |
|---|
| 76 | $this->_createStatusRecord($barUser->id, null, 'bar4'); |
|---|
| 77 | $this->_createStatusRecord($bazUser->id, null, 'baz1'); |
|---|
| 78 | $this->_createStatusRecord($bazUser->id, null, 'baz2'); |
|---|
| 79 | $this->_createStatusRecord($bazUser->id, null, 'baz3'); |
|---|
| 80 | $this->_createStatusRecord($bazUser->id, null, 'baz4'); |
|---|
| 81 | |
|---|
| 82 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 83 | $userStatuses = $status->listByFollowers(); |
|---|
| 84 | $this->spec(count($userStatuses))->should->be(8); |
|---|
| 85 | |
|---|
| 86 | $fooCount = 0; |
|---|
| 87 | $barCount = 0; |
|---|
| 88 | $bazCount = 0; |
|---|
| 89 | foreach ($userStatuses as $userStatus) { |
|---|
| 90 | if ($userStatus->userId == $fooUser->id) { |
|---|
| 91 | ++$fooCount; |
|---|
| 92 | } elseif ($userStatus->userId == $barUser->id) { |
|---|
| 93 | ++$barCount; |
|---|
| 94 | } elseif ($userStatus->userId == $bazUser->id) { |
|---|
| 95 | ++$bazCount; |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | $this->spec($fooCount)->should->be(4); |
|---|
| 100 | $this->spec($barCount)->should->be(4); |
|---|
| 101 | $this->spec($bazCount)->should->be(0); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | public function itRepliesは自身への返信リスト() |
|---|
| 105 | { |
|---|
| 106 | $this->_createUserRecord($this->_foo); |
|---|
| 107 | $this->_createUserRecord($this->_bar); |
|---|
| 108 | $this->_createUserRecord($this->_baz); |
|---|
| 109 | |
|---|
| 110 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 111 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 112 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 113 | $bazUser = $mapper->findByUserName($this->_baz->userName); |
|---|
| 114 | |
|---|
| 115 | $this->_createStatusRecord($fooUser->id, $fooUser->id, 'foo1'); |
|---|
| 116 | $this->_createStatusRecord($fooUser->id, null, 'foo2'); |
|---|
| 117 | $this->_createStatusRecord($fooUser->id, null, 'foo3'); |
|---|
| 118 | $this->_createStatusRecord($fooUser->id, null, 'foo4'); |
|---|
| 119 | $this->_createStatusRecord($barUser->id, $fooUser->id, 'bar1'); |
|---|
| 120 | $this->_createStatusRecord($barUser->id, $fooUser->id, 'bar2'); |
|---|
| 121 | $this->_createStatusRecord($barUser->id, $fooUser->id, 'bar3'); |
|---|
| 122 | $this->_createStatusRecord($barUser->id, null, 'bar4'); |
|---|
| 123 | $this->_createStatusRecord($bazUser->id, $fooUser->id, 'baz1'); |
|---|
| 124 | $this->_createStatusRecord($bazUser->id, $fooUser->id, 'baz2'); |
|---|
| 125 | $this->_createStatusRecord($bazUser->id, null, 'baz3'); |
|---|
| 126 | $this->_createStatusRecord($bazUser->id, null, 'baz4'); |
|---|
| 127 | |
|---|
| 128 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 129 | $userStatuses = $status->listReplies(); |
|---|
| 130 | $this->spec(count($userStatuses))->should->be(6); |
|---|
| 131 | |
|---|
| 132 | $fooCount = 0; |
|---|
| 133 | $barCount = 0; |
|---|
| 134 | $bazCount = 0; |
|---|
| 135 | foreach ($userStatuses as $userStatus) { |
|---|
| 136 | if ($userStatus->userId == $fooUser->id) { |
|---|
| 137 | ++$fooCount; |
|---|
| 138 | } elseif ($userStatus->userId == $barUser->id) { |
|---|
| 139 | ++$barCount; |
|---|
| 140 | } elseif ($userStatus->userId == $bazUser->id) { |
|---|
| 141 | ++$bazCount; |
|---|
| 142 | } |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | $this->spec($fooCount)->should->be(1); |
|---|
| 146 | $this->spec($barCount)->should->be(3); |
|---|
| 147 | $this->spec($bazCount)->should->be(2); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | public function itArchiveは自身の発言リスト() |
|---|
| 151 | { |
|---|
| 152 | $this->_createUserRecord($this->_foo); |
|---|
| 153 | $this->_createUserRecord($this->_bar); |
|---|
| 154 | $this->_createUserRecord($this->_baz); |
|---|
| 155 | |
|---|
| 156 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 157 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 158 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 159 | $bazUser = $mapper->findByUserName($this->_baz->userName); |
|---|
| 160 | |
|---|
| 161 | $this->_createStatusRecord($fooUser->id, null, 'foo1'); |
|---|
| 162 | $this->_createStatusRecord($fooUser->id, null, 'foo2'); |
|---|
| 163 | $this->_createStatusRecord($fooUser->id, null, 'foo3'); |
|---|
| 164 | $this->_createStatusRecord($fooUser->id, null, 'foo4'); |
|---|
| 165 | $this->_createStatusRecord($barUser->id, null, 'bar1'); |
|---|
| 166 | $this->_createStatusRecord($barUser->id, null, 'bar2'); |
|---|
| 167 | $this->_createStatusRecord($barUser->id, null, 'bar3'); |
|---|
| 168 | $this->_createStatusRecord($barUser->id, null, 'bar4'); |
|---|
| 169 | $this->_createStatusRecord($bazUser->id, null, 'baz1'); |
|---|
| 170 | $this->_createStatusRecord($bazUser->id, null, 'baz2'); |
|---|
| 171 | $this->_createStatusRecord($bazUser->id, null, 'baz3'); |
|---|
| 172 | $this->_createStatusRecord($bazUser->id, null, 'baz4'); |
|---|
| 173 | |
|---|
| 174 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 175 | $userStatuses = $status->listArchives(); |
|---|
| 176 | $this->spec(count($userStatuses))->should->be(4); |
|---|
| 177 | |
|---|
| 178 | $fooCount = 0; |
|---|
| 179 | foreach ($userStatuses as $userStatus) { |
|---|
| 180 | if ($userStatus->userId == $fooUser->id) { |
|---|
| 181 | ++$fooCount; |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | $this->spec($fooCount)->should->be(4); |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | public function itPublicTimelineは公開しているユーザすべての発言リスト() |
|---|
| 189 | { |
|---|
| 190 | $this->_createUserRecord($this->_foo); |
|---|
| 191 | $this->_createUserRecord($this->_bar); |
|---|
| 192 | $this->_createUserRecord($this->_baz); |
|---|
| 193 | |
|---|
| 194 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 195 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 196 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 197 | $bazUser = $mapper->findByUserName($this->_baz->userName); |
|---|
| 198 | |
|---|
| 199 | $bazUser->privateFlag = 1; |
|---|
| 200 | $mapper->update($bazUser); |
|---|
| 201 | |
|---|
| 202 | $this->_createStatusRecord($fooUser->id, null, 'foo1'); |
|---|
| 203 | $this->_createStatusRecord($fooUser->id, null, 'foo2'); |
|---|
| 204 | $this->_createStatusRecord($fooUser->id, null, 'foo3'); |
|---|
| 205 | $this->_createStatusRecord($fooUser->id, null, 'foo4'); |
|---|
| 206 | $this->_createStatusRecord($barUser->id, null, 'bar1'); |
|---|
| 207 | $this->_createStatusRecord($barUser->id, null, 'bar2'); |
|---|
| 208 | $this->_createStatusRecord($barUser->id, null, 'bar3'); |
|---|
| 209 | $this->_createStatusRecord($barUser->id, null, 'bar4'); |
|---|
| 210 | $this->_createStatusRecord($bazUser->id, null, 'baz1'); |
|---|
| 211 | $this->_createStatusRecord($bazUser->id, null, 'baz2'); |
|---|
| 212 | $this->_createStatusRecord($bazUser->id, null, 'baz3'); |
|---|
| 213 | $this->_createStatusRecord($bazUser->id, null, 'baz4'); |
|---|
| 214 | |
|---|
| 215 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 216 | $userStatuses = $status->listPublicTimeline(); |
|---|
| 217 | $this->spec(count($userStatuses))->should->be(8); |
|---|
| 218 | |
|---|
| 219 | $fooCount = 0; |
|---|
| 220 | $barCount = 0; |
|---|
| 221 | $bazCount = 0; |
|---|
| 222 | foreach ($userStatuses as $userStatus) { |
|---|
| 223 | if ($userStatus->userId == $fooUser->id) { |
|---|
| 224 | ++$fooCount; |
|---|
| 225 | } elseif ($userStatus->userId == $barUser->id) { |
|---|
| 226 | ++$barCount; |
|---|
| 227 | } elseif ($userStatus->userId == $bazUser->id) { |
|---|
| 228 | ++$bazCount; |
|---|
| 229 | } |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | $this->spec($fooCount)->should->be(4); |
|---|
| 233 | $this->spec($barCount)->should->be(4); |
|---|
| 234 | $this->spec($bazCount)->should->be(0); |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | public function it対象ユーザの発言リストが取得できる() |
|---|
| 238 | { |
|---|
| 239 | $this->_createUserRecord($this->_foo); |
|---|
| 240 | $this->_createUserRecord($this->_bar); |
|---|
| 241 | |
|---|
| 242 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 243 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 244 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 245 | |
|---|
| 246 | $this->_createStatusRecord($barUser->id, null, 'bar1'); |
|---|
| 247 | $this->_createStatusRecord($barUser->id, null, 'bar2'); |
|---|
| 248 | $this->_createStatusRecord($barUser->id, null, 'bar3'); |
|---|
| 249 | $this->_createStatusRecord($barUser->id, null, 'bar4'); |
|---|
| 250 | |
|---|
| 251 | $status = new Phwittr_Status($barUser->id); |
|---|
| 252 | $userStatuses = $status->listArchives(); |
|---|
| 253 | |
|---|
| 254 | $this->spec(count($userStatuses))->should->be(4); |
|---|
| 255 | |
|---|
| 256 | $barCount = 0; |
|---|
| 257 | foreach ($userStatuses as $userStatus) { |
|---|
| 258 | if ($userStatus->userId == $barUser->id) { |
|---|
| 259 | ++$barCount; |
|---|
| 260 | } |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | $this->spec($barCount)->should->be(4); |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | public function itプライベートの人の発言はフォローユーザにしか表示されない() |
|---|
| 267 | { |
|---|
| 268 | $this->_createUserRecord($this->_foo); |
|---|
| 269 | $this->_createUserRecord($this->_bar); |
|---|
| 270 | |
|---|
| 271 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 272 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 273 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 274 | |
|---|
| 275 | $barUser->privateFlag = 1; |
|---|
| 276 | $mapper->update($barUser); |
|---|
| 277 | |
|---|
| 278 | $this->_createFollowerRecord($fooUser->id, $barUser->id); |
|---|
| 279 | |
|---|
| 280 | $this->_createStatusRecord($barUser->id, null, 'bar1'); |
|---|
| 281 | $this->_createStatusRecord($barUser->id, null, 'bar2'); |
|---|
| 282 | $this->_createStatusRecord($barUser->id, null, 'bar3'); |
|---|
| 283 | $this->_createStatusRecord($barUser->id, null, 'bar4'); |
|---|
| 284 | |
|---|
| 285 | $statusForFoo = new Phwittr_Status($barUser->id, $fooUser->id); |
|---|
| 286 | $statusForGuest = new Phwittr_Status($barUser->id); |
|---|
| 287 | |
|---|
| 288 | $userStatusesForFoo = $statusForFoo->listArchives(); |
|---|
| 289 | $userStatusesForGuest = $statusForGuest->listArchives(); |
|---|
| 290 | |
|---|
| 291 | $this->spec(count($userStatusesForFoo))->should->be(4); |
|---|
| 292 | $this->spec(count($userStatusesForGuest))->should->be(0); |
|---|
| 293 | |
|---|
| 294 | $barCount = 0; |
|---|
| 295 | foreach ($userStatusesForFoo as $userStatus) { |
|---|
| 296 | if ($userStatus->userId == $barUser->id) { |
|---|
| 297 | ++$barCount; |
|---|
| 298 | } |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | $this->spec($barCount)->should->be(4); |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | public function itプライベートユーザは自身の発言リストが見れる() |
|---|
| 305 | { |
|---|
| 306 | $this->_createUserRecord($this->_foo); |
|---|
| 307 | |
|---|
| 308 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 309 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 310 | |
|---|
| 311 | $fooUser->privateFlag = 1; |
|---|
| 312 | $mapper->update($fooUser); |
|---|
| 313 | |
|---|
| 314 | $this->_createStatusRecord($fooUser->id, null, 'foo1'); |
|---|
| 315 | $this->_createStatusRecord($fooUser->id, null, 'foo2'); |
|---|
| 316 | $this->_createStatusRecord($fooUser->id, null, 'foo3'); |
|---|
| 317 | $this->_createStatusRecord($fooUser->id, null, 'foo4'); |
|---|
| 318 | |
|---|
| 319 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 320 | |
|---|
| 321 | $userStatuses = $status->listArchives(); |
|---|
| 322 | |
|---|
| 323 | $this->spec(count($userStatuses))->should->be(4); |
|---|
| 324 | |
|---|
| 325 | $fooCount = 0; |
|---|
| 326 | foreach ($userStatuses as $userStatus) { |
|---|
| 327 | if ($userStatus->userId == $fooUser->id) { |
|---|
| 328 | ++$fooCount; |
|---|
| 329 | } |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | $this->spec($fooCount)->should->be(4); |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | public function itステータスidを指定することで個別に発言を取得できる() |
|---|
| 336 | { |
|---|
| 337 | $this->_createUserRecord($this->_foo); |
|---|
| 338 | |
|---|
| 339 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 340 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 341 | |
|---|
| 342 | $this->_createStatusRecord($fooUser->id, null, 'foo1'); |
|---|
| 343 | |
|---|
| 344 | $status = new Phwittr_Status($fooUser->id); |
|---|
| 345 | |
|---|
| 346 | $fooStatus1 = $status->findStatus(1); |
|---|
| 347 | |
|---|
| 348 | $this->spec($fooStatus1->userId)->should->be($fooUser->id); |
|---|
| 349 | $this->spec($fooStatus1->userName)->should->be($fooUser->userName); |
|---|
| 350 | $this->spec($fooStatus1->comment)->should->be('foo1'); |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | public function itプライベートユーザの個別発言もフレンドでなければ取得できない() |
|---|
| 354 | { |
|---|
| 355 | $this->_createUserRecord($this->_foo); |
|---|
| 356 | $this->_createUserRecord($this->_bar); |
|---|
| 357 | |
|---|
| 358 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 359 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 360 | $barUser = $mapper->findByUserName($this->_bar->userName); |
|---|
| 361 | |
|---|
| 362 | $barUser->privateFlag = 1; |
|---|
| 363 | $mapper->update($barUser); |
|---|
| 364 | |
|---|
| 365 | $this->_createFollowerRecord($fooUser->id, $barUser->id); |
|---|
| 366 | |
|---|
| 367 | $this->_createStatusRecord($barUser->id, null, 'bar1'); |
|---|
| 368 | |
|---|
| 369 | $barStatusForFoo = new Phwittr_Status($barUser->id, $fooUser->id); |
|---|
| 370 | $barStatusForGuest = new Phwittr_Status($barUser->id); |
|---|
| 371 | |
|---|
| 372 | $barStatus1ForFoo = $barStatusForFoo->findStatus(1); |
|---|
| 373 | $barStatus1ForGuest = $barStatusForGuest->findStatus(1); |
|---|
| 374 | |
|---|
| 375 | $this->spec($barStatus1ForFoo->userId)->should->be($barUser->id); |
|---|
| 376 | $this->spec($barStatus1ForFoo->userName)->should->be($barUser->userName); |
|---|
| 377 | $this->spec($barStatus1ForFoo->comment)->should->be('bar1'); |
|---|
| 378 | |
|---|
| 379 | $this->spec($barStatus1ForGuest)->should->beNull(); |
|---|
| 380 | } |
|---|
| 381 | |
|---|
| 382 | public function itプライベートユーザは自身の個別発言も取得できる() |
|---|
| 383 | { |
|---|
| 384 | $this->_createUserRecord($this->_foo); |
|---|
| 385 | |
|---|
| 386 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 387 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 388 | |
|---|
| 389 | $fooUser->privateFlag = 1; |
|---|
| 390 | $mapper->update($fooUser); |
|---|
| 391 | |
|---|
| 392 | $this->_createStatusRecord($fooUser->id, null, 'foo1'); |
|---|
| 393 | |
|---|
| 394 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 395 | |
|---|
| 396 | $fooStatus1 = $status->findStatus(1); |
|---|
| 397 | |
|---|
| 398 | $this->spec($fooStatus1->userId)->should->be($fooUser->id); |
|---|
| 399 | $this->spec($fooStatus1->userName)->should->be($fooUser->userName); |
|---|
| 400 | $this->spec($fooStatus1->comment)->should->be('foo1'); |
|---|
| 401 | } |
|---|
| 402 | |
|---|
| 403 | public function it存在しないユーザのステータスは参照できない() |
|---|
| 404 | { |
|---|
| 405 | try { |
|---|
| 406 | $status = new Phwittr_Status(1, 1); |
|---|
| 407 | } catch (Phwittr_Exception $e) { |
|---|
| 408 | return; |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | $this->fail(); |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | public function itゲストのステータスなどない() |
|---|
| 415 | { |
|---|
| 416 | try { |
|---|
| 417 | $status = new Phwittr_Status(null); |
|---|
| 418 | } catch (Phwittr_Exception $e) { |
|---|
| 419 | return; |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | $this->fail(); |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | public function it表示される発言リストは、通常は最新20件() |
|---|
| 426 | { |
|---|
| 427 | $this->_createUserRecord($this->_foo); |
|---|
| 428 | |
|---|
| 429 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 430 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 431 | |
|---|
| 432 | for ($i = 0; $i < 100; ++$i) { |
|---|
| 433 | $this->_createStatusRecord($fooUser->id, null, 'foo' . ($i + 1), $i); |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 437 | $userStatuses = $status->listByFollowers(); |
|---|
| 438 | |
|---|
| 439 | $this->spec(count($userStatuses))->should->be(20); |
|---|
| 440 | for ($i = 0; $i < 20; ++$i) { |
|---|
| 441 | $number = 100 - $i; |
|---|
| 442 | $this->spec($userStatuses[$i]->comment)->should->be("foo$number"); |
|---|
| 443 | } |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | public function it表示される発言リスト20件のページが指定できる() |
|---|
| 447 | { |
|---|
| 448 | $this->_createUserRecord($this->_foo); |
|---|
| 449 | |
|---|
| 450 | $mapper = Piece_ORM::getMapper('Users'); |
|---|
| 451 | $fooUser = $mapper->findByUserName($this->_foo->userName); |
|---|
| 452 | |
|---|
| 453 | for ($i = 0; $i < 100; ++$i) { |
|---|
| 454 | $this->_createStatusRecord($fooUser->id, null, 'foo' . ($i + 1), $i); |
|---|
| 455 | } |
|---|
| 456 | |
|---|
| 457 | $status = new Phwittr_Status($fooUser->id, $fooUser->id); |
|---|
| 458 | $userStatuses = $status->listByFollowers(3); |
|---|
| 459 | |
|---|
| 460 | $this->spec(count($userStatuses))->should->be(20); |
|---|
| 461 | for ($i = 0; $i < 20; ++$i) { |
|---|
| 462 | $number = 100 - (20 * 2 + $i); |
|---|
| 463 | $this->spec($userStatuses[$i]->comment)->should->be("foo$number"); |
|---|
| 464 | } |
|---|
| 465 | } |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | |
|---|
| 490 | |
|---|
| 491 | |
|---|
| 492 | |
|---|
| 493 | |
|---|
| 494 | |
|---|
| 495 | |
|---|
| 496 | ?> |
|---|