Skip to content

Commit 85fb783

Browse files
author
Vladyslav Shcherbyna
committed
MAGETWO-32107: Stabilization and pull request
1 parent f0d5c5c commit 85fb783

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2008,5 +2008,6 @@
20082008
],
20092009
['getLinksConfig', 'Magento\Downloadable\Block\Catalog\Product\Links'],
20102010
['getAuthorizationAmounts', 'Magento\Paypal\Model\Config'],
2011-
['cleanTransactions', 'Magento\Paypal\Model\Observer']
2011+
['cleanTransactions', 'Magento\Paypal\Model\Observer'],
2012+
['checkQuoteAmount', 'Magento\Sales\Helper\Data']
20122013
];
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
4+
*/
5+
namespace Magento\Quote\Helper;
6+
7+
/**
8+
* Tests For Quote Data checker
9+
*/
10+
class DataTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \Magento\Quote\Helper\Data
14+
*/
15+
protected $helper;
16+
17+
/**
18+
* @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Quote\Model\Quote
19+
*/
20+
protected $quoteMock;
21+
22+
/**
23+
* @return void
24+
*/
25+
protected function setUp()
26+
{
27+
$this->helper = new \Magento\Quote\Helper\Data();
28+
29+
$this->quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote')
30+
->setMethods(['getHasError', 'setHasError', 'addMessage', '__wakeup'])
31+
->disableOriginalConstructor()
32+
->getMock();
33+
}
34+
35+
public function testCheckQuoteAmountExistingError()
36+
{
37+
$this->quoteMock->expects($this->once())
38+
->method('getHasError')
39+
->will($this->returnValue(true));
40+
41+
$this->quoteMock->expects($this->never())
42+
->method('setHasError');
43+
44+
$this->quoteMock->expects($this->never())
45+
->method('addMessage');
46+
47+
$this->assertSame(
48+
$this->helper,
49+
$this->helper->checkQuoteAmount($this->quoteMock, Data::MAXIMUM_AVAILABLE_NUMBER + 1)
50+
);
51+
}
52+
53+
public function testCheckQuoteAmountAmountLessThanAvailable()
54+
{
55+
$this->quoteMock->expects($this->once())
56+
->method('getHasError')
57+
->will($this->returnValue(false));
58+
59+
$this->quoteMock->expects($this->never())
60+
->method('setHasError');
61+
62+
$this->quoteMock->expects($this->never())
63+
->method('addMessage');
64+
65+
$this->assertSame(
66+
$this->helper,
67+
$this->helper->checkQuoteAmount($this->quoteMock, Data::MAXIMUM_AVAILABLE_NUMBER - 1)
68+
);
69+
}
70+
71+
public function testCheckQuoteAmountAmountGreaterThanAvailable()
72+
{
73+
$this->quoteMock->expects($this->once())
74+
->method('getHasError')
75+
->will($this->returnValue(false));
76+
77+
$this->quoteMock->expects($this->once())
78+
->method('setHasError')
79+
->with(true);
80+
81+
$this->quoteMock->expects($this->once())
82+
->method('addMessage')
83+
->with(__('This item price or quantity is not valid for checkout.'));
84+
85+
$this->assertSame(
86+
$this->helper,
87+
$this->helper->checkQuoteAmount($this->quoteMock, Data::MAXIMUM_AVAILABLE_NUMBER + 1)
88+
);
89+
}
90+
}

0 commit comments

Comments
 (0)