Skip to content

Commit cd7a64e

Browse files
committed
Remove obsolete plugin method request parameter and clean up test class properties
1 parent 8d209c3 commit cd7a64e

File tree

4 files changed

+39
-45
lines changed

4 files changed

+39
-45
lines changed

app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,15 @@ class ContextPluginTest extends \PHPUnit\Framework\TestCase
2424
protected $customerSessionMock;
2525

2626
/**
27-
* @var \Magento\Framework\App\Http\Context $httpContext|\PHPUnit_Framework_MockObject_MockObject
27+
* @var \Magento\Framework\App\Http\Context|\PHPUnit_Framework_MockObject_MockObject
2828
*/
2929
protected $httpContextMock;
3030

3131
/**
32-
* @var \PHPUnit_Framework_MockObject_MockObject
32+
* @var \Magento\Framework\App\Action\Action|\PHPUnit_Framework_MockObject_MockObject
3333
*/
3434
protected $subjectMock;
3535

36-
/**
37-
* @var \PHPUnit_Framework_MockObject_MockObject
38-
*/
39-
protected $requestMock;
40-
4136
/**
4237
* Set up
4338
*/
@@ -46,7 +41,6 @@ protected function setUp()
4641
$this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
4742
$this->httpContextMock = $this->createMock(\Magento\Framework\App\Http\Context::class);
4843
$this->subjectMock = $this->createMock(\Magento\Framework\App\Action\Action::class);
49-
$this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
5044
$this->plugin = new \Magento\Customer\Model\App\Action\ContextPlugin(
5145
$this->customerSessionMock,
5246
$this->httpContextMock
@@ -71,6 +65,6 @@ public function testBeforeExecute()
7165
]
7266
)
7367
);
74-
$this->plugin->beforeExecute($this->subjectMock, $this->requestMock);
68+
$this->plugin->beforeExecute($this->subjectMock);
7569
}
7670
}

app/code/Magento/Store/Test/Unit/App/Action/Plugin/StoreCheckTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,20 @@ class StoreCheckTest extends \PHPUnit\Framework\TestCase
1313
protected $_plugin;
1414

1515
/**
16-
* @var \PHPUnit_Framework_MockObject_MockObject
16+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
1717
*/
1818
protected $_storeManagerMock;
1919

2020
/**
21-
* @var \PHPUnit_Framework_MockObject_MockObject
21+
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
2222
*/
2323
protected $_storeMock;
2424

2525
/**
2626
* @var \Magento\Framework\App\Action\AbstractAction|\PHPUnit_Framework_MockObject_MockObject
2727
*/
2828
protected $subjectMock;
29-
30-
/**
31-
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
32-
*/
33-
protected $requestMock;
34-
29+
3530
protected function setUp()
3631
{
3732
$this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
@@ -43,7 +38,6 @@ protected function setUp()
4338
)->will(
4439
$this->returnValue($this->_storeMock)
4540
);
46-
$this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
4741
$this->subjectMock = $this->getMockBuilder(\Magento\Framework\App\Action\AbstractAction::class)
4842
->disableOriginalConstructor()
4943
->getMockForAbstractClass();
@@ -58,13 +52,13 @@ protected function setUp()
5852
public function testBeforeExecuteWhenStoreNotActive()
5953
{
6054
$this->_storeMock->expects($this->any())->method('isActive')->will($this->returnValue(false));
61-
$this->_plugin->beforeExecute($this->subjectMock, $this->requestMock);
55+
$this->_plugin->beforeExecute($this->subjectMock);
6256
}
6357

6458
public function testBeforeExecuteWhenStoreIsActive()
6559
{
6660
$this->_storeMock->expects($this->any())->method('isActive')->will($this->returnValue(true));
67-
$result = $this->_plugin->beforeExecute($this->subjectMock, $this->requestMock);
61+
$result = $this->_plugin->beforeExecute($this->subjectMock);
6862
$this->assertNull($result);
6963
}
7064
}

app/code/Magento/Theme/Test/Unit/Model/Theme/Plugin/RegistrationTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ class RegistrationTest extends \PHPUnit\Framework\TestCase
2121
/** @var ActionInterface|\PHPUnit_Framework_MockObject_MockObject */
2222
protected $action;
2323

24-
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
25-
protected $request;
26-
2724
/** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */
2825
protected $appState;
2926

@@ -41,7 +38,6 @@ protected function setUp()
4138
$this->themeRegistration = $this->createMock(\Magento\Theme\Model\Theme\Registration::class);
4239
$this->logger = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class, [], '', false);
4340
$this->action = $this->createMock(ActionInterface::class);
44-
$this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false);
4541
$this->appState = $this->createMock(\Magento\Framework\App\State::class);
4642
$this->themeCollection = $this->createMock(\Magento\Theme\Model\Theme\Collection::class);
4743
$this->themeLoader = $this->createMock(\Magento\Theme\Model\ResourceModel\Theme\Collection::class);
@@ -160,7 +156,7 @@ public function dataProviderBeforeExecute()
160156
public function testBeforeDispatchWithProductionMode()
161157
{
162158
$this->appState->expects($this->once())->method('getMode')->willReturn('production');
163-
$this->plugin->beforeExecute($this->action, $this->request);
159+
$this->plugin->beforeExecute($this->action);
164160
}
165161

166162
public function testBeforeDispatchWithException()
@@ -169,6 +165,6 @@ public function testBeforeDispatchWithException()
169165
$this->themeRegistration->expects($this->once())->method('register')->willThrowException($exception);
170166
$this->logger->expects($this->once())->method('critical');
171167

