@@ 379-405 (lines=27) @@ | ||
376 | ||
377 | ||
378 | ||
379 | public function testGetSiteJournalDealsWithDefaultParams() |
|
380 | { |
|
381 | $apiClient = $this->getMockBuilder(Client::class) |
|
382 | ->disableOriginalConstructor() |
|
383 | ->setMethods(['doGetSiteJournalDeals']) |
|
384 | ->getMock(); |
|
385 | ||
386 | $apiClient->expects($this->once()) |
|
387 | ->method('doGetSiteJournalDeals') |
|
388 | ->with($this->equalTo([ |
|
389 | 'journalStart' => 0, |
|
390 | ])) |
|
391 | ->willReturn((object)[ |
|
392 | 'siteJournalDeals' => (object)[ |
|
393 | 'item' => [ |
|
394 | (object)[ |
|
395 | 'dealEventId' => 42 |
|
396 | ] |
|
397 | ] |
|
398 | ] |
|
399 | ]); |
|
400 | ||
401 | $helper = new Helper($apiClient); |
|
402 | $deals = $helper->getSiteJournalDeals(); |
|
403 | ||
404 | $this->assertContainsOnly('Radowoj\Yaah\Journal\Deal', $deals); |
|
405 | } |
|
406 | ||
407 | ||
408 | public function testGetSiteJournalDealsWithNonzeroStart() |
|
@@ 408-434 (lines=27) @@ | ||
405 | } |
|
406 | ||
407 | ||
408 | public function testGetSiteJournalDealsWithNonzeroStart() |
|
409 | { |
|
410 | $apiClient = $this->getMockBuilder(Client::class) |
|
411 | ->disableOriginalConstructor() |
|
412 | ->setMethods(['doGetSiteJournalDeals']) |
|
413 | ->getMock(); |
|
414 | ||
415 | $apiClient->expects($this->once()) |
|
416 | ->method('doGetSiteJournalDeals') |
|
417 | ->with($this->equalTo([ |
|
418 | 'journalStart' => 71830, |
|
419 | ])) |
|
420 | ->willReturn((object)[ |
|
421 | 'siteJournalDeals' => (object)[ |
|
422 | 'item' => [ |
|
423 | (object)[ |
|
424 | 'dealEventId' => 42 |
|
425 | ] |
|
426 | ] |
|
427 | ] |
|
428 | ]); |
|
429 | ||
430 | $helper = new Helper($apiClient); |
|
431 | $deals = $helper->getSiteJournalDeals(71830); |
|
432 | ||
433 | $this->assertContainsOnly('Radowoj\Yaah\Journal\Deal', $deals); |
|
434 | } |
|
435 | ||
436 | ||
437 | /** |
|
@@ 460-484 (lines=25) @@ | ||
457 | } |
|
458 | ||
459 | ||
460 | public function testGetAuctionByItem() |
|
461 | { |
|
462 | $apiClient = $this->getMockBuilder(Client::class) |
|
463 | ->disableOriginalConstructor() |
|
464 | ->setMethods(['doGetItemFields']) |
|
465 | ->getMock(); |
|
466 | ||
467 | $apiClient->expects($this->once()) |
|
468 | ->method('doGetItemFields') |
|
469 | ->with($this->equalTo([ |
|
470 | 'itemId' => 4321, |
|
471 | ])) |
|
472 | ->willReturn((object)[ |
|
473 | 'itemFields' => (object)[ |
|
474 | 'item' => [ |
|
475 | //no fields returned - mapping from fields to auction tested separately |
|
476 | ] |
|
477 | ] |
|
478 | ]); |
|
479 | ||
480 | $helper = new Helper($apiClient); |
|
481 | $auction = $helper->getAuctionByItemId(4321); |
|
482 | ||
483 | $this->assertInstanceOf('Radowoj\Yaah\Auction', $auction); |
|
484 | } |
|
485 | ||
486 | } |
|
487 |