Skip to content

Commit 7d36238

Browse files
committed
Add failing test for wishlist product attribute loading
1 parent 1e9377a commit 7d36238

File tree

1 file changed

+66
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Wishlist/Model/ResourceModel/Item

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
4+
namespace Magento\Wishlist\Model\ResourceModel\Item;
5+
6+
7+
use Magento\Catalog\Model\Product;
8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\Wishlist\Model\Wishlist;
10+
use Magento\Catalog\Model\Attribute\Config;
11+
12+
class CollectionTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* @var ObjectManager
16+
*/
17+
private $objectManager;
18+
/**
19+
* @var Collection
20+
*/
21+
private $itemCollection;
22+
/**
23+
* @var Wishlist
24+
*/
25+
private $wishlist;
26+
/**
27+
* @var Config\Data
28+
*/
29+
private $attributeConfig;
30+
31+
protected function setUp()
32+
{
33+
$this->objectManager = ObjectManager::getInstance();
34+
$this->wishlist = $this->objectManager->create(Wishlist::class);
35+
$this->itemCollection = $this->objectManager->get(Collection::class);
36+
$this->attributeConfig = $this->objectManager->get(Config\Data::class);
37+
}
38+
/**
39+
* @magentoDataFixture Magento/Wishlist/_files/wishlist_shared.php
40+
* @magentoAppIsolation enabled
41+
* @magentoDbIsolation enabled
42+
*/
43+
public function testLoadedProductAttributes()
44+
{
45+
$this->addAttributesToWishlistConfig([
46+
'short_description',
47+
]);
48+
$this->wishlist->loadByCode('fixture_unique_code');
49+
$this->itemCollection->addWishlistFilter($this->wishlist);
50+
51+
/** @var Product $productOnWishlist */
52+
$productOnWishlist = $this->itemCollection->getFirstItem()->getProduct();
53+
$this->assertEquals('Simple Product', $productOnWishlist->getName());
54+
$this->assertEquals('Short description', $productOnWishlist->getData('short_description'));
55+
}
56+
57+
/**
58+
* @param $attributes
59+
*/
60+
private function addAttributesToWishlistConfig($attributes)
61+
{
62+
$this->attributeConfig->merge([
63+
'wishlist_item' => $attributes
64+
]);
65+
}
66+
}

0 commit comments

Comments
 (0)