172-
$this->plugin->beforeExecute($this->action, $this->request);
168+
$this->plugin->beforeExecute($this->action);
173169
}
174170
}

app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,60 @@
1414
class ContextPluginTest extends \PHPUnit\Framework\TestCase
1515
{
1616
/**
17-
* @var \Magento\Tax\Helper\Data
17+
* @var \Magento\Tax\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
1818
*/
1919
protected $taxHelperMock;
2020

2121
/**
22-
* @var \Magento\Weee\Helper\Data
22+
* @var \Magento\Weee\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
2323
*/
2424
protected $weeeHelperMock;
2525

2626
/**
27-
* @var \Magento\Weee\Model\Tax
27+
* @var \Magento\Weee\Model\Tax|\PHPUnit_Framework_MockObject_MockObject
2828
*/
2929
protected $weeeTaxMock;
3030

3131
/**
32-
* @var \Magento\Framework\App\Http\Context
32+
* @var \Magento\Framework\App\Http\Context|\PHPUnit_Framework_MockObject_MockObject
3333
*/
3434
protected $httpContextMock;
3535

3636
/**
37-
* @var \Magento\Tax\Model\Calculation\Proxy
37+
* @var \Magento\Tax\Model\Calculation\Proxy|\PHPUnit_Framework_MockObject_MockObject
3838
*/
3939
protected $taxCalculationMock;
4040

4141
/**
42-
* @var \Magento\Framework\Module\Manager
42+
* @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject
4343
*/
4444
protected $moduleManagerMock;
4545

4646
/**
47-
* @var \Magento\PageCache\Model\Config
47+
* @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject
4848
*/
4949
protected $cacheConfigMock;
5050

5151
/**
52-
* @var \Magento\Store\Model\StoreManager
52+
* @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject
5353
*/
54-
protected $storeManageMock;
54+
protected $storeManagerMock;
5555

5656
/**
57-
* @var \Magento\Framework\App\Config\ScopeConfig
57+
* @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject
5858
*/
5959
protected $scopeConfigMock;
6060

61+
/**
62+
* @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
63+
*/
64+
private $customerSessionMock;
65+
66+
/**
67+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
68+
*/
69+
private $objectManager;
70+
6171
/**
6272
* @var \Magento\Tax\Model\App\Action\ContextPlugin
6373
*/
@@ -98,7 +108,7 @@ protected function setUp()
98108
$this->cacheConfigMock = $this->getMockBuilder(\Magento\PageCache\Model\Config::class)
99109
->disableOriginalConstructor()
100110
->getMock();
101-
111+
102112
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManager::class)
103113
->disableOriginalConstructor()
104114
->getMock();
@@ -185,10 +195,10 @@ public function testBeforeExecuteBasedOnDefault()
185195
->method('setValue')
186196
->with('weee_tax_region', ['countryId' => 'US', 'regionId' => 0], 0);
187197

198+
/** @var \Magento\Framework\App\Test\Unit\Action\Stub\ActionStub $action */
188199
$action = $this->objectManager->getObject(\Magento\Framework\App\Test\Unit\Action\Stub\ActionStub::class);
189-
$request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getActionName']);
190200

191-
$this->contextPlugin->beforeExecute($action, $request);
201+
$this->contextPlugin->beforeExecute($action);
192202
}
193203

194204
public function testBeforeExecuteBasedOnOrigin()
@@ -214,10 +224,10 @@ public function testBeforeExecuteBasedOnOrigin()
214224
->method('getTaxBasedOn')
215225
->willReturn('origin');
216226

227+
/** @var \Magento\Framework\App\Test\Unit\Action\Stub\ActionStub $action */
217228
$action = $this->objectManager->getObject(\Magento\Framework\App\Test\Unit\Action\Stub\ActionStub::class);
218-
$request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getActionName']);
219229

220-
$this->contextPlugin->beforeExecute($action, $request);
230+
$this->contextPlugin->beforeExecute($action);
221231
}
222232

223233
public function testBeforeExecuteBasedOnBilling()
@@ -286,10 +296,10 @@ public function testBeforeExecuteBasedOnBilling()
286296
->method('setValue')
287297
->with('weee_tax_region', ['countryId' => 'US', 'regionId' => 1], 0);
288298

299+
/** @var \Magento\Framework\App\Test\Unit\Action\Stub\ActionStub $action */
289300
$action = $this->objectManager->getObject(\Magento\Framework\App\Test\Unit\Action\Stub\ActionStub::class);
290-
$request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getActionName']);
291301

292-
$this->contextPlugin->beforeExecute($action, $request);
302+
$this->contextPlugin->beforeExecute($action);
293303
}
294304

295305
public function testBeforeExecuterBasedOnShipping()
@@ -358,9 +368,9 @@ public function testBeforeExecuterBasedOnShipping()
358368
->method('setValue')
359369
->with('weee_tax_region', ['countryId' => 'US', 'regionId' => 1], 0);
360370

371+
/** @var \Magento\Framework\App\Test\Unit\Action\Stub\ActionStub $action */
361372
$action = $this->objectManager->getObject(\Magento\Framework\App\Test\Unit\Action\Stub\ActionStub::class);
362-
$request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getActionName']);
363373

364-
$this->contextPlugin->beforeExecute($action, $request);
374+
$this->contextPlugin->beforeExecute($action);
365375
}
366376
}

0 commit comments

Comments
 (0)