Skip to content
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 24 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
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 Oct 4, 2017
c660fa9
[Documentation][API] - add product reviews api docs
paulstoicareea Oct 4, 2017
fb337a6
[Product Reviews API]: accept/reject endpoints with state machine
paulstoicareea Oct 5, 2017
0e2ccc9
[Unit Testing]: ProductReviewApi Controller
paulstoicareea Oct 5, 2017
0151d20
[Documentation]: add in toctree and map Product Reviews API
paulstoicareea Oct 5, 2017
9785c0e
[Documentation]: minor changes
paulstoicareea Oct 9, 2017
4aa26f9
[Product Reviews API] - minor changes
paulstoicareea Oct 9, 2017
de75e27
[Documentation]: fix malformed tables Product reviews API
paulstoicareea Oct 9, 2017
ca4a90a
[Product Reviews API] - minor changes for tests
paulstoicareea Oct 9, 2017
3c1048f
[Product Reviews API] - add API for product reviews
paulstoicareea Oct 4, 2017
bc07098
[Documentation][API] - add product reviews api docs
paulstoicareea Oct 4, 2017
5e41ae6
[Product Reviews API]: accept/reject endpoints with state machine
paulstoicareea Oct 5, 2017
e998b59
[Unit Testing]: ProductReviewApi Controller
paulstoicareea Oct 5, 2017
dd37af3
[Documentation]: add in toctree and map Product Reviews API
paulstoicareea Oct 5, 2017
0228602
[Documentation]: minor changes
paulstoicareea Oct 9, 2017
d571b9c
[Product Reviews API] - minor changes
paulstoicareea Oct 9, 2017
3933ed2
[Documentation]: fix malformed tables Product reviews API
paulstoicareea Oct 9, 2017
3cf247a
[Product Reviews API] - minor changes for tests
paulstoicareea Oct 9, 2017
859021c
[Documentation]: texts improvments Product reviews API
paulstoicareea Nov 17, 2017
ca795cb
Product review API syntax improvments
paulstoicareea Nov 17, 2017
78d2c96
Product Review API tests: review creation real inputs
paulstoicareea Nov 18, 2017
aca53a4
[Product Reviews API] - add API for product reviews
paulstoicareea Oct 4, 2017
27086bd
fix product reviews api test methods names, expected response
paulstoicareea Dec 5, 2017
e386f37
product reviews api test remove author, fix indentation
paulstoicareea Jan 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions tests/Controller/ProductReviewApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,27 @@
*/
final class ProductReviewApiTest extends JsonApiTestCase
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant

Copy link
Member

Choose a reason for hiding this comment

The 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');

Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -121,13 +122,13 @@ public function it_allows_create_product_review()
$product = $productReviewsData['product1'];

$data =
<<<EOT
<<<EOT
Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -348,7 +349,7 @@ private function getReviewListUrl(ProductInterface $product): string

/**
* @param ProductInterface $product
* @param ReviewInterface $productReview
* @param ReviewInterface $productReview
*
* @return string
*/
Expand Down
20 changes: 10 additions & 10 deletions tests/Responses/Expected/product_review/accept_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
Expand Down Expand Up @@ -45,13 +45,13 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "new",
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
},
"2": {
"id": @integer@,
Expand All @@ -67,14 +67,14 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "rejected",
"createdAt": @string@,
"updatedAt": @string@
}
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
}
},
"averageRating": 4,
"images": [],
Expand All @@ -87,6 +87,6 @@
}
}
},
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
}
36 changes: 18 additions & 18 deletions tests/Responses/Expected/product_review/create_response.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id": @integer@,
"title": "J_REVIEW",
"title": "A good product",
"rating": 3,
"comment": "J_REVIEW_COMMENT",
"comment": "This is a good product.",
"author": {
"id": @integer@,
"email": "j@example.com",
"emailCanonical": "j@example.com",
"email": "my_review@example.com",
"emailCanonical": "my_review@example.com",
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
Expand Down Expand Up @@ -43,13 +43,13 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "new",
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
},
{
"id": @integer@,
Expand All @@ -65,13 +65,13 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "new",
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
},
{
"id": @integer@,
Expand All @@ -87,13 +87,13 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "rejected",
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
}
],
"averageRating": 0,
Expand All @@ -102,11 +102,11 @@
"self": {
"href": "\/api\/v1\/products\/MUG_REVIEW_BEST"
},
"variants": {
"variants": {
"href": "\/api\/v1\/products\/MUG_REVIEW_BEST\/variants\/"
}
}
}
},
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
}
18 changes: 9 additions & 9 deletions tests/Responses/Expected/product_review/reject_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
Expand Down Expand Up @@ -45,13 +45,13 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "new",
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
},
"2": {
"id": @integer@,
Expand All @@ -67,13 +67,13 @@
"gender": "u",
"_links": {
"self": {
"href": @string@
"href": "@string@"
}
}
},
"status": "rejected",
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
}
},
"averageRating": 0,
Expand All @@ -87,6 +87,6 @@
}
}
},
"createdAt": @string@,
"updatedAt": @string@
"createdAt": "@string@.isDateTime()",
"updatedAt": "@string@.isDateTime()"
}
Loading