Skip to content

Commit fd7abdf

Browse files
committed
Merge pull request #71 from magento-south/BUGS
[SOUTH] Bugfixes
2 parents cd08089 + 6fd8d7e commit fd7abdf

File tree

6 files changed

+102
-5
lines changed

6 files changed

+102
-5
lines changed

app/code/Magento/Captcha/Block/Captcha.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct(
3232
) {
3333
$this->_captchaData = $captchaData;
3434
parent::__construct($context, $data);
35+
$this->_isScopePrivate = true;
3536
}
3637

3738
/**

app/code/Magento/Customer/Block/Form/Register.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(
6363
$countryCollectionFactory,
6464
$data
6565
);
66-
$this->_isScopePrivate = true;
66+
$this->_isScopePrivate = false;
6767
}
6868

6969
/**

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ public function getProductInfo()
158158
*/
159159
public function getAction()
160160
{
161-
return $this->getUrl('review/product/post', ['id' => $this->getProductId()]);
161+
return $this->getUrl(
162+
'review/product/post',
163+
[
164+
'_secure' => $this->getRequest()->isSecure(),
165+
'id' => $this->getProductId(),
166+
]
167+
);
162168
}
163169

164170
/**

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ public function getProductId()
6666
*/
6767
public function getProductReviewUrl()
6868
{
69-
return $this->getUrl('review/product/listAjax', ['id' => $this->getProductId()]);
69+
return $this->getUrl(
70+
'review/product/listAjax',
71+
[
72+
'_secure' => $this->getRequest()->isSecure(),
73+
'id' => $this->getProductId(),
74+
]
75+
);
7076
}
7177

7278
/**

app/code/Magento/Review/Test/Unit/Block/FormTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class FormTest extends \PHPUnit_Framework_TestCase
3434
/** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
3535
protected $storeManager;
3636

37+
/** @var \Magento\Framework\UrlInterface|PHPUnit_Framework_MockObject_MockObject */
38+
protected $urlBuilder;
39+
3740
protected function setUp()
3841
{
3942
$this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface');
@@ -46,6 +49,7 @@ protected function setUp()
4649
->method('getIsGuestAllowToWrite')
4750
->willReturn(true);
4851

52+
$this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMockForAbstractClass();
4953
$this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false);
5054
$this->context->expects(
5155
$this->any()
@@ -57,6 +61,7 @@ protected function setUp()
5761
$this->context->expects($this->any())
5862
->method('getRequest')
5963
->willReturn($this->requestMock);
64+
$this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
6065
$this->productRepository = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface');
6166

6267
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -96,4 +101,35 @@ public function testGetProductInfo()
96101

97102
$this->assertSame($productMock, $this->object->getProductInfo());
98103
}
104+
105+
/**
106+
* @param bool $isSecure
107+
* @param string $actionUrl
108+
* @param int $productId
109+
* @dataProvider getActionDataProvider
110+
*/
111+
public function testGetAction($isSecure, $actionUrl, $productId)
112+
{
113+
$this->urlBuilder->expects($this->any())
114+
->method('getUrl')
115+
->with('review/product/post', ['_secure' => $isSecure, 'id' => $productId])
116+
->willReturn($actionUrl . '/id/' . $productId);
117+
$this->requestMock->expects($this->any())
118+
->method('getParam')
119+
->with('id', false)
120+
->willReturn($productId);
121+
$this->requestMock->expects($this->any())
122+
->method('isSecure')
123+
->willReturn($isSecure);
124+
125+
$this->assertEquals($actionUrl . '/id/' . $productId, $this->object->getAction());
126+
}
127+
128+
public function getActionDataProvider()
129+
{
130+
return [
131+
[false, 'http://localhost/review/product/post', 3],
132+
[true, 'https://localhost/review/product/post' ,3],
133+
];
134+
}
99135
}

app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ class ReviewTest extends \PHPUnit_Framework_TestCase
5858
*/
5959
private $store;
6060

61+
/** @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject */
62+
protected $context;
63+
64+
/** @var \Magento\Framework\UrlInterface|PHPUnit_Framework_MockObject_MockObject */
65+
protected $urlBuilder;
66+
67+
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
68+
protected $requestMock;
69+
6170
protected function setUp()
6271
{
6372
$this->initContextMock();
@@ -66,7 +75,7 @@ protected function setUp()
6675

6776
$helper = new ObjectManager($this);
6877
$this->block = $helper->getObject(ReviewBlock::class, [
69-
'storeManager' => $this->storeManager,
78+
'context' => $this->context,
7079
'registry' => $this->registry,
7180
'collectionFactory' => $this->collectionFactory,
7281
]);
@@ -124,7 +133,7 @@ private function initRegistryMock()
124133
->setMethods(['registry'])
125134
->getMock();
126135

127-
$this->registry->expects(static::once())
136+
$this->registry->expects($this->any())
128137
->method('registry')
129138
->with('product')
130139
->willReturn($this->product);
@@ -159,5 +168,44 @@ private function initContextMock()
159168
$this->storeManager->expects(static::any())
160169
->method('getStore')
161170
->willReturn($this->store);
171+
$this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMockForAbstractClass();
172+
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
173+
->getMockForAbstractClass();
174+
$this->context = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context')
175+
->disableOriginalConstructor()
176+
->getMock();
177+
$this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
178+
$this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
179+
$this->context->expects($this->any())->method('getStoreManager')->willReturn($this->storeManager);
180+
}
181+
182+
/**
183+
* @param bool $isSecure
184+
* @param string $actionUrl
185+
* @param int $productId
186+
* @dataProvider getProductReviewUrlDataProvider
187+
*/
188+
public function testGetProductReviewUrl($isSecure, $actionUrl, $productId)
189+
{
190+
$this->urlBuilder->expects($this->any())
191+
->method('getUrl')
192+
->with('review/product/listAjax', ['_secure' => $isSecure, 'id' => $productId])
193+
->willReturn($actionUrl . '/id/' . $productId);
194+
$this->product->expects($this->any())
195+
->method('getId')
196+
->willReturn($productId);
197+
$this->requestMock->expects($this->any())
198+
->method('isSecure')
199+
->willReturn($isSecure);
200+
201+
$this->assertEquals($actionUrl . '/id/' . $productId, $this->block->getProductReviewUrl());
202+
}
203+
204+
public function getProductReviewUrlDataProvider()
205+
{
206+
return [
207+
[false, 'http://localhost/review/product/listAjax', 3],
208+
[true, 'https://localhost/review/product/listAjax' ,3],
209+
];
162210
}
163211
}

0 commit comments

Comments
 (0)