Skip to content
Snippets Groups Projects
Commit c74424e4 authored by Iryna Lagno's avatar Iryna Lagno
Browse files

Merge branch 'mainline_develop' into checkout

parents 21db8d63 06beed02
Branches
No related merge requests found
...@@ -1413,7 +1413,7 @@ abstract class AbstractEntity extends \Magento\Framework\Model\Resource\Abstract ...@@ -1413,7 +1413,7 @@ abstract class AbstractEntity extends \Magento\Framework\Model\Resource\Abstract
*/ */
protected function _processSaveData($saveData) protected function _processSaveData($saveData)
{ {
extract($saveData); extract($saveData, EXTR_SKIP);
/** /**
* Import variables into the current symbol table from save data array * Import variables into the current symbol table from save data array
* *
......
...@@ -40,7 +40,8 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress ...@@ -40,7 +40,8 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress
$order = $this->_checkout->getOrder(); $order = $this->_checkout->getOrder();
if ($order) { if ($order) {
$this->_getCheckoutSession()->setLastOrderId($order->getId()) $this->_getCheckoutSession()->setLastOrderId($order->getId())
->setLastRealOrderId($order->getIncrementId()); ->setLastRealOrderId($order->getIncrementId())
->setLastOrderStatus($order->getStatus());
} }
$this->_eventManager->dispatch( $this->_eventManager->dispatch(
......
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files;
class DeleteFilesTest extends \PHPUnit_Framework_TestCase
{
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */
protected $controller;
/** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_MockObject_MockObject*/
protected $objectManager;
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */
protected $storage;
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $request;
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */
protected $response;
public function setUp()
{
$this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface');
$this->storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false);
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
$this->request = $this->getMockForAbstractClass(
'Magento\Framework\App\RequestInterface',
[],
'',
false,
false,
true,
['isPost', 'getParam']
);
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->controller = $helper->getObject(
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\DeleteFiles',
[
'objectManager' => $this->objectManager,
'request' => $this->request,
'response' => $this->response,
]
);
}
public function testExecuteWithWrongRequest()
{
$this->request->expects($this->once())
->method('isPost')
->willReturn(false);
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
$jsonData->expects($this->once())
->method('jsonEncode')
->with(['error' => true, 'message' => 'Wrong request'])
->willReturn('{"error":"true","message":"Wrong request"}');
$this->objectManager->expects($this->once())
->method('get')
->with('Magento\Framework\Json\Helper\Data')
->willReturn($jsonData);
$this->response->expects($this->once())
->method('representJson')
->with('{"error":"true","message":"Wrong request"}');
$this->controller->execute();
}
public function testExecute()
{
$this->request->expects($this->once())
->method('isPost')
->willReturn(true);
$this->request->expects($this->once())
->method('getParam')
->with('files')
->willReturn('{"files":"file"}');
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
$jsonData->expects($this->once())
->method('jsonDecode')
->with('{"files":"file"}')
->willReturn(['files' => 'file']);
$this->objectManager->expects($this->at(0))
->method('get')
->with('Magento\Framework\Json\Helper\Data')
->willReturn($jsonData);
$this->objectManager->expects($this->at(1))
->method('get')
->with('Magento\Theme\Model\Wysiwyg\Storage')
->willReturn($this->storage);
$this->storage->expects($this->once())
->method('deleteFile')
->with('file');
$this->controller->execute();
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files;
class DeleteFolderTest extends \PHPUnit_Framework_TestCase
{
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */
protected $controller;
/** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_MockObject_MockObject*/
protected $objectManager;
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */
protected $response;
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */
protected $storage;
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */
protected $storageHelper;
public function setUp()
{
$this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface');
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
$this->storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false);
$this->storageHelper = $this->getMock('Magento\Theme\Helper\Storage', [], [], '', false);
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->controller = $helper->getObject(
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\DeleteFolder',
[
'objectManager' => $this->objectManager,
'response' => $this->response,
'storage' => $this->storageHelper
]
);
}
public function testExecute()
{
$this->storageHelper->expects($this->once())
->method('getCurrentPath')
->willReturn('/current/path/');
$this->objectManager->expects($this->at(0))
->method('get')
->with('Magento\Theme\Model\Wysiwyg\Storage')
->willReturn($this->storage);
$this->storage->expects($this->once())
->method('deleteDirectory')
->with('/current/path/')
->willThrowException(new \Exception('Message'));
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
$jsonData->expects($this->once())
->method('jsonEncode')
->with(['error' => true, 'message' => 'Message'])
->willReturn('{"error":"true","message":"Message"}');
$this->objectManager->expects($this->at(1))
->method('get')
->with('Magento\Framework\Json\Helper\Data')
->willReturn($jsonData);
$this->controller->execute();
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files;
class IndexTest extends \PHPUnit_Framework_TestCase
{
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */
protected $controller;
/** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $view;
public function setUp()
{
$this->view = $this->getMock('\Magento\Framework\App\ViewInterface', [], [], '', false);
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->controller = $helper->getObject(
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\Index',
[
'view' => $this->view,
]
);
}
public function testExecute()
{
$this->view ->expects($this->once())
->method('loadLayout')
->with('overlay_popup');
$this->view ->expects($this->once())
->method('renderLayout');
$this->controller->execute();
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files;
class OnInsertTest extends \PHPUnit_Framework_TestCase
{
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */
protected $controller;
/** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $view;
/** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_MockObject_MockObject */
protected $objectManager;
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */
protected $storageHelper;
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */
protected $response;
public function setUp()
{
$this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface');
$this->view = $this->getMock('\Magento\Framework\App\ViewInterface', [], [], '', false);
$this->storageHelper = $this->getMock('Magento\Theme\Helper\Storage', [], [], '', false);
$this->response = $this->getMock('Magento\Framework\App\Response\Http', ['setBody'], [], '', false);
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->controller = $helper->getObject(
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\OnInsert',
[
'objectManager' => $this->objectManager,
'view' => $this->view,
'response' => $this->response
]
);
}
public function testExecute()
{
$this->objectManager->expects($this->once())
->method('get')
->with('Magento\Theme\Helper\Storage')
->willReturn($this->storageHelper);
$this->storageHelper
->expects($this->once())
->method('getRelativeUrl')
->willReturn('http://relative.url/');
$this->response->expects($this->once())
->method('setBody')
->with('http://relative.url/');
$this->controller->execute();
}
}
...@@ -165,7 +165,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase ...@@ -165,7 +165,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase
$this->model->addOption($option); $this->model->addOption($option);
$this->assertEquals(1, count($this->model->getOptions())); $this->assertEquals(1, count($this->model->getOptions()));
$this->model->removeOption($code); $this->model->removeOption($code);
$actualOptions = $this->model->getOptions(); $actualOptions = $this->model->getOptions();
$actualOption = array_pop($actualOptions); $actualOption = array_pop($actualOptions);
$this->assertTrue($actualOption->isDeleted()); $this->assertTrue($actualOption->isDeleted());
} }
...@@ -185,7 +185,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase ...@@ -185,7 +185,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase
->getMock(); ->getMock();
return [ return [
['first_key', ['code' => 'first_key', 'value' => 'first_data']], ['first_key', ['code' => 'first_key', 'value' => 'first_data']],
['second_key',$optionMock], ['second_key', $optionMock],
['third_key', new \Magento\Framework\Object(['code' => 'third_key', 'product' => $productMock])], ['third_key', new \Magento\Framework\Object(['code' => 'third_key', 'product' => $productMock])],
]; ];
} }
...@@ -262,4 +262,63 @@ class ItemTest extends \PHPUnit_Framework_TestCase ...@@ -262,4 +262,63 @@ class ItemTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($result); $this->assertFalse($result);
} }
public function testSetAndSaveItemOptions()
{
$this->assertEmpty($this->model->getOptions());
$firstOptionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option')
->disableOriginalConstructor()
->setMethods(['getCode', 'isDeleted', 'delete', '__wakeup'])
->getMock();
$firstOptionMock->expects($this->any())
->method('getCode')
->willReturn('first_code');
$firstOptionMock->expects($this->any())
->method('isDeleted')
->willReturn(true);
$firstOptionMock->expects($this->once())
->method('delete');
$secondOptionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option')
->disableOriginalConstructor()
->setMethods(['getCode', 'save', '__wakeup'])
->getMock();
$secondOptionMock->expects($this->any())
->method('getCode')
->willReturn('second_code');
$secondOptionMock->expects($this->once())
->method('save');
$this->model->setOptions([$firstOptionMock, $secondOptionMock]);
$this->assertNull($this->model->isOptionsSaved());
$this->model->saveItemOptions();
$this->assertTrue($this->model->isOptionsSaved());
}
public function testGetProductWithException()
{
$this->setExpectedException('Magento\Framework\Exception\LocalizedException', __('Cannot specify product.'));
$this->model->getProduct();
}
public function testGetProduct()
{
$productId = 1;
$storeId = 0;
$this->model->setData('product_id', $productId);
$this->model->setData('store_id', $storeId);
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
->disableOriginalConstructor()
->getMock();
$productMock->expects($this->any())
->method('setFinalPrice')
->with(null);
$productMock->expects($this->any())
->method('setCustomOprtions')
->with([]);
$this->productRepository->expects($this->once())
->method('getById')
->willReturn($productMock);
$this->assertEquals($productMock, $this->model->getProduct());
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment