| @@ 327-349 (lines=23) @@ | ||
| 324 | /** |
|
| 325 | * @test |
|
| 326 | */ |
|
| 327 | public function calculateProductBehavior() { |
|
| 328 | $I = $this->tester; |
|
| 329 | ||
| 330 | $I->describe('`calculateProduct` behavior'); |
|
| 331 | ||
| 332 | $collection = Collection::of([2, 4, 3]); |
|
| 333 | ||
| 334 | $I->expectThat('numeric collection product can be calculated'); |
|
| 335 | ||
| 336 | $collectionProduct = $collection->calculateProduct(); |
|
| 337 | ||
| 338 | $I->seeNumber($collectionProduct) |
|
| 339 | ->isEqualTo(24); |
|
| 340 | ||
| 341 | $collection = Collection::of([2, 'hi', 'there']); |
|
| 342 | ||
| 343 | $I->expectThat('mixed collection product can be calculated'); |
|
| 344 | ||
| 345 | $collectionProduct = $collection->calculateProduct(); |
|
| 346 | ||
| 347 | $I->seeNumber($collectionProduct) |
|
| 348 | ->isEqualTo(0); |
|
| 349 | } |
|
| 350 | ||
| 351 | /** |
|
| 352 | * @test |
|
| @@ 354-371 (lines=18) @@ | ||
| 351 | /** |
|
| 352 | * @test |
|
| 353 | */ |
|
| 354 | public function popBehavior() { |
|
| 355 | $I = $this->tester; |
|
| 356 | ||
| 357 | $I->describe('`pop` behavior'); |
|
| 358 | ||
| 359 | $collection = Collection::of([2, 4, 3]); |
|
| 360 | ||
| 361 | $I->expectThat('`pop` ejects last element fro the collection'); |
|
| 362 | ||
| 363 | $poppedElement = $collection->pop(); |
|
| 364 | ||
| 365 | $I->lookAt('popped element'); |
|
| 366 | $I->seeNumber($poppedElement) |
|
| 367 | ->isEqualTo($lastCollectionElement = 3); |
|
| 368 | $I->lookAt('collection without last(popped) element'); |
|
| 369 | $I->see($collection) |
|
| 370 | ->isEqualTo(Collection::of([2, 4])); |
|
| 371 | } |
|
| 372 | ||
| 373 | /** |
|
| 374 | * @test |
|
| @@ 376-393 (lines=18) @@ | ||
| 373 | /** |
|
| 374 | * @test |
|
| 375 | */ |
|
| 376 | public function shiftBehavior() { |
|
| 377 | $I = $this->tester; |
|
| 378 | ||
| 379 | $I->describe('`shift` behavior'); |
|
| 380 | ||
| 381 | $collection = Collection::of([2, 4, 3]); |
|
| 382 | ||
| 383 | $I->expectThat('`shift` ejects first element fro the collection'); |
|
| 384 | ||
| 385 | $poppedElement = $collection->shift(); |
|
| 386 | ||
| 387 | $I->lookAt('shifted element'); |
|
| 388 | $I->seeNumber($poppedElement) |
|
| 389 | ->isEqualTo($firstCollectionElement = 2); |
|
| 390 | $I->lookAt('collection without first(shifted) element'); |
|
| 391 | $I->see($collection) |
|
| 392 | ->isEqualTo(Collection::of([4, 3])); |
|
| 393 | } |
|
| 394 | ||
| 395 | /** |
|
| 396 | * @test |
|