Guest User

Untitled

a guest
Dec 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. public function testIsGettingWishList(): void
  2. {
  3. // Real WishList
  4. $simpleIphoneSixPlus = new Simple();
  5. $simpleIphoneSixPlus->setSku('iph0n3-6plus');
  6.  
  7. $productIphone = new WishListProduct('iph0n3');
  8. $productIphone->setSimples([$simpleIphoneSixPlus]);
  9. $productIphone->setName('iPhone');
  10. $productIphone->setWishListId(1);
  11. $productIphone->setWishListPrice(Money::fromCents(110000));
  12. $productIphone->setAddedOn(new DateTime('2016-04-24 12:00:00'));
  13. $productIphone->setStock(9);
  14. $productIphone->setPrice(Money::fromCents(100000));
  15. $productIphone->setOriginalPrice(Money::fromCents(110000));
  16. $productIphone->setSlug('iphone');
  17. $productIphone->activate();
  18.  
  19. $simpleMacBookAir = new Simple();
  20. $simpleMacBookAir->setSku('M4cBo0k-air');
  21.  
  22. $productMacBook = new WishListProduct('M4cBo0k');
  23. $productMacBook->setSimples([$simpleMacBookAir]);
  24. $productMacBook->setWishListId(2);
  25. $productMacBook->setName('MacBookPro');
  26. $productMacBook->setWishListPrice(Money::fromCents(22000));
  27. $productMacBook->setAddedOn(new DateTime('2016-04-25 12:00:00'));
  28. $productMacBook->setStock(5);
  29. $productMacBook->setPrice(Money::fromCents(1000));
  30. $productMacBook->setOriginalPrice(Money::fromCents(10));
  31. $productMacBook->setSlug('macbook');
  32. $productMacBook->activate();
  33.  
  34. $owner = new Customer();
  35. $owner->setId(10);
  36.  
  37. $paginationData = [
  38. 'page' => 1,
  39. 'pageSize' => 10,
  40. ];
  41.  
  42. $wishList = new WishList('Birthday', $owner);
  43. $wishList->setId(10);
  44. $wishList->setVisibility(WishList::VISIBILITY_PRIVATE);
  45. $wishList->setCreatedAt(new DateTime('2016-04-24 11:00:00'));
  46. $wishList->setDescription('My birthday greed.');
  47. $wishList->addProduct($productIphone);
  48. $wishList->addProduct($productMacBook);
  49.  
  50. // Set up test doubles
  51. $wishListAdapter = $this->prophesize(WishListAdapter::class);
  52. $wishListAdapter->getWishList($wishList, $paginationData)
  53. ->shouldBeCalled()
  54. ->willReturn($wishList);
  55.  
  56. $cacheService = $this->prophesize(CacheService::class);
  57.  
  58. $productService = $this->prophesize(ProductService::class);
  59. $productService->getBySkus(['iph0n3', 'M4cBo0k'])
  60. ->shouldBeCalled()
  61. ->willReturn([$productIphone, $productMacBook]);
  62.  
  63. $service = new ManageWishList($wishListAdapter->reveal(), $cacheService->reveal());
  64. $service->setProductService($productService->reveal());
  65. $actual = $service->getWishList($wishList, $paginationData);
  66.  
  67. $this->assertEquals($wishList, $actual);
  68. }
Add Comment
Please, Sign In to add comment