forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
magento#12147: The function "isUsingStaticUrlsAllowed" (configuration…
… setting "cms/wysiwyg/use_static_urls_in_catalog") doesn't have any effect with the WYSIWYG editor image insertion
- Loading branch information
1 parent
5bd0104
commit 26a83d5
Showing
2 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...e/Magento/Catalog/Test/Unit/Observer/CatalogCheckIsUsingStaticUrlsAllowedObserverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Test\Unit\Observer; | ||
|
||
use Magento\Catalog\Helper\Data; | ||
use Magento\Catalog\Observer\CatalogCheckIsUsingStaticUrlsAllowedObserver; | ||
use Magento\Framework\Event; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Provide tests for CatalogCheckIsUsingStaticUrlsAllowedObserver observer. | ||
*/ | ||
class CatalogCheckIsUsingStaticUrlsAllowedObserverTest extends TestCase | ||
{ | ||
/** | ||
* Test subject. | ||
* | ||
* @var CatalogCheckIsUsingStaticUrlsAllowedObserver | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var Data|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $catalogData; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$objectManager = new ObjectManager($this); | ||
$this->catalogData = $this->getMockBuilder(Data::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->model = $objectManager->getObject( | ||
CatalogCheckIsUsingStaticUrlsAllowedObserver::class, | ||
['catalogData' => $this->catalogData] | ||
); | ||
} | ||
|
||
/** | ||
* Test observer can correctly handle non integer store id values. | ||
* | ||
* @dataProvider executeDataProvider | ||
* @param string|int $storeId | ||
* @return void | ||
*/ | ||
public function testExecute($storeId) | ||
{ | ||
$result = new \stdClass(); | ||
/** @var Observer|\PHPUnit_Framework_MockObject_MockObject $observer */ | ||
$observer = $this->getMockBuilder(Observer::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$event = $this->getMockBuilder(Event::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$event->expects($this->exactly(2)) | ||
->method('getData') | ||
->withConsecutive( | ||
$this->identicalTo('store_id'), | ||
$this->identicalTo('result') | ||
)->willReturnOnConsecutiveCalls( | ||
$storeId, | ||
$result | ||
); | ||
$observer->expects($this->exactly(2)) | ||
->method('getEvent') | ||
->willReturn($event); | ||
$this->catalogData->expects($this->once()) | ||
->method('setStoreId') | ||
->with(0) | ||
->willReturnSelf(); | ||
$this->catalogData->expects($this->once()) | ||
->method('isUsingStaticUrlsAllowed') | ||
->willReturn(true); | ||
$this->model->execute($observer); | ||
$this->assertTrue($result->isAllowed); | ||
} | ||
|
||
/** | ||
* Provide test data for testExecute(). | ||
* | ||
* @return array | ||
*/ | ||
public function executeDataProvider() | ||
{ | ||
return [ | ||
[ | ||
'store_id' => 0, | ||
], | ||
[ | ||
'store_id' => '' | ||
] | ||
]; | ||
} | ||
} |