|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +/* |
| 4 | + * This file is part of the Sylius package. |
| 5 | + * |
| 6 | + * (c) Sylius Sp. z o.o. |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
3 | 12 | declare(strict_types=1); |
4 | 13 |
|
5 | 14 | namespace Tests\Sylius\WishlistPlugin\Unit\CommandHandler\Wishlist; |
@@ -58,56 +67,24 @@ public function testShouldBeInitializable(): void |
58 | 67 |
|
59 | 68 | public function testShouldAddProductToWishlist(): void |
60 | 69 | { |
61 | | - $this->productRepository |
62 | | - ->expects($this->once()) |
63 | | - ->method('find') |
64 | | - ->with(1) |
65 | | - ->willReturn($this->product); |
66 | | - $this->wishlistProductFactory |
67 | | - ->expects($this->once()) |
68 | | - ->method('createForWishlistAndProduct') |
69 | | - ->with($this->wishlist, $this->product) |
70 | | - ->willReturn($this->wishlistProduct); |
71 | | - $this->wishlist |
72 | | - ->expects($this->once()) |
73 | | - ->method('addWishlistProduct') |
74 | | - ->with($this->wishlistProduct); |
75 | | - $this->wishlistManager |
76 | | - ->expects($this->once()) |
77 | | - ->method('persist') |
78 | | - ->with($this->wishlistProduct); |
79 | | - $this->wishlistManager |
80 | | - ->expects($this->once()) |
81 | | - ->method('flush'); |
82 | | - |
83 | | - $this->handler->__invoke($this->command); |
| 70 | + $this->productRepository->expects($this->once())->method('find')->with(1)->willReturn($this->product); |
| 71 | + $this->wishlistProductFactory->expects($this->once())->method('createForWishlistAndProduct')->with($this->wishlist, $this->product)->willReturn($this->wishlistProduct); |
| 72 | + $this->wishlist->expects($this->once())->method('addWishlistProduct')->with($this->wishlistProduct); |
| 73 | + $this->wishlistManager->expects($this->once())->method('persist')->with($this->wishlistProduct); |
| 74 | + $this->wishlistManager->expects($this->once())->method('flush'); |
| 75 | + |
| 76 | + ($this->handler)($this->command); |
84 | 77 | } |
85 | 78 |
|
86 | 79 | public function testShouldThrowExceptionIfProductIsNotFound(): void |
87 | 80 | { |
88 | 81 | $this->expectException(ProductNotFoundException::class); |
89 | | - $this->productRepository |
90 | | - ->expects($this->once()) |
91 | | - ->method('find') |
92 | | - ->with(1) |
93 | | - ->willReturn(null); |
94 | | - $this->wishlistProductFactory |
95 | | - ->expects($this->never()) |
96 | | - ->method('createForWishlistAndProduct') |
97 | | - ->with($this->wishlist, $this->product) |
98 | | - ->willReturn($this->wishlistProduct); |
99 | | - $this->wishlist |
100 | | - ->expects($this->never()) |
101 | | - ->method('addWishlistProduct') |
102 | | - ->with($this->wishlistProduct); |
103 | | - $this->wishlistManager |
104 | | - ->expects($this->never()) |
105 | | - ->method('persist') |
106 | | - ->with($this->wishlistProduct); |
107 | | - $this->wishlistManager |
108 | | - ->expects($this->never()) |
109 | | - ->method('flush'); |
110 | | - |
111 | | - $this->handler->__invoke($this->command); |
| 82 | + $this->productRepository->expects($this->once())->method('find')->with(1)->willReturn(null); |
| 83 | + $this->wishlistProductFactory->expects($this->never())->method('createForWishlistAndProduct')->with($this->wishlist, $this->product)->willReturn($this->wishlistProduct); |
| 84 | + $this->wishlist->expects($this->never())->method('addWishlistProduct')->with($this->wishlistProduct); |
| 85 | + $this->wishlistManager->expects($this->never())->method('persist')->with($this->wishlistProduct); |
| 86 | + $this->wishlistManager->expects($this->never())->method('flush'); |
| 87 | + |
| 88 | + ($this->handler)($this->command); |
112 | 89 | } |
113 | 90 | } |
0 commit comments