-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Product reviews API #8772
Merged
Merged
Product reviews API #8772
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0f6966a
[Product Reviews API] - add API for product reviews
paulstoicareea c660fa9
[Documentation][API] - add product reviews api docs
paulstoicareea fb337a6
[Product Reviews API]: accept/reject endpoints with state machine
paulstoicareea 0e2ccc9
[Unit Testing]: ProductReviewApi Controller
paulstoicareea 0151d20
[Documentation]: add in toctree and map Product Reviews API
paulstoicareea 9785c0e
[Documentation]: minor changes
paulstoicareea 4aa26f9
[Product Reviews API] - minor changes
paulstoicareea de75e27
[Documentation]: fix malformed tables Product reviews API
paulstoicareea ca4a90a
[Product Reviews API] - minor changes for tests
paulstoicareea 3c1048f
[Product Reviews API] - add API for product reviews
paulstoicareea bc07098
[Documentation][API] - add product reviews api docs
paulstoicareea 5e41ae6
[Product Reviews API]: accept/reject endpoints with state machine
paulstoicareea e998b59
[Unit Testing]: ProductReviewApi Controller
paulstoicareea dd37af3
[Documentation]: add in toctree and map Product Reviews API
paulstoicareea 0228602
[Documentation]: minor changes
paulstoicareea d571b9c
[Product Reviews API] - minor changes
paulstoicareea 3933ed2
[Documentation]: fix malformed tables Product reviews API
paulstoicareea 3cf247a
[Product Reviews API] - minor changes for tests
paulstoicareea 859021c
[Documentation]: texts improvments Product reviews API
paulstoicareea ca795cb
Product review API syntax improvments
paulstoicareea 78d2c96
Product Review API tests: review creation real inputs
paulstoicareea aca53a4
[Product Reviews API] - add API for product reviews
paulstoicareea 27086bd
fix product reviews api test methods names, expected response
paulstoicareea e386f37
product reviews api test remove author, fix indentation
paulstoicareea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,26 +23,27 @@ | |
*/ | ||
final class ProductReviewApiTest extends JsonApiTestCase | ||
{ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant |
||
/** | ||
* @var array | ||
*/ | ||
private static $authorizedHeaderWithContentType = [ | ||
'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', | ||
'CONTENT_TYPE' => 'application/json', | ||
'CONTENT_TYPE' => 'application/json', | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private static $authorizedHeaderWithAccept = [ | ||
'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', | ||
'ACCEPT' => 'application/json', | ||
'ACCEPT' => 'application/json', | ||
]; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_does_not_allow_to_show_product_review_list_when_access_is_denied() | ||
public function it_does_not_allows_showing_product_review_list_when_access_is_denied() | ||
{ | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
||
|
@@ -58,7 +59,7 @@ public function it_does_not_allow_to_show_product_review_list_when_access_is_den | |
/** | ||
* @test | ||
*/ | ||
public function it_does_not_allow_to_show_product_review_when_it_does_not_exist() | ||
public function it_does_not_allows_showing_product_review_when_it_does_not_exist() | ||
{ | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
|
@@ -112,7 +113,7 @@ public function it_allows_indexing_product_reviews() | |
/** | ||
* @test | ||
*/ | ||
public function it_allows_create_product_review() | ||
public function it_allows_creating_product_review() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
@@ -121,13 +122,13 @@ public function it_allows_create_product_review() | |
$product = $productReviewsData['product1']; | ||
|
||
$data = | ||
<<<EOT | ||
<<<EOT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong indent |
||
{ | ||
"title": "J_REVIEW", | ||
"title": "A good product", | ||
"rating": "3", | ||
"comment": "J_REVIEW_COMMENT", | ||
"comment": "This is a good product.", | ||
"author": { | ||
"email": "j@example.com" | ||
"email": "my_review@example.com" | ||
} | ||
} | ||
EOT; | ||
|
@@ -141,7 +142,7 @@ public function it_allows_create_product_review() | |
/** | ||
* @test | ||
*/ | ||
public function it_does_not_allow_to_create_product_review_without_required_fields() | ||
public function it_does_not_allows_creating_product_review_without_required_fields() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
@@ -158,7 +159,7 @@ public function it_does_not_allow_to_create_product_review_without_required_fiel | |
/** | ||
* @test | ||
*/ | ||
public function it_does_not_allow_delete_product_review_if_it_does_not_exist() | ||
public function it_does_not_allows_deleting_product_review_if_it_does_not_exist() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
@@ -175,7 +176,7 @@ public function it_does_not_allow_delete_product_review_if_it_does_not_exist() | |
/** | ||
* @test | ||
*/ | ||
public function it_allows_delete_product_review() | ||
public function it_allows_deleting_product_review() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
@@ -215,7 +216,7 @@ public function it_allows_updating_information_about_product_review() | |
$productReview = $productReviewsData['productReview1']; | ||
|
||
$data = | ||
<<<EOT | ||
<<<EOT | ||
{ | ||
"title": "NEW_REVIEW_TITLE", | ||
"rating": "1", | ||
|
@@ -244,7 +245,7 @@ public function it_allows_updating_partial_information_about_product_review() | |
$productReview = $productReviewsData['productReview1']; | ||
|
||
$data = | ||
<<<EOT | ||
<<<EOT | ||
{ | ||
"comment": "A_NEW_REVIEW_COMMENT" | ||
} | ||
|
@@ -259,15 +260,15 @@ public function it_allows_updating_partial_information_about_product_review() | |
/** | ||
* @test | ||
*/ | ||
public function it_allows_accept_product_review() | ||
public function it_allows_accepting_product_review() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
||
/** @var ProductInterface $product */ | ||
$product = $productReviewsData['product1']; | ||
|
||
/** @var ReviewInterface $productReview */ | ||
/** @var ReviewInterface $productReview */ | ||
$productReview = $productReviewsData['productReview1']; | ||
|
||
$this->client->request('PATCH', $this->getReviewUrl($product, $productReview) . '/accept', [], [], static::$authorizedHeaderWithAccept); | ||
|
@@ -279,15 +280,15 @@ public function it_allows_accept_product_review() | |
/** | ||
* @test | ||
*/ | ||
public function it_does_not_allows_accept_product_review_if_it_has_not_new_status() | ||
public function it_does_not_allows_accepting_product_review_if_it_has_not_new_status() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
||
/** @var ProductInterface $product */ | ||
$product = $productReviewsData['product1']; | ||
|
||
/** @var ReviewInterface $productReview */ | ||
/** @var ReviewInterface $productReview */ | ||
$productReview = $productReviewsData['productReview3']; | ||
|
||
$this->client->request('POST', $this->getReviewUrl($product, $productReview) . '/accept', [], [], static::$authorizedHeaderWithAccept); | ||
|
@@ -299,15 +300,15 @@ public function it_does_not_allows_accept_product_review_if_it_has_not_new_statu | |
/** | ||
* @test | ||
*/ | ||
public function it_allows_reject_product_review() | ||
public function it_allows_rejecting_product_review() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
||
/** @var ProductInterface $product */ | ||
$product = $productReviewsData['product1']; | ||
|
||
/** @var ReviewInterface $productReview */ | ||
/** @var ReviewInterface $productReview */ | ||
$productReview = $productReviewsData['productReview1']; | ||
|
||
$this->client->request('PATCH', $this->getReviewUrl($product, $productReview) . '/reject', [], [], static::$authorizedHeaderWithAccept); | ||
|
@@ -316,18 +317,18 @@ public function it_allows_reject_product_review() | |
$this->assertResponse($response, 'product_review/reject_response', Response::HTTP_OK); | ||
} | ||
|
||
/** | ||
/** | ||
* @test | ||
*/ | ||
public function it_does_not_allows_reject_product_review_if_it_has_not_new_status() | ||
public function it_does_not_allows_rejecting_product_review_if_it_has_not_new_status() | ||
{ | ||
$this->loadFixturesFromFile('authentication/api_administrator.yml'); | ||
$productReviewsData = $this->loadFixturesFromFile('resources/product_reviews.yml'); | ||
|
||
/** @var ProductInterface $product */ | ||
$product = $productReviewsData['product1']; | ||
|
||
/** @var ReviewInterface $productReview */ | ||
/** @var ReviewInterface $productReview */ | ||
$productReview = $productReviewsData['productReview3']; | ||
|
||
$this->client->request('POST', $this->getReviewUrl($product, $productReview) . '/accept', [], [], static::$authorizedHeaderWithAccept); | ||
|
@@ -348,7 +349,7 @@ private function getReviewListUrl(ProductInterface $product): string | |
|
||
/** | ||
* @param ProductInterface $product | ||
* @param ReviewInterface $productReview | ||
* @param ReviewInterface $productReview | ||
* | ||
* @return string | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant