Skip to content

Commit

Permalink
Merge pull request #1801 from magento-borg/Borg-PR-11-29
Browse files Browse the repository at this point in the history
[borg] Backports: MAGETWO-69213, MAGETWO-69577, MAGETWO-84822
  • Loading branch information
pdohogne-magento authored Dec 2, 2017
2 parents d7583ca + 5205d53 commit 6415e3d
Show file tree
Hide file tree
Showing 34 changed files with 780 additions and 407 deletions.
3 changes: 0 additions & 3 deletions app/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@
}

AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));

// Sets default autoload mappings, may be overridden in Bootstrap::create
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);
3 changes: 3 additions & 0 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
}

require_once __DIR__ . '/autoload.php';
// Sets default autoload mappings, may be overridden in Bootstrap::create
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);

require_once BP . '/app/functions.php';

/* Custom umask value may be provided in optional mage_umask file in root */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ define(
braintreeDeviceData: null,
paymentMethodNonce: null,
lastBillingAddress: null,
ccCode: null,
ccMessageContainer: null,
validatorManager: validatorManager,
code: 'braintree',

Expand Down Expand Up @@ -138,9 +140,39 @@ define(
return;
}

this.restoreMessageContainer();
this.restoreCode();

/**
* Define onReady callback
*/
braintree.onReady = function () {};
this.initBraintree();
},

/**
* Restore original message container for cc-form component
*/
restoreMessageContainer: function () {
this.messageContainer = this.ccMessageContainer;
},

/**
* Restore original code for cc-form component
*/
restoreCode: function () {
this.code = this.ccCode;
},

/** @inheritdoc */
initChildren: function () {
this._super();
this.ccMessageContainer = this.messageContainer;
this.ccCode = this.code;

return this;
},

