Skip to content

Commit 578e284

Browse files
author
Vladyslav Shcherbyna
committed
MAGETWO-37089: [Firedrakes] Unit test coverage for MLS10
1 parent ef82088 commit 578e284

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
}

0 commit comments

Comments
 (0)