|
17 | 17 | use Magento\Directory\Model\Currency;
|
18 | 18 | use Magento\Framework\App\Http\Context;
|
19 | 19 | use Magento\Framework\App\RequestInterface;
|
| 20 | +use Magento\Framework\Cache\LockGuardedCacheLoader; |
20 | 21 | use Magento\Framework\DataObject\IdentityInterface;
|
21 | 22 | use Magento\Framework\Pricing\PriceCurrencyInterface;
|
22 | 23 | use Magento\Framework\Pricing\Render;
|
23 | 24 | use Magento\Framework\Serialize\Serializer\Json;
|
24 | 25 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
|
25 | 26 | use Magento\Framework\View\Design\ThemeInterface;
|
26 | 27 | use Magento\Framework\View\DesignInterface;
|
| 28 | +use Magento\Catalog\Block\Product\Context as ViewContext; |
27 | 29 | use Magento\Framework\View\LayoutInterface;
|
28 | 30 | use Magento\Rule\Model\Condition\Combine;
|
29 | 31 | use Magento\Rule\Model\Condition\Sql\Builder;
|
@@ -137,13 +139,14 @@ protected function setUp(): void
|
137 | 139 | 'conditionsHelper' => $this->widgetConditionsHelper,
|
138 | 140 | 'storeManager' => $this->storeManager,
|
139 | 141 | 'design' => $this->design,
|
140 |
| - 'json' => $this->serializer |
| 142 | + 'json' => $this->serializer, |
141 | 143 | ]
|
142 | 144 | );
|
143 | 145 | $this->request = $arguments['context']->getRequest();
|
144 | 146 | $this->layout = $arguments['context']->getLayout();
|
145 | 147 | $this->priceCurrency = $this->getMockForAbstractClass(PriceCurrencyInterface::class);
|
146 | 148 |
|
| 149 | + //$arguments['context'] = $this->viewContext; |
147 | 150 | $this->productsList = $objectManagerHelper->getObject(
|
148 | 151 | ProductsList::class,
|
149 | 152 | $arguments
|
@@ -454,4 +457,56 @@ public function testScope()
|
454 | 457 | {
|
455 | 458 | $this->assertFalse($this->productsList->isScopePrivate());
|
456 | 459 | }
|
| 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 | + } |
457 | 512 | }
|
0 commit comments