Skip to content

Commit 73e34b8

Browse files
author
Kostiantyn Poida
committed
MAGETWO-31363: Unit and Integration tests coverage
1 parent 1de6a42 commit 73e34b8

File tree

1 file changed

+74
-0
lines changed
  • dev/tests/unit/testsuite/Magento/OfflineShipping/Model/Plugin/Checkout/Block/Cart

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\OfflineShipping\Model\SalesRule;
7+
8+
class ShippingTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \Magento\OfflineShipping\Model\Plugin\Checkout\Block\Cart\Shipping
12+
*/
13+
protected $model;
14+
15+
/**
16+
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
protected $scopeConfigMock;
19+
20+
protected function setUp()
21+
{
22+
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
23+
24+
$this->scopeConfigMock = $this->getMockBuilder('\Magento\Framework\App\Config\ScopeConfigInterface')
25+
->disableOriginalConstructor()
26+
->setMethods([
27+
'getValue',
28+
'isSetFlag'
29+
])
30+
->getMock();
31+
32+
$this->model = $helper->getObject('\Magento\OfflineShipping\Model\Plugin\Checkout\Block\Cart\Shipping', [
33+
'scopeConfig' => $this->scopeConfigMock
34+
]);
35+
}
36+
37+
/**
38+
* @dataProvider afterGetStateActiveDataProvider
39+
*/
40+
public function testAfterGetStateActive($scopeConfigMockReturnValue, $result, $assertResult)
41+
{
42+
/** @var \Magento\Checkout\Block\Cart\Shipping $subjectMock */
43+
$subjectMock = $this->getMockBuilder('Magento\Checkout\Block\Cart\Shipping')
44+
->disableOriginalConstructor()
45+
->getMock();
46+
47+
$this->scopeConfigMock->expects($result ? $this->never() : $this->once())
48+
->method('getValue')
49+
->willReturn($scopeConfigMockReturnValue);
50+
51+
$this->assertEquals($this->model->afterGetStateActive($subjectMock, $result), $assertResult);
52+
}
53+
54+
public function afterGetStateActiveDataProvider()
55+
{
56+
return [
57+
[
58+
true,
59+
true,
60+
true
61+
],
62+
[
63+
true,
64+
false,
65+
true
66+
],
67+
[
68+
false,
69+
false,
70+
false
71+
]
72+
];
73+
}
74+
}

0 commit comments

Comments
 (0)