urlBuilder = $this->_objectManager->get(\Magento\Rss\Model\UrlBuilder::class); $this->customerRepository = $this->_objectManager->get( \Magento\Customer\Api\CustomerRepositoryInterface::class ); $this->wishlist = $this->_objectManager->get(\Magento\Wishlist\Model\Wishlist::class); $this->customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class); } /** * Check Rss response. * * @magentoAppIsolation enabled * @magentoDataFixture Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php * @magentoConfigFixture current_store rss/wishlist/active 1 * @magentoConfigFixture current_store rss/config/active 1 */ public function testRssResponse() { $firstCustomerId = 1; $this->customerSession->setCustomerId($firstCustomerId); $customer = $this->customerRepository->getById($firstCustomerId); $customerEmail = $customer->getEmail(); $wishlistId = $this->wishlist->loadByCustomerId($firstCustomerId)->getId(); $this->dispatch($this->getLink($firstCustomerId, $customerEmail, $wishlistId)); $body = $this->getResponse()->getBody(); $this->assertContains('John Smith\'s Wishlist', $body); } /** * Check Rss with incorrect wishlist id. * * @magentoAppIsolation enabled * @magentoDataFixture Magento/Wishlist/_files/two_wishlists_for_two_diff_customers.php * @magentoConfigFixture current_store rss/wishlist/active 1 * @magentoConfigFixture current_store rss/config/active 1 */ public function testRssResponseWithIncorrectWishlistId() { $firstCustomerId = 1; $secondCustomerId = 2; $this->customerSession->setCustomerId($firstCustomerId); $customer = $this->customerRepository->getById($firstCustomerId); $customerEmail = $customer->getEmail(); $wishlistId = $this->wishlist->loadByCustomerId($secondCustomerId, true)->getId(); $this->dispatch($this->getLink($firstCustomerId, $customerEmail, $wishlistId)); $body = $this->getResponse()->getBody(); $this->assertContains('404 Not Found', $body); } private function getLink($customerId, $customerEmail, $wishlistId) { return 'rss/feed/index/type/wishlist/data/' . base64_encode($customerId . ',' . $customerEmail) . '/wishlist_id/' . $wishlistId; } }