Skip to content

Commit

Permalink
Merge branch 'merchant_beta' into SUPEE-6995
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Nosov committed Oct 1, 2015
2 parents b6ffa78 + 3c06d03 commit 12bc0c1
Show file tree
Hide file tree
Showing 57 changed files with 1,483 additions and 555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,18 @@ class FilterableAttributeList implements FilterableAttributeListInterface
*/
protected $storeManager;

/**
* @var \Magento\Catalog\Model\Layer
*/
protected $layer;

/**
* FilterableAttributeList constructor
*
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
*/
public function __construct(
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Layer\Resolver $layerResolver
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->collectionFactory = $collectionFactory;
$this->storeManager = $storeManager;
$this->layer = $layerResolver->get();
}

/**
Expand All @@ -50,14 +42,9 @@ public function __construct(
*/
public function getList()
{
$setIds = $this->layer->getProductCollection()->getSetIds();
if (!$setIds) {
return [];
}
/** @var $collection \Magento\Catalog\Model\Resource\Product\Attribute\Collection */
$collection = $this->collectionFactory->create();
$collection->setItemObjectClass('Magento\Catalog\Model\Resource\Eav\Attribute')
->setAttributeSetFilter($setIds)
->addStoreLabel($this->storeManager->getStore()->getId())
->setOrder('position', 'ASC');
$collection = $this->_prepareAttributeCollection($collection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public function filter(
->addStoreFilter()
->addUrlRewrite()
->setVisibility($this->productVisibility->getVisibleInSearchIds())
->setOrder('relevance', Select::SQL_ASC);
->setOrder('relevance', Select::SQL_DESC);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

class FilterableAttributeList extends \Magento\Catalog\Model\Layer\Category\FilterableAttributeList
{
/**
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
*/
public function __construct(
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Layer\Resolver $layerResolver
) {
parent::__construct($collectionFactory, $storeManager, $layerResolver);
}

/**
* @param \Magento\Catalog\Model\Resource\Product\Attribute\Collection $collection
* @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase
*/
protected $storeManagerMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $layerMock;

protected function setUp()
{
$this->collectionFactoryMock = $this->getMock(
Expand All @@ -39,50 +34,15 @@ protected function setUp()
'\Magento\Store\Model\StoreManagerInterface', [], [], '', false
);

$this->layerMock = $this->getMock(
'Magento\Catalog\Model\Layer\Search', [], [], '', false
);

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */
$layerResolver = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Resolver')
->disableOriginalConstructor()
->setMethods(['get', 'create'])
->getMock();
$layerResolver->expects($this->any())
->method($this->anything())
->will($this->returnValue($this->layerMock));

$this->model = new \Magento\Catalog\Model\Layer\Search\FilterableAttributeList(
$this->collectionFactoryMock,
$this->storeManagerMock,
$layerResolver
);

}

public function testGetListWithEmptyIds()
{
$productCollectionMock = $this->getMock(
'\Magento\Catalog\Model\Resource\Product\Collection', [], [], '', false
$this->storeManagerMock
);
$this->layerMock->expects($this->once())->method('getProductCollection')
->will($this->returnValue($productCollectionMock));
$productCollectionMock->expects($this->once())->method('getSetIds')->will($this->returnValue([]));

$this->collectionFactoryMock->expects($this->never())->method('create');
$this->assertEquals([], $this->model->getList());
}

public function testGetList()
{
$productCollectionMock = $this->getMock(
'\Magento\Catalog\Model\Resource\Product\Collection', [], [], '', false
);
$this->layerMock->expects($this->once())->method('getProductCollection')
->will($this->returnValue($productCollectionMock));
$setIds = [2, 3, 5];
$productCollectionMock->expects($this->once())->method('getSetIds')->will($this->returnValue($setIds));

$storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));

Expand All @@ -102,11 +62,6 @@ public function testGetList()
->method('setItemObjectClass')
->with('Magento\Catalog\Model\Resource\Eav\Attribute')
->will($this->returnSelf());
$collectionMock
->expects($this->once())
->method('setAttributeSetFilter')
->with($setIds)
->will($this->returnSelf());
$collectionMock
->expects($this->once())
->method('addStoreLabel')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase
*/
protected $storeManagerMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $layerMock;

protected function setUp()
{
$this->collectionFactoryMock = $this->getMock(
Expand All @@ -39,23 +34,9 @@ protected function setUp()
'\Magento\Store\Model\StoreManagerInterface', [], [], '', false
);

$this->layerMock = $this->getMock(
'\Magento\Catalog\Model\Layer\Search', [], [], '', false
);

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver $layerResolver */
$layerResolver = $this->getMockBuilder('\Magento\Catalog\Model\Layer\Resolver')
->disableOriginalConstructor()
->setMethods(['get', 'create'])
->getMock();
$layerResolver->expects($this->any())
->method($this->anything())
->will($this->returnValue($this->layerMock));

$this->model = new \Magento\Catalog\Model\Layer\Search\FilterableAttributeList(
$this->collectionFactoryMock,
$this->storeManagerMock,
$layerResolver
$this->storeManagerMock
);

}
Expand All @@ -65,14 +46,6 @@ protected function setUp()
*/
public function testGetList()
{
$productCollectionMock = $this->getMock(
'\Magento\Catalog\Model\Resource\Product\Collection', [], [], '', false
);
$this->layerMock->expects($this->once())->method('getProductCollection')
->will($this->returnValue($productCollectionMock));
$setIds = [2, 3, 5];
$productCollectionMock->expects($this->once())->method('getSetIds')->will($this->returnValue($setIds));

$storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));

Expand All @@ -92,11 +65,6 @@ public function testGetList()
->method('setItemObjectClass')
->with('Magento\Catalog\Model\Resource\Eav\Attribute')
->will($this->returnSelf());
$collectionMock
->expects($this->once())
->method('setAttributeSetFilter')
->with($setIds)
->will($this->returnSelf());
$collectionMock
->expects($this->once())
->method('addStoreLabel')
Expand Down
Loading

0 comments on commit 12bc0c1

Please sign in to comment.