Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
ENGCOM-4572: Missing key model in Wishlist value data #506
Browse files Browse the repository at this point in the history
  • Loading branch information
naydav authored Mar 25, 2019
2 parents ab5486a + 3bcf336 commit 0371936
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Wishlist\Model\ResourceModel\Wishlist as WishlistResourceModel;
use Magento\Wishlist\Model\Wishlist;
use Magento\Wishlist\Model\WishlistFactory;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;

/**
* Fetches the Wishlist data according to the GraphQL schema
Expand Down Expand Up @@ -51,6 +52,10 @@ public function resolve(
) {
$customerId = $context->getUserId();

/* Guest checking */
if (!$customerId && 0 === $customerId) {
throw new GraphQlAuthorizationException(__('The current user cannot perform operations on wishlist'));
}
/** @var Wishlist $wishlist */
$wishlist = $this->wishlistFactory->create();
$this->wishlistResource->load($wishlist, $customerId, 'customer_id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,36 @@ public function testGetCustomerWishlist(): void
$this->assertEquals($wishlistItemProduct->getName(), $response['wishlist']['items'][0]['product']['name']);
}

/**
* @expectedException \Exception
* @expectedExceptionMessage The current user cannot perform operations on wishlist
*/
public function testGetGuestWishlist()
{
$query =
<<<QUERY
{
wishlist {
items_count
name
sharing_code
updated_at
items {
id
qty
description
added_at
product {
sku
name
}
}
}
}
QUERY;
$this->graphQlQuery($query);
}

/**
* @param string $email
* @param string $password
Expand Down

0 comments on commit 0371936

Please sign in to comment.