Skip to content

Commit 950b5e5

Browse files
committed
MAGETWO-37935: Bugfix PR
- Fix unit tests
1 parent 765823e commit 950b5e5

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ protected function setUp()
201201
->disableOriginalConstructor()->getMock();
202202
$this->mimeTypeExtensionMapMock =
203203
$this->getMockBuilder('Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap')->getMock();
204-
$this->contentFactoryMock = $this->getMockBuilder(
205-
'Magento\Framework\Api\Data\ImageContentInterfaceFactory'
206-
)->disableOriginalConstructor()->setMethods(['create'])->getMockForAbstractClass();
204+
$this->contentFactoryMock = $this->getMock('Magento\Framework\Api\Data\ImageContentInterfaceFactory', ['create'], [], '', false);
207205
$this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface')
208206
->disableOriginalConstructor()
209207
->getMock();

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

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@ class PreviewTest extends \PHPUnit_Framework_TestCase
1313
protected $objectManager;
1414

1515
/**
16-
* @var \Magento\Newsletter\Model\Template
16+
* @var \Magento\Newsletter\Model\Template|\PHPUnit_Framework_MockObject_MockObject
1717
*/
1818
protected $template;
1919

2020
/**
21-
* @var \Magento\Framework\App\RequestInterface
21+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
2222
*/
2323
protected $request;
2424

2525
/**
26-
* @var \Magento\Newsletter\Model\Queue
26+
* @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
protected $subscriber;
29+
30+
/**
31+
* @var \Magento\Newsletter\Model\Queue|\PHPUnit_Framework_MockObject_MockObject
2732
*/
2833
protected $queue;
2934

3035
/**
31-
* @var \Magento\Store\Model\StoreManagerInterface
36+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
3237
*/
3338
protected $storeManager;
3439

@@ -39,30 +44,44 @@ class PreviewTest extends \PHPUnit_Framework_TestCase
3944

4045
public function setUp()
4146
{
42-
$templateFactory = $this->getMock('Magento\Newsletter\Model\TemplateFactory', ['create'], [], '', false);
43-
$this->template = $this->getMock('Magento\Newsletter\Model\Template', [], [], '', false);
44-
$templateFactory->expects($this->once())->method('create')->will($this->returnValue($this->template));
45-
$queueFactory = $this->getMock('Magento\Newsletter\Model\QueueFactory', ['create'], [], '', false);
46-
$this->queue = $this->getMock('Magento\Newsletter\Model\Queue', ['load'], [], '', false);
47-
$queueFactory->expects($this->any())->method('create')->will($this->returnValue($this->queue));
48-
47+
$context = $this->getMock('Magento\Backend\Block\Template\Context', [], [], '', false);
48+
$eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false);
49+
$context->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager));
50+
$scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false);
51+
$context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig));
4952
$this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
53+
$context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
5054
$this->storeManager = $this->getMock(
5155
'Magento\Store\Model\StoreManager',
5256
['getStores', 'getDefaultStoreView'],
5357
[],
5458
'',
5559
false
5660
);
61+
$context->expects($this->once())->method('getStoreManager')->will($this->returnValue($this->storeManager));
62+
$appState = $this->getMock('Magento\Framework\App\State', [], [], '', false);
63+
$context->expects($this->once())->method('getAppState')->will($this->returnValue($appState));
64+
65+
$templateFactory = $this->getMock('Magento\Newsletter\Model\TemplateFactory', ['create'], [], '', false);
66+
$this->template = $this->getMock('Magento\Newsletter\Model\Template', [], [], '', false);
67+
$templateFactory->expects($this->once())->method('create')->will($this->returnValue($this->template));
68+
69+
$subscriberFactory = $this->getMock('Magento\Newsletter\Model\SubscriberFactory', ['create'], [], '', false);
70+
$this->subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', [], [], '', false);
71+
$subscriberFactory->expects($this->once())->method('create')->will($this->returnValue($this->subscriber));
72+
73+
$queueFactory = $this->getMock('Magento\Newsletter\Model\QueueFactory', ['create'], [], '', false);
74+
$this->queue = $this->getMock('Magento\Newsletter\Model\Queue', ['load'], [], '', false);
75+
$queueFactory->expects($this->any())->method('create')->will($this->returnValue($this->queue));
5776

5877
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
5978
$this->preview = $this->objectManager->getObject(
6079
'Magento\Newsletter\Block\Adminhtml\Queue\Preview',
6180
[
81+
'context' => $context,
6282
'templateFactory' => $templateFactory,
83+
'subscriberFactory' => $subscriberFactory,
6384
'queueFactory' => $queueFactory,
64-
'request' => $this->request,
65-
'storeManager' => $this->storeManager
6685
]
6786
);
6887
}

app/code/Magento/Quote/Test/Unit/Model/AddressDetailsManagementTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class AddressDetailsManagementTest extends \PHPUnit_Framework_TestCase
5555
protected function setUp()
5656
{
5757
$this->objectManager = new ObjectManager($this);
58-
$this->billingAddressManagement = $this->getMock('\Magento\Quote\Api\BillingAddressManagementInterface');
59-
$this->shippingAddressManagement = $this->getMock('\Magento\Quote\Api\ShippingAddressManagementInterface');
60-
$this->paymentMethodManagement = $this->getMock('\Magento\Quote\Api\PaymentMethodManagementInterface');
61-
$this->shippingMethodManagement = $this->getMock('\Magento\Quote\Api\ShippingMethodManagementInterface');
62-
$this->addressDetailsFactory = $this->getMock('\Magento\Quote\Model\AddressDetailsFactory', [], [], '', false);
63-
$this->dataProcessor = $this->getMock('\Magento\Quote\Model\AddressAdditionalDataProcessor', [], [], '', false);
58+
$this->billingAddressManagement = $this->getMock('Magento\Quote\Api\BillingAddressManagementInterface');
59+
$this->shippingAddressManagement = $this->getMock('Magento\Quote\Api\ShippingAddressManagementInterface');
60+
$this->paymentMethodManagement = $this->getMock('Magento\Quote\Api\PaymentMethodManagementInterface');
61+
$this->shippingMethodManagement = $this->getMock('Magento\Quote\Api\ShippingMethodManagementInterface');
62+
$this->addressDetailsFactory = $this->getMock('Magento\Quote\Model\AddressDetailsFactory', ['create'], [], '', false);
63+
$this->dataProcessor = $this->getMock('Magento\Quote\Model\AddressAdditionalDataProcessor', [], [], '', false);
6464
$this->quoteRepository = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false);
6565

6666
$this->model = $this->objectManager->getObject(

app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function ($value) {
196196
);
197197
$this->serviceOrderFactory = $this->getMock(
198198
'Magento\Sales\Model\Service\OrderFactory',
199-
[],
199+
['create'],
200200
[],
201201
'',
202202
false

0 commit comments

Comments
 (0)