Skip to content

Commit df2a84a

Browse files
committed
Merge remote-tracking branch 'origin/phpunit8' into phpunit8/module-ImportExport
2 parents 7433734 + 0537aa9 commit df2a84a

File tree

65 files changed

+1234
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1234
-734
lines changed

app/code/Magento/Cms/Model/Wysiwyg/Gallery/DefaultConfigProvider.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
namespace Magento\Cms\Model\Wysiwyg\Gallery;
1010

11+
use Magento\Ui\Component\Form\Element\DataType\Media\OpenDialogUrl;
12+
13+
/**
14+
* @inheritdoc
15+
*/
1116
class DefaultConfigProvider implements \Magento\Framework\Data\Wysiwyg\ConfigProviderInterface
1217
{
1318
/**
@@ -30,26 +35,34 @@ class DefaultConfigProvider implements \Magento\Framework\Data\Wysiwyg\ConfigPro
3035
*/
3136
private $currentTreePath;
3237

38+
/**
39+
* @var OpednDialogUrl
40+
*/
41+
private $openDialogUrl;
42+
3343
/**
3444
* @param \Magento\Backend\Model\UrlInterface $backendUrl
3545
* @param \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper
46+
* @param OpenDialogUrl $openDialogUrl
3647
* @param array $windowSize
3748
* @param string|null $currentTreePath
3849
*/
3950
public function __construct(
4051
\Magento\Backend\Model\UrlInterface $backendUrl,
4152
\Magento\Cms\Helper\Wysiwyg\Images $imagesHelper,
53+
OpenDialogUrl $openDialogUrl,
4254
array $windowSize = [],
4355
$currentTreePath = null
4456
) {
4557
$this->backendUrl = $backendUrl;
4658
$this->imagesHelper = $imagesHelper;
59+
$this->openDialogUrl = $openDialogUrl;
4760
$this->windowSize = $windowSize;
4861
$this->currentTreePath = $currentTreePath;
4962
}
5063

5164
/**
52-
* {@inheritdoc}
65+
* @inheritdoc
5366
*/
5467
public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
5568
{
@@ -72,7 +85,7 @@ public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Fram
7285
[
7386
'add_images' => true,
7487
'files_browser_window_url' => $this->backendUrl->getUrl(
75-
'cms/wysiwyg_images/index',
88+
$this->openDialogUrl->get(),
7689
$fileBrowserUrlParams
7790
),
7891
'files_browser_window_width' => $this->windowSize['width'],
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminDisableWYSIWYGActionGroup">
12+
<annotations>
13+
<description>Runs bin/magento command to disable WYSIWYG</description>
14+
</annotations>
15+
16+
<magentoCLI stepKey="disableWYSIWYG" command="config:set cms/wysiwyg/enabled disabled"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminEnableWYSIWYGActionGroup">
12+
<annotations>
13+
<description>Runs bin/magento command to enable WYSIWYG</description>
14+
</annotations>
15+
16+
<magentoCLI stepKey="enableWYSIWYG" command="config:set cms/wysiwyg/enabled enabled"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/Cms/Test/Mftf/ActionGroup/AssertStorefrontTextOnCategoryPageActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
<waitForPageLoad stepKey="waitForPageLoad1"/>
1717
<see selector="{{StorefrontCategoryMainSection.CategoryTitle}}" userInput="{{category.name_lwr}}" stepKey="assertCategoryOnStorefront"/>
1818
<seeInTitle userInput="{{category.name}}" stepKey="seeCategoryNameInTitle"/>
19-
<see selector="{{StorefrontCMSPageSection.mainContent}}" userInput="{{text}}" stepKey="seeAssertTextInMainContent"/>
19+
<see userInput="{{text}}" stepKey="seeAssertTextInMainContent"/>
2020
</actionGroup>
2121
</actionGroups>

dev/tests/acceptance/tests/_suite/WYSIWYGDisabledSuite.xml renamed to app/code/Magento/Cms/Test/Mftf/Suite/WYSIWYGDisabledSuite.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd">
99
<suite name="WYSIWYGDisabledSuite">
1010
<before>
11-
<magentoCLI stepKey="disableWYSYWYG" command="config:set cms/wysiwyg/enabled disabled" />
11+
<actionGroup ref="AdminDisableWYSIWYGActionGroup" stepKey="disableWYSYWYG" />
1212
</before>
1313
<include>
1414
<group name="WYSIWYGDisabled"/>
@@ -17,7 +17,7 @@
1717
<group name="skip"/>
1818
</exclude>
1919
<after>
20-
<magentoCLI stepKey="disableWYSYWYG" command="config:set cms/wysiwyg/enabled enabled" />
20+
<actionGroup ref="AdminEnableWYSIWYGActionGroup" stepKey="disableWYSYWYG" />
2121
</after>
2222
</suite>
2323
</suites>

app/code/Magento/Newsletter/Test/Unit/Block/Adminhtml/Queue/PreviewTest.php

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Magento\Framework\Escaper;
1717
use Magento\Framework\Event\ManagerInterface;
1818
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
19-
use Magento\Newsletter\Block\Adminhtml\Queue\Preview;
19+
use Magento\Newsletter\Block\Adminhtml\Queue\Preview as QueuePreview;
2020
use Magento\Newsletter\Model\Queue;
2121
use Magento\Newsletter\Model\QueueFactory;
2222
use Magento\Newsletter\Model\Subscriber;
@@ -32,85 +32,100 @@
3232
/**
3333
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3434
*/
35-
class PreviewTest extends TestCase
35+
class PreviewTest extends \PHPUnit\Framework\TestCase
3636
{
3737
/**
3838
* @var ObjectManager
3939
*/
40-
protected $objectManager;
40+
private $objectManager;
4141

4242
/**
4343
* @var Template|MockObject
4444
*/
45-
protected $template;
45+
private $templateMock;
4646

4747
/**
4848
* @var RequestInterface|MockObject
4949
*/
50-
protected $request;
50+
private $requestMock;
5151

5252
/**
5353
* @var Subscriber|MockObject
5454
*/
55-
protected $subscriber;
55+
private $subscriberMock;
5656

5757
/**
5858
* @var Queue|MockObject
5959
*/
60-
protected $queue;
60+
private $queueMock;
6161

6262
/**
6363
* @var StoreManagerInterface|MockObject
6464
*/
65-
protected $storeManager;
65+
private $storeManagerMock;
6666

6767
/**
68-
* @var Preview
68+
* @var QueuePreview
6969
*/
70-
protected $preview;
70+
private $preview;
7171

7272
protected function setUp(): void
7373
{
7474
$context = $this->createMock(Context::class);
7575
$eventManager = $this->createMock(ManagerInterface::class);
76-
$context->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager));
76+
$context->expects($this->once())->method('getEventManager')
77+
->will($this->returnValue($eventManager));
7778
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
78-
$context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig));
79-
$this->request = $this->createMock(Http::class);
80-
$context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
81-
$this->storeManager = $this->createPartialMock(
79+
$context->expects($this->once())->method('getScopeConfig')
80+
->will($this->returnValue($scopeConfig));
81+
$this->requestMock = $this->createMock(Http::class);
82+
$context->expects($this->once())->method('getRequest')
83+
->will($this->returnValue($this->requestMock));
84+
$this->storeManagerMock = $this->createPartialMock(
8285
StoreManager::class,
8386
['getStores', 'getDefaultStoreView']
8487
);
85-
$context->expects($this->once())->method('getStoreManager')->will($this->returnValue($this->storeManager));
88+
$context->expects($this->once())->method('getStoreManager')
89+
->will($this->returnValue($this->storeManagerMock));
8690
$appState = $this->createMock(State::class);
87-
$context->expects($this->once())->method('getAppState')->will($this->returnValue($appState));
91+
$context->expects($this->once())->method('getAppState')
92+
->will($this->returnValue($appState));
8893

8994
$backendSession = $this->getMockBuilder(Session::class)
9095
->disableOriginalConstructor()
9196
->getMock();
9297

93-
$context->expects($this->once())->method('getBackendSession')->willReturn($backendSession);
98+
$context->expects($this->once())
99+
->method('getBackendSession')
100+
->willReturn($backendSession);
94101

95102
$templateFactory = $this->createPartialMock(TemplateFactory::class, ['create']);
96-
$this->template = $this->createMock(Template::class);
97-
$templateFactory->expects($this->once())->method('create')->will($this->returnValue($this->template));
103+
$this->templateMock = $this->createMock(Template::class);
104+
$templateFactory->expects($this->once())
105+
->method('create')
106+
->will($this->returnValue($this->templateMock));
98107

99108
$subscriberFactory = $this->createPartialMock(SubscriberFactory::class, ['create']);
100-
$this->subscriber = $this->createMock(Subscriber::class);
101-
$subscriberFactory->expects($this->once())->method('create')->will($this->returnValue($this->subscriber));
109+
$this->subscriberMock = $this->createMock(Subscriber::class);
110+
$subscriberFactory->expects($this->once())
111+
->method('create')
112+
->will($this->returnValue($this->subscriberMock));
102113

103114
$queueFactory = $this->createPartialMock(QueueFactory::class, ['create']);
104-
$this->queue = $this->createPartialMock(Queue::class, ['load']);
105-
$queueFactory->expects($this->any())->method('create')->will($this->returnValue($this->queue));
115+
$this->queueMock = $this->createPartialMock(Queue::class, ['load']);
116+
$queueFactory->expects($this->any())
117+
->method('create')
118+
->will($this->returnValue($this->queueMock));
106119

107120
$this->objectManager = new ObjectManager($this);
108121

109122
$escaper = $this->objectManager->getObject(Escaper::class);
110-
$context->expects($this->once())->method('getEscaper')->willReturn($escaper);
123+
$context->expects($this->once())
124+
->method('getEscaper')
125+
->willReturn($escaper);
111126

112127
$this->preview = $this->objectManager->getObject(
113-
Preview::class,
128+
QueuePreview::class,
114129
[
115130
'context' => $context,
116131
'templateFactory' => $templateFactory,
@@ -124,27 +139,37 @@ public function testToHtmlEmpty()
124139
{
125140
/** @var Store $store */
126141
$store = $this->createPartialMock(Store::class, ['getId']);
127-
$this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue($store));
142+
$this->storeManagerMock->expects($this->once())
143+
->method('getDefaultStoreView')
144+
->will($this->returnValue($store));
128145
$result = $this->preview->toHtml();
129146
$this->assertEquals('', $result);
130147
}
131148

132149
public function testToHtmlWithId()
133150
{
134-
$this->request->expects($this->any())->method('getParam')->will(
151+
$this->requestMock->expects($this->any())->method('getParam')->will(
135152
$this->returnValueMap(
136153
[
137154
['id', null, 1],
138155
['store_id', null, 0]
139156
]
140157
)
141158
);
142-
$this->queue->expects($this->once())->method('load')->will($this->returnSelf());
143-
$this->template->expects($this->any())->method('isPlain')->will($this->returnValue(true));
159+
$this->queueMock->expects($this->once())
160+
->method('load')
161+
->will($this->returnSelf());
162+
$this->templateMock->expects($this->any())
163+
->method('isPlain')
164+
->will($this->returnValue(true));
144165
/** @var Store $store */
145-
$this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue(null));
166+
$this->storeManagerMock->expects($this->once())
167+
->method('getDefaultStoreView')
168+
->will($this->returnValue(null));
146169
$store = $this->createPartialMock(Store::class, ['getId']);
147-
$this->storeManager->expects($this->once())->method('getStores')->will($this->returnValue([0 => $store]));
170+
$this->storeManagerMock->expects($this->once())
171+
->method('getStores')
172+
->will($this->returnValue([0 => $store]));
148173
$result = $this->preview->toHtml();
149174
$this->assertEquals('<pre></pre>', $result);
150175
}

0 commit comments

Comments
 (0)