Skip to content

Commit

Permalink
Merge pull request #71 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[SOUTH] Bugfixes
  • Loading branch information
slavvka committed Oct 30, 2015
2 parents cd08089 + 6fd8d7e commit fd7abdf
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Captcha/Block/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct(
) {
$this->_captchaData = $captchaData;
parent::__construct($context, $data);
$this->_isScopePrivate = true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Block/Form/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(
$countryCollectionFactory,
$data
);
$this->_isScopePrivate = true;
$this->_isScopePrivate = false;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion app/code/Magento/Review/Block/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ public function getProductInfo()
*/
public function getAction()
{
return $this->getUrl('review/product/post', ['id' => $this->getProductId()]);
return $this->getUrl(
'review/product/post',
[
'_secure' => $this->getRequest()->isSecure(),
'id' => $this->getProductId(),
]
);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion app/code/Magento/Review/Block/Product/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ public function getProductId()
*/
public function getProductReviewUrl()
{
return $this->getUrl('review/product/listAjax', ['id' => $this->getProductId()]);
return $this->getUrl(
'review/product/listAjax',
[
'_secure' => $this->getRequest()->isSecure(),
'id' => $this->getProductId(),
]
);
}

/**
Expand Down
36 changes: 36 additions & 0 deletions app/code/Magento/Review/Test/Unit/Block/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class FormTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $storeManager;

/** @var \Magento\Framework\UrlInterface|PHPUnit_Framework_MockObject_MockObject */
protected $urlBuilder;

protected function setUp()
{
$this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface');
Expand All @@ -46,6 +49,7 @@ protected function setUp()
->method('getIsGuestAllowToWrite')
->willReturn(true);

$this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMockForAbstractClass();
$this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false);
$this->context->expects(
$this->any()
Expand All @@ -57,6 +61,7 @@ protected function setUp()
$this->context->expects($this->any())
->method('getRequest')
->willReturn($this->requestMock);
$this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
$this->productRepository = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface');

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

$this->assertSame($productMock, $this->object->getProductInfo());
}

/**
* @param bool $isSecure
* @param string $actionUrl
* @param int $productId
* @dataProvider getActionDataProvider
*/
public function testGetAction($isSecure, $actionUrl, $productId)
{
$this->urlBuilder->expects($this->any())
->method('getUrl')
->with('review/product/post', ['_secure' => $isSecure, 'id' => $productId])
->willReturn($actionUrl . '/id/' . $productId);
$this->requestMock->expects($this->any())
->method('getParam')
->with('id', false)
->willReturn($productId);
$this->requestMock->expects($this->any())
->method('isSecure')
->willReturn($isSecure);

$this->assertEquals($actionUrl . '/id/' . $productId, $this->object->getAction());
}

public function getActionDataProvider()
{
return [
[false, 'http://localhost/review/product/post', 3],
[true, 'https://localhost/review/product/post' ,3],
];
}
}
52 changes: 50 additions & 2 deletions app/code/Magento/Review/Test/Unit/Block/Product/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ class ReviewTest extends \PHPUnit_Framework_TestCase
*/
private $store;

/** @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject */
protected $context;

/** @var \Magento\Framework\UrlInterface|PHPUnit_Framework_MockObject_MockObject */
protected $urlBuilder;

/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $requestMock;

protected function setUp()
{
$this->initContextMock();
Expand All @@ -66,7 +75,7 @@ protected function setUp()

$helper = new ObjectManager($this);
$this->block = $helper->getObject(ReviewBlock::class, [
'storeManager' => $this->storeManager,
'context' => $this->context,
'registry' => $this->registry,
'collectionFactory' => $this->collectionFactory,
]);
Expand Down Expand Up @@ -124,7 +133,7 @@ private function initRegistryMock()
->setMethods(['registry'])
->getMock();

$this->registry->expects(static::once())
$this->registry->expects($this->any())
->method('registry')
->with('product')
->willReturn($this->product);
Expand Down Expand Up @@ -159,5 +168,44 @@ private function initContextMock()
$this->storeManager->expects(static::any())
->method('getStore')
->willReturn($this->store);
$this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface')->getMockForAbstractClass();
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
->getMockForAbstractClass();
$this->context = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context')
->disableOriginalConstructor()
->getMock();
$this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
$this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
$this->context->expects($this->any())->method('getStoreManager')->willReturn($this->storeManager);
}

/**
* @param bool $isSecure
* @param string $actionUrl
* @param int $productId
* @dataProvider getProductReviewUrlDataProvider
*/
public function testGetProductReviewUrl($isSecure, $actionUrl, $productId)
{
$this->urlBuilder->expects($this->any())
->method('getUrl')
->with('review/product/listAjax', ['_secure' => $isSecure, 'id' => $productId])
->willReturn($actionUrl . '/id/' . $productId);
$this->product->expects($this->any())
->method('getId')
->willReturn($productId);
$this->requestMock->expects($this->any())
->method('isSecure')
->willReturn($isSecure);

$this->assertEquals($actionUrl . '/id/' . $productId, $this->block->getProductReviewUrl());
}

public function getProductReviewUrlDataProvider()
{
return [
[false, 'http://localhost/review/product/listAjax', 3],
[true, 'https://localhost/review/product/listAjax' ,3],
];
}
}

0 comments on commit fd7abdf

Please sign in to comment.