Skip to content

Commit 5d9f8b3

Browse files
author
Tymchynskyi, Viktor(vtymchynskyi)
committed
Merge pull request #43 from magento-mpi/MPI-BUGFIXES
[MPI] Bugfixes
2 parents 4499554 + 8474b03 commit 5d9f8b3

File tree

9 files changed

+235
-4
lines changed

9 files changed

+235
-4
lines changed

app/code/Magento/Braintree/view/frontend/templates/creditcard/edit.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonE
328328
</label>
329329

330330
<div class="control">
331-
<?php echo $block->escapeHtml($block->countrySelect('credit_card[billing_address][country_code_alpha2]', 'billing_address_country', $default)); ?>
331+
<?php /* @noEscape */ echo $block->countrySelect('credit_card[billing_address][country_code_alpha2]', 'billing_address_country', $default); ?>
332332
</div>
333333
</div>
334334
</fieldset>

app/code/Magento/Paypal/Observer/AddBillingAgreementToSessionObserver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function execute(EventObserver $observer)
5353
if ($agreement->isValid()) {
5454
$message = __('Created billing agreement #%1.', $agreement->getReferenceId());
5555
$order->addRelatedObject($agreement);
56+
$agreement->addOrderRelation($order);
5657
$this->checkoutSession->setLastBillingAgreementReferenceId($agreement->getReferenceId());
5758
$agreementCreated = true;
5859
} else {

app/code/Magento/Paypal/Test/Unit/Observer/AddBillingAgreementToSessionObserverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function testAddBillingAgreementToSession($isValid)
122122
)->will(
123123
$this->returnValue('agreement reference id')
124124
);
125+
$agreement->expects($this->once())->method('addOrderRelation')->with($order);
125126
$order->expects(new MethodInvokedAtIndex(0))->method('addRelatedObject')->with($agreement);
126127
$this->_checkoutSession->expects(
127128
$this->once()

app/code/Magento/Paypal/view/frontend/templates/billing/agreement/view.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ $relatedOrders = $block->getRelatedOrders();
105105
)); ?>
106106
</td>
107107
<td data-th="<?php echo $block->escapeHtml(__('Order Total')); ?>" class="col total">
108-
<?php echo $block->escapeHtml($block->getOrderItemValue($order, 'order_total')); ?>
108+
<?php /* @noEscape */ echo $block->getOrderItemValue($order, 'order_total'); ?>
109109
</td>
110110
<td data-th="<?php echo $block->escapeHtml(__('Order Status')); ?>" class="col status">
111111
<?php echo $block->escapeHtml($block->getOrderItemValue(

app/code/Magento/Review/Block/Product/Review.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
*/
66
namespace Magento\Review\Block\Product;
77

8+
use Magento\Framework\DataObject\IdentityInterface;
9+
use Magento\Framework\View\Element\Template;
810

911
/**
1012
* Product Review Tab
1113
*
1214
* @author Magento Core Team <core@magentocommerce.com>
1315
*/
14-
class Review extends \Magento\Framework\View\Element\Template
16+
class Review extends Template implements IdentityInterface
1517
{
1618
/**
1719
* Core registry
@@ -98,4 +100,14 @@ public function getCollectionSize()
98100

99101
return $collection->getSize();
100102
}
103+
104+
/**
105+
* Return unique ID(s) for each object in system
106+
*
107+
* @return array
108+
*/
109+
public function getIdentities()
110+
{
111+
return [\Magento\Review\Model\Review::CACHE_TAG];
112+
}
101113
}

app/code/Magento/Review/Model/Rating.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Review\Model;
77

8+
use Magento\Framework\DataObject\IdentityInterface;
9+
810
/**
911
* Rating model
1012
*
@@ -18,7 +20,7 @@
1820
*
1921
* @author Magento Core Team <core@magentocommerce.com>
2022
*/
21-
class Rating extends \Magento\Framework\Model\AbstractModel
23+
class Rating extends \Magento\Framework\Model\AbstractModel implements IdentityInterface
2224
{
2325
/**
2426
* rating entity codes
@@ -161,4 +163,15 @@ public function getEntityIdByCode($entityCode)
161163
{
162164
return $this->getResource()->getEntityIdByCode($entityCode);
163165
}
166+
167+
/**
168+
* Return unique ID(s) for each object in system
169+
*
170+
* @return array
171+
*/
172+
public function getIdentities()
173+
{
174+
// clear cache for all reviews
175+
return [Review::CACHE_TAG];
176+
}
164177
}

app/code/Magento/Review/Model/Review.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ class Review extends \Magento\Framework\Model\AbstractModel implements IdentityI
3131
*/
3232
protected $_eventPrefix = 'review';
3333

34+
/**
35+
* Cache tag
36+
*/
37+
const CACHE_TAG = 'review_block';
38+
3439
/**
3540
* Product entity review code
3641
*/
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Review\Test\Unit\Block\Product;
8+
9+
use Magento\Framework\Registry;
10+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11+
use Magento\Framework\View\Element\Template\Context;
12+
use Magento\Catalog\Model\Product;
13+
use Magento\Review\Block\Product\Review as ReviewBlock;
14+
use Magento\Review\Model\ResourceModel\Review\Collection;
15+
use Magento\Review\Model\ResourceModel\Review\CollectionFactory;
16+
use Magento\Review\Model\Review;
17+
use Magento\Store\Model\Store;
18+
use Magento\Store\Model\StoreManager;
19+
20+
/**
21+
* Class ReviewTest
22+
* @package Magento\Review\Test\Unit\Block\Product
23+
*/
24+
class ReviewTest extends \PHPUnit_Framework_TestCase
25+
{
26+
/**
27+
* @var \Magento\Review\Block\Product\Review
28+
*/
29+
private $block;
30+
31+
/**
32+
* @var \Magento\Review\Model\ResourceModel\Review\Collection|\PHPUnit_Framework_MockObject_MockObject
33+
*/
34+
private $collection;
35+
36+
/**
37+
* @var \Magento\Review\Model\ResourceModel\Review\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
38+
*/
39+
private $collectionFactory;
40+
41+
/**
42+
* @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
43+
*/
44+
private $registry;
45+
46+
/**
47+
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
48+
*/
49+
private $product;
50+
51+
/**
52+
* @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject
53+
*/
54+
private $storeManager;
55+
56+
/**
57+
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
58+
*/
59+
private $store;
60+
61+
protected function setUp()
62+
{
63+
$this->initContextMock();
64+
$this->initRegistryMock();
65+
$this->initCollectionMocks();
66+
67+
$helper = new ObjectManager($this);
68+
$this->block = $helper->getObject(ReviewBlock::class, [
69+
'storeManager' => $this->storeManager,
70+
'registry' => $this->registry,
71+
'collectionFactory' => $this->collectionFactory,
72+
]);
73+
}
74+
75+
/**
76+
* @covers \Magento\Review\Block\Product\Review::getIdentities()
77+
*/
78+
public function testGetIdentities()
79+
{
80+
static::assertEquals([Review::CACHE_TAG], $this->block->getIdentities());
81+
}
82+
83+
/**
84+
* Create mocks for collection and its factory
85+
*/
86+
private function initCollectionMocks()
87+
{
88+
$this->collection = $this->getMockBuilder(Collection::class)
89+
->disableOriginalConstructor()
90+
->setMethods(['addStoreFilter', 'addStatusFilter', 'addEntityFilter', 'getSize', '__wakeup'])
91+
->getMock();
92+
93+
$this->collection->expects(static::any())
94+
->method('addStoreFilter')
95+
->willReturnSelf();
96+
97+
$this->collection->expects(static::any())
98+
->method('addStatusFilter')
99+
->with(Review::STATUS_APPROVED)
100+
->willReturnSelf();
101+
102+
$this->collection->expects(static::any())
103+
->method('addEntityFilter')
104+
->willReturnSelf();
105+
106+
$this->collectionFactory = $this->getMockBuilder(CollectionFactory::class)
107+
->disableOriginalConstructor()
108+
->setMethods(['create', '__wakeup'])
109+
->getMock();
110+
111+
$this->collectionFactory->expects(static::once())
112+
->method('create')
113+
->willReturn($this->collection);
114+
}
115+
116+
/**
117+
* Create mock for registry object
118+
*/
119+
private function initRegistryMock()
120+
{
121+
$this->initProductMock();
122+
$this->registry = $this->getMockBuilder(Registry::class)
123+
->disableOriginalConstructor()
124+
->setMethods(['registry'])
125+
->getMock();
126+
127+
$this->registry->expects(static::once())
128+
->method('registry')
129+
->with('product')
130+
->willReturn($this->product);
131+
}
132+
133+
/**
134+
* Create mock object for catalog product
135+
*/
136+
private function initProductMock()
137+
{
138+
$this->product = $this->getMockBuilder(Product::class)
139+
->disableOriginalConstructor()
140+
->setMethods(['getId'])
141+
->getMock();
142+
}
143+
144+
/**
145+
* Create mock object for context
146+
*/
147+
private function initContextMock()
148+
{
149+
$this->store = $this->getMockBuilder(Store::class)
150+
->disableOriginalConstructor()
151+
->setMethods(['getId', '__wakeup'])
152+
->getMock();
153+
154+
$this->storeManager = $this->getMockBuilder(StoreManager::class)
155+
->disableOriginalConstructor()
156+
->setMethods(['getStore', '__wakeup'])
157+
->getMock();
158+
159+
$this->storeManager->expects(static::any())
160+
->method('getStore')
161+
->willReturn($this->store);
162+
}
163+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Review\Test\Unit\Model;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
use Magento\Review\Model\Review;
10+
use Magento\Review\Model\Rating;
11+
12+
class RatingTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* @var \Magento\Review\Model\Rating
16+
*/
17+
private $rating;
18+
19+
/**
20+
* Init objects needed by tests
21+
*/
22+
protected function setUp()
23+
{
24+
$helper = new ObjectManager($this);
25+
$this->rating = $helper->getObject(Rating::class);
26+
}
27+
28+
/**
29+
* @covers \Magento\Review\Model\Rating::getIdentities()
30+
* @return void
31+
*/
32+
public function testGetIdentities()
33+
{
34+
static::assertEquals([Review::CACHE_TAG], $this->rating->getIdentities());
35+
}
36+
}

0 commit comments

Comments
 (0)