Skip to content

Commit 097518f

Browse files
committed
ACP2E-3490: Product Content Type in Page Builder Gets Collapsed Without Correct Messages
1 parent 2e2e6a6 commit 097518f

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
use Magento\Directory\Model\Currency;
1818
use Magento\Framework\App\Http\Context;
1919
use Magento\Framework\App\RequestInterface;
20+
use Magento\Framework\Cache\LockGuardedCacheLoader;
2021
use Magento\Framework\DataObject\IdentityInterface;
2122
use Magento\Framework\Pricing\PriceCurrencyInterface;
2223
use Magento\Framework\Pricing\Render;
2324
use Magento\Framework\Serialize\Serializer\Json;
2425
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
2526
use Magento\Framework\View\Design\ThemeInterface;
2627
use Magento\Framework\View\DesignInterface;
28+
use Magento\Catalog\Block\Product\Context as ViewContext;
2729
use Magento\Framework\View\LayoutInterface;
2830
use Magento\Rule\Model\Condition\Combine;
2931
use Magento\Rule\Model\Condition\Sql\Builder;
@@ -137,13 +139,14 @@ protected function setUp(): void
137139
'conditionsHelper' => $this->widgetConditionsHelper,
138140
'storeManager' => $this->storeManager,
139141
'design' => $this->design,
140-
'json' => $this->serializer
142+
'json' => $this->serializer,
141143
]
142144
);
143145
$this->request = $arguments['context']->getRequest();
144146
$this->layout = $arguments['context']->getLayout();
145147
$this->priceCurrency = $this->getMockForAbstractClass(PriceCurrencyInterface::class);
146148

149+
//$arguments['context'] = $this->viewContext;
147150
$this->productsList = $objectManagerHelper->getObject(
148151
ProductsList::class,
149152
$arguments
@@ -454,4 +457,56 @@ public function testScope()
454457
{
455458
$this->assertFalse($this->productsList->isScopePrivate());
456459
}
460+
461+
public function testTrimHtml()
462+
{
463+
$this->productsList->setData('conditions', []);
464+
465+
$collection = $this->getCollection();
466+
$this->getConditionsForCollection($collection);
467+
$this->productsList->setDat('html', ' ');
468+
469+
$this->assertEquals('', $this->productsList->toHtml());
470+
}
471+
472+
/**
473+
* @return MockObject
474+
*/
475+
private function getCollection() : MockObject
476+
{
477+
$this->visibility->expects($this->once())->method('getVisibleInCatalogIds')
478+
->willReturn([Visibility::VISIBILITY_IN_CATALOG, Visibility::VISIBILITY_BOTH]);
479+
$collection = $this->getMockBuilder(Collection::class)
480+
->onlyMethods([
481+
'setVisibility',
482+
'addMinimalPrice',
483+
'addFinalPrice',
484+
'addTaxPercents',
485+
'addAttributeToSelect',
486+
'addUrlRewrite',
487+
'addStoreFilter',
488+
'addAttributeToSort',
489+
'setPageSize',
490+
'setCurPage',
491+
'distinct'
492+
])->disableOriginalConstructor()
493+
->getMock();
494+
$collection->expects($this->once())->method('setVisibility')
495+
->with([Visibility::VISIBILITY_IN_CATALOG, Visibility::VISIBILITY_BOTH])
496+
->willReturnSelf();
497+
$collection->expects($this->once())->method('addMinimalPrice')->willReturnSelf();
498+
$collection->expects($this->once())->method('addFinalPrice')->willReturnSelf();
499+
$collection->expects($this->once())->method('addTaxPercents')->willReturnSelf();
500+
$collection->expects($this->once())->method('addAttributeToSelect')->willReturnSelf();
501+
$collection->expects($this->once())->method('addUrlRewrite')->willReturnSelf();
502+
$collection->expects($this->once())->method('addStoreFilter')->willReturnSelf();
503+
$collection->expects($this->once())->method('addAttributeToSort')->willReturnSelf();
504+
$collection->expects($this->once())->method('setPageSize')->willReturnSelf();
505+
$collection->expects($this->once())->method('setCurPage')->willReturnSelf();
506+
$collection->expects($this->once())->method('distinct')->willReturnSelf();
507+
508+
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
509+
510+
return $collection;
511+
}
457512
}

0 commit comments

Comments
 (0)