Skip to content

Commit 2a1d955

Browse files
committed
MAGETWO-37089: Unit test coverage
1 parent a80bbd7 commit 2a1d955

File tree

2 files changed

+113
-111
lines changed

2 files changed

+113
-111
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,22 @@ public function mockPay($hasForcedState, $forcedState)
367367
/**
368368
* @dataProvider payDataProvider
369369
* @param bool $hasForcedState
370-
* @param string|null $forcedState
370+
* @param float string|null $forcedState
371371
* @param float $orderTotalPaid
372372
* @param float $orderBaseTotalPaid
373373
* @param float $grandTotal
374374
* @param float $baseGrandTotal
375375
* @param float $expectedState
376-
* @param float $expectedTotalPaid
377-
* @param float $expectedBaseTotalPaid
378376
*/
379-
public function testPay($hasForcedState, $forcedState, $orderTotalPaid, $orderBaseTotalPaid, $grandTotal,
380-
$baseGrandTotal, $expectedState, $expectedTotalPaid, $expectedBaseTotalPaid)
381-
{
377+
public function testPay(
378+
$hasForcedState,
379+
$forcedState,
380+
$orderTotalPaid,
381+
$orderBaseTotalPaid,
382+
$grandTotal,
383+
$baseGrandTotal,
384+
$expectedState
385+
) {
382386
$this->mockPay($hasForcedState, $forcedState);
383387
$this->model->setGrandTotal($grandTotal);
384388
$this->model->setBaseGrandTotal($baseGrandTotal);
@@ -388,8 +392,6 @@ public function testPay($hasForcedState, $forcedState, $orderTotalPaid, $orderBa
388392
$this->assertEquals($this->model, $this->model->pay());
389393
$this->assertTrue($this->model->wasPayCalled());
390394
$this->assertEquals($expectedState, $this->model->getState());
391-
//$this->assertEquals($expectedTotalPaid, $this->model->getTotalPaid());
392-
//$this->assertEquals($expectedBaseTotalPaid, $this->model->getBaseTotalPaid());
393395
#second call of pay() method must do nothing
394396
$this->model->pay();
395397
}
@@ -398,7 +400,7 @@ public function payDataProvider()
398400
{
399401
//ToDo: fill data provider and uncomment assertings totals in testPay
400402
return [
401-
[true, 'payment_state', 10.99, 1.00, 10.99, 1.00, 'payment_state', 11.99, 11.99]
403+
[true, 'payment_state', 10.99, 1.00, 10.99, 1.00, 'payment_state']
402404
];
403405
}
404406
}
Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,102 @@
1-
<?php
2-
/**
3-
* Copyright © 2015 Magento. All rights reserved.
4-
* See COPYING.txt for license details.
5-
*/
6-
7-
namespace Magento\Sales\Test\Unit\Model\Order\Status;
8-
9-
use Magento\Sales\Model\Order\Status\History;
10-
11-
/**
12-
* Class HistoryTest
13-
*/
14-
class HistoryTest extends \PHPUnit_Framework_TestCase
15-
{
16-
/**
17-
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
18-
*/
19-
protected $objectManager;
20-
21-
/**
22-
* @var \Magento\Sales\Model\Order | \PHPUnit_Framework_MockObject_MockObject
23-
*/
24-
protected $order;
25-
26-
/**
27-
* @var History
28-
*/
29-
protected $model;
30-
31-
/**
32-
* @var \Magento\Store\Model\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject
33-
*/
34-
protected $storeManager;
35-
36-
protected function setUp()
37-
{
38-
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
39-
40-
$this->order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
41-
$this->storeManager = $this->getMockForAbstractClass(
42-
'Magento\Store\Model\StoreManagerInterface',
43-
[],
44-
'',
45-
false
46-
);
47-
48-
49-
50-
$this->model = $this->objectManager->getObject(
51-
'Magento\Sales\Model\Order\Status\History',
52-
['storeManager' => $this->storeManager]
53-
);
54-
}
55-
56-
public function testSetOrder()
57-
{
58-
$storeId = 1;
59-
$this->order->expects($this->once())->method('getStoreId')->willReturn($storeId);
60-
$this->model->setOrder($this->order);
61-
$this->assertEquals($this->order, $this->model->getOrder());
62-
}
63-
64-
public function testSetIsCustomerNotified()
65-
{
66-
$this->model->setIsCustomerNotified(true);
67-
$this->assertEquals(true, $this->model->getIsCustomerNotified());
68-
}
69-
70-
public function testSetIsCustomerNotifiedNotApplicable()
71-
{
72-
$this->model->setIsCustomerNotified();
73-
$this->assertEquals($this->model->isCustomerNotificationNotApplicable(), $this->model->getIsCustomerNotified());
74-
}
75-
76-
public function testGetStatusLabel()
77-
{
78-
$status = 'pending';
79-
$this->assertNull($this->model->getStatusLabel());
80-
$this->model->setStatus($status);
81-
$config = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false);
82-
$config->expects($this->once())->method('getStatusLabel')->with($status)->willReturn($status);
83-
$this->order->expects($this->once())->method('getConfig')->willReturn($config);
84-
$this->model->setOrder($this->order);
85-
$this->assertEquals($status, $this->model->getStatusLabel());
86-
}
87-
88-
public function testGetStoreFromStoreManager()
89-
{
90-
$resultStore = 1;
91-
$this->storeManager->expects($this->once())->method('getStore')->willReturn($resultStore);
92-
$this->assertEquals($resultStore, $this->model->getStore());
93-
}
94-
95-
public function testGetStoreFromOrder()
96-
{
97-
$resultStore = 1;
98-
$this->model->setOrder($this->order);
99-
$this->order->expects($this->once())->method('getStore')->willReturn($resultStore);
100-
$this->assertEquals($resultStore, $this->model->getStore());
101-
}
102-
}
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Unit\Model\Order\Status;
8+
9+
use Magento\Sales\Model\Order\Status\History;
10+
11+
/**
12+
* Class HistoryTest
13+
*/
14+
class HistoryTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
18+
*/
19+
protected $objectManager;
20+
21+
/**
22+
* @var \Magento\Sales\Model\Order | \PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
protected $order;
25+
26+
/**
27+
* @var History
28+
*/
29+
protected $model;
30+
31+
/**
32+
* @var \Magento\Store\Model\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject
33+
*/
34+
protected $storeManager;
35+
36+
protected function setUp()
37+
{
38+
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
39+
40+
$this->order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
41+
$this->storeManager = $this->getMockForAbstractClass(
42+
'Magento\Store\Model\StoreManagerInterface',
43+
[],
44+
'',
45+
false
46+
);
47+
48+
49+
50+
$this->model = $this->objectManager->getObject(
51+
'Magento\Sales\Model\Order\Status\History',
52+
['storeManager' => $this->storeManager]
53+
);
54+
}
55+
56+
public function testSetOrder()
57+
{
58+
$storeId = 1;
59+
$this->order->expects($this->once())->method('getStoreId')->willReturn($storeId);
60+
$this->model->setOrder($this->order);
61+
$this->assertEquals($this->order, $this->model->getOrder());
62+
}
63+
64+
public function testSetIsCustomerNotified()
65+
{
66+
$this->model->setIsCustomerNotified(true);
67+
$this->assertEquals(true, $this->model->getIsCustomerNotified());
68+
}
69+
70+
public function testSetIsCustomerNotifiedNotApplicable()
71+
{
72+
$this->model->setIsCustomerNotified();
73+
$this->assertEquals($this->model->isCustomerNotificationNotApplicable(), $this->model->getIsCustomerNotified());
74+
}
75+
76+
public function testGetStatusLabel()
77+
{
78+
$status = 'pending';
79+
$this->assertNull($this->model->getStatusLabel());
80+
$this->model->setStatus($status);
81+
$config = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false);
82+
$config->expects($this->once())->method('getStatusLabel')->with($status)->willReturn($status);
83+
$this->order->expects($this->once())->method('getConfig')->willReturn($config);
84+
$this->model->setOrder($this->order);
85+
$this->assertEquals($status, $this->model->getStatusLabel());
86+
}
87+
88+
public function testGetStoreFromStoreManager()
89+
{
90+
$resultStore = 1;
91+
$this->storeManager->expects($this->once())->method('getStore')->willReturn($resultStore);
92+
$this->assertEquals($resultStore, $this->model->getStore());
93+
}
94+
95+
public function testGetStoreFromOrder()
96+
{
97+
$resultStore = 1;
98+
$this->model->setOrder($this->order);
99+
$this->order->expects($this->once())->method('getStore')->willReturn($resultStore);
100+
$this->assertEquals($resultStore, $this->model->getStore());
101+
}
102+
}

0 commit comments

Comments
 (0)