/**
* Init config
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define([
var self = this;

/**
* Define already callback
* Define onReady callback
*/
Braintree.onReady = function () {
self.getPaymentMethodNonce();
Expand All @@ -78,6 +78,7 @@ define([
formComponent.setPaymentMethodNonce(response.paymentMethodNonce);
formComponent.additionalData['public_hash'] = self.publicHash;
formComponent.code = self.code;
formComponent.messageContainer = self.messageContainer;
formComponent.placeOrder();
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function setUp()
->with($productId)
->willReturn($stockItemMock);

$this->productExtensionMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtension')
$this->productExtensionMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionInterface')
->setMethods(['setStockItem'])
->getMock();
$this->productExtensionMock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class RegionTest extends \PHPUnit_Framework_TestCase
public function testRender($regionCollection)
{
$countryFactoryMock = $this->getMock(
'Magento\Directory\Model\CountryFactory',
['create'],
\Magento\Directory\Model\CountryFactory::class,
[],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define(
return {
getAddressItems: function() {
var items = [];
if (isLoggedIn) {
if (isLoggedIn()) {
var customerData = window.customerData;
if (Object.keys(customerData).length) {
$.each(customerData.addresses, function (key, item) {
Expand Down
39 changes: 0 additions & 39 deletions app/code/Magento/Directory/Model/CountryFactory.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,30 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase
/**
* @var \Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo
*/
protected $_model;
private $model;

/**
* @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_order;
private $order;

/**
* @var \Magento\Sales\Model\Order\Pdf\AbstractPdf|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_pdf;
private $pdf;

protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$arguments = [
'productFactory' => $this->getMock('Magento\Catalog\Model\ProductFactory', [], [], '', false),
'orderItemCollectionFactory' => $this->getMock(
'Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory',
[],
[],
'',
false
),
'serviceOrderFactory' => $this->getMock(
'Magento\Sales\Model\Service\OrderFactory',
[],
[],
'',
false
),
'currencyFactory' => $this->getMock(
'Magento\Directory\Model\CurrencyFactory',
[],
[],
'',
false
),
'orderHistoryFactory' => $this->getMock(
'Magento\Sales\Model\Order\Status\HistoryFactory',
[],
[],
'',
false
),
'orderTaxCollectionFactory' => $this->getMock(
'Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory',
[],
[],
'',
false
),
];
$orderConstructorArgs = $objectManager->getConstructArguments('Magento\Sales\Model\Order', $arguments);
$this->_order = $this->getMock('Magento\Sales\Model\Order', ['formatPriceTxt'], $orderConstructorArgs);
$this->_order->expects(
$this->any()
)->method(
'formatPriceTxt'
)->will(
$this->returnCallback([$this, 'formatPrice'])
);
$this->order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)
->disableOriginalConstructor()
->getMock();
$this->order->expects($this->any())
->method('formatPriceTxt')
->will($this->returnCallback([$this, 'formatPrice']));

$this->_pdf = $this->getMock(
'Magento\Sales\Model\Order\Pdf\AbstractPdf',
$this->pdf = $this->getMock(
\Magento\Sales\Model\Order\Pdf\AbstractPdf::class,
['drawLineBlocks', 'getPdf'],
[],
'',
Expand All @@ -96,22 +55,22 @@ protected function setUp()
['string' => new \Magento\Framework\Stdlib\StringUtils(), 'filterManager' => $filterManager]
);

$this->_model = $this->getMock(
'Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo',
$this->model = $this->getMock(
\Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo::class,
['getLinks', 'getLinksTitle'],
$modelConstructorArgs
);

$this->_model->setOrder($this->_order);
$this->_model->setPdf($this->_pdf);
$this->_model->setPage(new \Zend_Pdf_Page('a4'));
$this->model->setOrder($this->order);
$this->model->setPdf($this->pdf);
$this->model->setPage(new \Zend_Pdf_Page('a4'));
}

protected function tearDown()
{
$this->_model = null;
$this->_order = null;
$this->_pdf = null;
$this->model = null;
$this->order = null;
$this->pdf = null;
}

/**
Expand Down Expand Up @@ -150,7 +109,7 @@ public function testDraw()
],
];

$this->_model->setItem(
$this->model->setItem(
new \Magento\Framework\DataObject(
[
'name' => 'Downloadable Documentation',
Expand All @@ -170,8 +129,8 @@ public function testDraw()
]
)
);
$this->_model->expects($this->any())->method('getLinksTitle')->will($this->returnValue('Download Links'));
$this->_model->expects(
$this->model->expects($this->any())->method('getLinksTitle')->will($this->returnValue('Download Links'));
$this->model->expects(
$this->any()
)->method(
'getLinks'
Expand All @@ -184,7 +143,7 @@ public function testDraw()
)
)
);
$this->_pdf->expects(
$this->pdf->expects(
$this->once()
)->method(
'drawLineBlocks'
Expand All @@ -196,8 +155,8 @@ public function testDraw()
$this->returnValue($expectedPdfPage)
);

$this->assertNotSame($expectedPdfPage, $this->_model->getPage());
$this->assertNull($this->_model->draw());
$this->assertSame($expectedPdfPage, $this->_model->getPage());
$this->assertNotSame($expectedPdfPage, $this->model->getPage());
$this->assertNull($this->model->draw());
$this->assertSame($expectedPdfPage, $this->model->getPage());
}
}
6 changes: 4 additions & 2 deletions app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ protected function setUp()
$client->expects($this->any())->method('request')->will($this->returnSelf());
$client->expects($this->any())->method('getBody')->will($this->returnValue('RESULT name=value&name2=value2'));

$clientFactory = $this->getMock('Magento\Framework\HTTP\ZendClientFactory', ['create'], [], '', false);
$clientFactory->expects($this->any())->method('create')->will($this->returnValue($client));
$clientFactory = $this->getMockBuilder(ZendClientFactory::class)
->disableOriginalConstructor()
->getMock();
$clientFactory->method('create')->will($this->returnValue($client));

$this->eventManager = $this->getMockForAbstractClass(ManagerInterface::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,25 @@ protected function setUp()
false
);
$fetchStrategy->expects($this->any())->method('fetchAll')->will($this->returnValue([]));
$this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
->getObject(
'\Magento\Review\Model\ResourceModel\Review\Product\Collection',
[
'universalFactory' => $universalFactory,
'storeManager' => $storeManager,
'eavConfig' => $eavConfig,
'fetchStrategy' => $fetchStrategy
]
);
$productLimitationMock = $this->getMock(
\Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitation::class
);
$productLimitationFactoryMock = $this->getMockBuilder(ProductLimitationFactory::class)
->disableOriginalConstructor()
->getMock();
$productLimitationFactoryMock->method('create')
->willReturn($productLimitationMock);
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->model = $this->objectManager->getObject(
\Magento\Review\Model\ResourceModel\Review\Product\Collection::class,
[
'universalFactory' => $universalFactory,
'storeManager' => $storeManager,
'eavConfig' => $eavConfig,
'fetchStrategy' => $fetchStrategy,
'productLimitationFactory' => $productLimitationFactoryMock
]
);
}

/**
Expand Down
Loading

0 comments on commit 6415e3d

Please sign in to comment.