Skip to content

Commit

Permalink
#7765: Filter block on category is still present also mode is to just…
Browse files Browse the repository at this point in the history
… show "static block"
  • Loading branch information
RomaKis committed Jan 4, 2018
1 parent a39e37f commit 39e0fd9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/code/Magento/LayeredNavigation/Block/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public function getFilters()
*/
public function canShowBlock()
{
return $this->visibilityFlag->isEnabled($this->getLayer(), $this->getFilters());
return $this->getLayer()->getCurrentCategory()->getDisplayMode() !== \Magento\Catalog\Model\Category::DM_PAGE
&& $this->visibilityFlag->isEnabled($this->getLayer(), $this->getFilters());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Magento\LayeredNavigation\Test\Unit\Block;

use Magento\Catalog\Model\Category;

class NavigationTest extends \PHPUnit\Framework\TestCase
{
/**
Expand Down Expand Up @@ -98,9 +100,62 @@ public function testCanShowBlock()
->method('isEnabled')
->with($this->catalogLayerMock, $filters)
->will($this->returnValue($enabled));

$category = $this->createMock(Category::class);
$this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category);
$category->expects($this->once())->method('getDisplayMode')->willReturn(Category::DM_PRODUCT);

$this->assertEquals($enabled, $this->model->canShowBlock());
}

/**
* Test canShowBlock() with different category display types.
*
* @param string $mode
* @param bool $result
*
* @dataProvider canShowBlockDataProvider
*/
public function testCanShowBlockWithDifferentDisplayModes(string $mode, bool $result)
{
$filters = ['To' => 'be', 'or' => 'not', 'to' => 'be'];

$this->filterListMock->expects($this->atLeastOnce())->method('getFilters')
->with($this->catalogLayerMock)
->will($this->returnValue($filters));
$this->assertEquals($filters, $this->model->getFilters());

$this->visibilityFlagMock
->expects($this->any())
->method('isEnabled')
->with($this->catalogLayerMock, $filters)
->will($this->returnValue(true));

$category = $this->createMock(Category::class);
$this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category);
$category->expects($this->once())->method('getDisplayMode')->willReturn($mode);

$this->assertEquals($result, $this->model->canShowBlock());
}

public function canShowBlockDataProvider()
{
return [
[
Category::DM_PRODUCT,
true,
],
[
Category::DM_PAGE,
false,
],
[
Category::DM_MIXED,
true,
],
];
}

public function testGetClearUrl()
{
$this->filterListMock->expects($this->any())->method('getFilters')->will($this->returnValue([]));
Expand Down

0 comments on commit 39e0fd9

Please sign in to comment.