|
12 | 12 | use Shopware\Core\Framework\Test\TestCaseBase\SalesChannelApiTestBehaviour; |
13 | 13 | use Shopware\Core\Framework\Test\TestDataCollection; |
14 | 14 | use Shopware\Core\Framework\Uuid\Uuid; |
| 15 | +use Symfony\Component\HttpFoundation\Response; |
15 | 16 |
|
16 | 17 | /** |
17 | 18 | * @group store-api |
@@ -120,6 +121,39 @@ public function testValidation(): void |
120 | 121 | static::assertEquals($response['errors'][1]['source']['pointer'], '/content'); |
121 | 122 | } |
122 | 123 |
|
| 124 | + public function testCustomerValidation(): void |
| 125 | + { |
| 126 | + $this->login(); |
| 127 | + |
| 128 | + $this->assertReviewCount(0); |
| 129 | + |
| 130 | + $id = Uuid::randomHex(); |
| 131 | + |
| 132 | + // Create review |
| 133 | + $this->browser->request('POST', $this->getUrl(), [ |
| 134 | + 'id' => $id, |
| 135 | + 'title' => 'Lorem ipsum dolor sit amet', |
| 136 | + 'content' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna', |
| 137 | + ]); |
| 138 | + |
| 139 | + // Re-login as another user |
| 140 | + $this->login(); |
| 141 | + |
| 142 | + // Try to use the id from previous review which is not attached to this customer |
| 143 | + $this->browser->request('POST', $this->getUrl(), [ |
| 144 | + 'id' => $id, |
| 145 | + 'title' => 'Lorem ipsum dolor sit amet', |
| 146 | + 'content' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna', |
| 147 | + ]); |
| 148 | + |
| 149 | + $response = $this->browser->getResponse(); |
| 150 | + |
| 151 | + static::assertSame(Response::HTTP_BAD_REQUEST, $response->getStatusCode()); |
| 152 | + $content = json_decode($response->getContent(), true); |
| 153 | + |
| 154 | + static::assertSame('VIOLATION::ENTITY_DOES_NOT_EXISTS', $content['errors'][0]['code']); |
| 155 | + } |
| 156 | + |
123 | 157 | private function assertReviewCount(int $expected): void |
124 | 158 | { |
125 | 159 | $count = $this->getContainer() |
|
0 commit comments