Skip to content

Commit

Permalink
Missing key model in Wishlist value data
Browse files Browse the repository at this point in the history
  • Loading branch information
XxXgeoXxX committed Mar 21, 2019
1 parent 0e8428c commit ef3cc36
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 ef3cc36

Please sign in to comment.