Skip to content

Updated to latest MG2 develop #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 85 commits into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
a3b5a18
Fix for https://github.com/magento/magento2/issues/8392
kirashet666 Feb 8, 2017
207b160
Fix for https://github.com/magento/magento2/issues/8392
kirashet666 Feb 8, 2017
d92845a
Remove the use of Zend_Json from the Onepage checkout block
dmanners Feb 3, 2017
248cd85
Mock the serialize method return value
dmanners Feb 3, 2017
072dde7
Remove Zend_Json usage from the cart shipping block
dmanners Feb 3, 2017
287c315
Remove Zend_Json usage from the onepage.phtml template
dmanners Feb 3, 2017
122997c
Remove Zend_Json usage from the cart shipping.phtml template
dmanners Feb 3, 2017
4ddbfc2
Remove Zend_Json usage from the minicart.phtml template
dmanners Feb 3, 2017
d350783
Update the serializer to use directly the json version and not just a…
dmanners Feb 9, 2017
eb31f86
Fix the getting of the Serializer Json mock object to match the codin…
dmanners Feb 9, 2017
ea50a0e
MTO-112: [Variation] Use Layered Navigation by Price (Navigation Step…
AndreiZiblitski Feb 9, 2017
5c57dc2
Make sure that the new dependancy on Serializer\Json is the last thin…
dmanners Feb 9, 2017
5d42cef
Update the Adminhtml image tree to use the new Serializer Json rather…
dmanners Feb 10, 2017
f796c3a
MAGETWO-64536: [GitHub] [PR] Remove zend json checkout magento/magent…
Feb 10, 2017
1f4528e
Add missing names to catalog layout xml
Feb 11, 2017
8d73c8c
MAGETWO-64538: [GitHub] [PR] Add missing name attributes to catalog_p…
Feb 11, 2017
2aacffc
Change link text from "Report Bugs" to "Report a Bug"
Feb 11, 2017
d01f687
Merge branch 'develop' of https://github.com/magento/magento2ce into …
AndreiZiblitski Feb 13, 2017
149d7d3
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 10, 2017
af97b13
Merge branch 'develop' of https://github.com/magento-epam/magento2ce …
vitalysery Feb 13, 2017
de140ed
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 13, 2017
991a54d
Issue 8392 fix improved
kirashet666 Feb 13, 2017
acfce4e
Issue 8392 fix improved
kirashet666 Feb 13, 2017
85965cc
MTO-112: [Variation] Use Layered Navigation by Price (Navigation Step…
AndreiZiblitski Feb 13, 2017
10cde3e
MTO-112: [Variation] Use Layered Navigation by Price (Navigation Step…
AndreiZiblitski Feb 13, 2017
b4503fd
MTO-112: [Variation] Use Layered Navigation by Price (Navigation Step…
AndreiZiblitski Feb 13, 2017
0002f6d
Issue 8392 - formatting wanking
kirashet666 Feb 13, 2017
40c5f52
MTO-112: [Variation] Use Layered Navigation by Price (Navigation Step…
AndreiZiblitski Feb 14, 2017
a7f0425
MAGETWO-63014: Configurable shows lowest price after product was assi…
Feb 13, 2017
4376757
MTO-117: [Variation] Use attribute in the Advanced Search
vitalysery Feb 13, 2017
6f5d3c0
MTO-117: [Variation] Use attribute in the Advanced Search
vitalysery Feb 13, 2017
f1327a0
MTO-117: [Variation] Use attribute in the Advanced Search
vitalysery Feb 14, 2017
957f068
Merge branch 'MTO-112' into 'pr1'
AndreiZiblitski Feb 14, 2017
25e6257
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 14, 2017
3ba2b4e
MAGETWO-63014: Configurable shows lowest price after product was assi…
Feb 14, 2017
0077343
Merge branch 'mto-117-new' into 'pr1'
vitalysery Feb 14, 2017
e2fda94
MTO-108: [Test] Observe Different Base Currency per Website
AndreiZiblitski Feb 15, 2017
ae45e6b
Merge branch 'develop' of https://github.com/magento/magento2ce into pr1
AndreiZiblitski Feb 15, 2017
991956d
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 15, 2017
0fae435
Merge branch 'mto-108' into pr1
AndreiZiblitski Feb 15, 2017
dfa2a18
MAGETWO-61826: Cannot save a product with imported custom options.
interio-zz Feb 15, 2017
234e42b
Merge branch 'develop' into MAGETWO-61826
interio-zz Feb 15, 2017
ce24603
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 16, 2017
76f4fdf
Merge branch 'MAGETWO-61826' into MAGETWO-61826_63014
interio-zz Feb 16, 2017
839cec7
Merge branch 'MAGETWO-63014' into MAGETWO-61826_63014
interio-zz Feb 16, 2017
258fa76
MTO-108: [Test] Observe Different Base Currency per Website
AndreiZiblitski Feb 16, 2017
7a5e4a7
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 16, 2017
fa33267
MTO-108: [Test] Observe Different Base Currency per Website
AndreiZiblitski Feb 16, 2017
ec0fab4
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 16, 2017
54ef5f4
MTO-108: [Test] Observe Different Base Currency per Website
AndreiZiblitski Feb 16, 2017
ba9fc39
MTO-109: [Variation] Create and use XML Sitemap with submission to Ro…
AndreiZiblitski Feb 16, 2017
7e2a836
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 16, 2017
e656be1
MTO-108: [Test] Observe Different Base Currency per Website
vitalysery Feb 16, 2017
a170f6a
MTO-109: [Variation] Create and use XML Sitemap with submission to Ro…
AndreiZiblitski Feb 16, 2017
84ba4a5
Merge branch 'pr1' of https://github.com/magento-epam/magento2ce into…
AndreiZiblitski Feb 16, 2017
4925030
Merge branch 'develop' of https://github.com/magento/magento2ce into pr1
AndreiZiblitski Feb 16, 2017
551f694
Replace installation instructions and system requirements with links …
Feb 16, 2017
b214866
Merge branch 'feature/report-a-bug-label' of https://github.com/Zifiu…
Feb 16, 2017
38a7ad5
Merge branch 'develop' of https://github.com/magento/magento2ce into pr1
AndreiZiblitski Feb 17, 2017
e1f2e42
Merge branch 'develop' into MAGETWO-61826_63014
interio-zz Feb 17, 2017
87b2d34
MAGETWO-64846: [GitHub][PR] Update the Adminhtml image tree JSON mage…
Feb 18, 2017
ef40ba3
Feb 19, 2017
a797a31
MAGETWO-64772: [GitHub] [PR] Change link text from "Report Bugs" to "…
Feb 19, 2017
9940a71
MAGETWO-64538: [GitHub] [PR] Add missing name attributes to catalog_p…
Feb 19, 2017
1d80c33
MAGETWO-64536: [GitHub] [PR] Remove zend json checkout magento/magent…
Feb 19, 2017
92d2d0d
Merge pull request #857 from magento-engcom/develop-prs
Feb 19, 2017
2edfc08
Merge remote-tracking branch 'mainline/develop' into MAGETWO-61826_63014
Feb 19, 2017
d01b91a
Merge pull request #851 from magento-tango/MAGETWO-61826_63014
Feb 20, 2017
c98828b
Merge pull request #852 from xcomSteveJohnson/develop
Feb 20, 2017
afe52d0
Merge branch 'develop' of https://github.com/magento-epam/magento2ce …
vitalysery Feb 20, 2017
c7fff61
Merge pull request #853 from magento-epam/pr1
okolesnyk Feb 20, 2017
a60ed27
Remove Zend_Json from Customer module in the auth-pop-up block and ad…
dmanners Feb 20, 2017
d232d32
MAGETWO-64846: [GitHub][PR] Update the Adminhtml image tree JSON mage…
Feb 20, 2017
168701c
MAGETWO-64403: [GitHub] [PR] Sorting the returning array by the posit…
Feb 20, 2017
308b70b
MAGETWO-64403: [GitHub] [PR] Sorting the returning array by the posit…
Feb 20, 2017
08edf2f
MAGETWO-64898: [GitHub][PR] Remove Zend_Json from Customer module mag…
Feb 20, 2017
706108e
MAGETWO-64900: [GitHub] [Issue] Travis Does not support freetype on P…
Feb 20, 2017
a328bbe
MAGETWO-64900: [GitHub] [Issue] Travis Does not support freetype on P…
Feb 20, 2017
2f6b417
MAGETWO-64900: [GitHub] [Issue] Travis Does not support freetype on P…
Feb 20, 2017
d3a5208
MAGETWO-64900: [GitHub] [Issue] Travis Does not support freetype on P…
Feb 20, 2017
67baf87
MAGETWO-64900: [GitHub] [Issue] Travis Does not support freetype on P…
Feb 20, 2017
15de93d
MAGETWO-64403: [GitHub] [PR] Sorting the returning array by the posit…
Feb 20, 2017
7dd8d4c
MAGETWO-64898: [GitHub][PR] Remove Zend_Json from Customer module mag…
Feb 20, 2017
c74b6b7
MAGETWO-64898: [GitHub][PR] Remove Zend_Json from Customer module mag…
Feb 21, 2017
b180d87
Merge pull request #858 from magento-engcom/develop-prs
Feb 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ addons:
- postfix
language: php
php:
- 5.6
- 5.6.29
- 7.0
env:
global:
Expand Down
59 changes: 6 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,14 @@
<h2>Welcome</h2>
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results.

The installation instructions that used to be here are now published on our GitHub site. Use the information on this page to get started or go directly to the <a href="http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html" target="_blank">guide</a>.
## Magento system requirements
[Magento system requirements](http://devdocs.magento.com/magento-system-requirements.html)

<h2>New to Magento? Need some help?</h2>
If you're not sure about the following, you probably need a little help before you start installing the Magento software:
## Install Magento
To install Magento, see either:

* Is the Magento software <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_magento-installed.html">installed already</a>?
* What's a <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_login.html">terminal, command prompt, or Secure Shell (ssh)</a>?
* Where's my <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_login.html">Magento server</a> and how do I access it?
* What's <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_software.html">PHP</a>?
* What's <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_software.html">Apache</a>?
* What's <a href="http://devdocs.magento.com/guides/v2.0/install-gde/basics/basics_software.html">MySQL</a>?

<h2>Step 1: Verify your prerequisites</h2>

Use the following table to verify you have the correct prerequisites to install the Magento software.

<table>
<tbody>
<tr>
<th>Prerequisite</th>
<th>How to check</th>
<th>For more information</th>
</tr>
<tr>
<td>Apache 2.2 or 2.4</td>
<td>Ubuntu: <code>apache2 -v</code><br>
CentOS: <code>httpd -v</code></td>
<td><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache.html">Apache</a></td>
</tr>
<tr>
<td>PHP 5.6.x, 7.0.2, 7.0.4 or 7.0.6</td>
<td><code>php -v</code></td>
<td><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/php-ubuntu.html">PHP Ubuntu</a><br><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/php-centos.html">PHP CentOS</a></td>
</tr>
<tr><td>MySQL 5.6.x</td>
<td><code>mysql -u [root user name] -p</code></td>
<td><a href="http://devdocs.magento.com/guides/v2.0/install-gde/prereq/mysql.html">MySQL</a></td>
</tr>
</tbody>
</table>

<h2>Step 2: Prepare to install</h2>

After verifying your prerequisites, perform the following tasks in order to prepare to install the Magento software.

1. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/composer-clone.html#instgde-prereq-compose-install">Install Composer</a>
2. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/composer-clone.html#instgde-prereq-compose-clone">Clone the Magento repository</a>

<h2>Step 3: Install and verify the installation</h2>

1. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/prepare-install.html">Update installation dependencies</a>
2. Install Magento:
* <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/install-web.html">Install Magento software using the web interface</a>
* <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/install-cli.html">Install Magento software using the command line</a>
2. <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/verify.html">Verify the installation</a>
* [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento.
* [Installation guide](http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html)

<h2>Contributing to the Magento 2 code base</h2>
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Minute,Minute
"JavaScript may be disabled in your browser.","JavaScript may be disabled in your browser."
"To use this website you must first enable JavaScript in your browser.","To use this website you must first enable JavaScript in your browser."
"This is only a demo store. You can browse and place orders, but nothing will be processed.","This is only a demo store. You can browse and place orders, but nothing will be processed."
"Report Bugs","Report Bugs"
"Report a Bug","Report a Bug"
"Store View:","Store View:"
"Stores Configuration","Stores Configuration"
"Please confirm scope switching. All data that hasn\'t been saved will be lost.","Please confirm scope switching. All data that hasn\'t been saved will be lost."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

?>
<?php if ($block->getBugreportUrl()): ?>
<a class="link-report" href="<?php /* @escapeNotVerified */ echo $block->getBugreportUrl(); ?>" id="footer_bug_tracking"><?php /* @escapeNotVerified */ echo __('Report Bugs') ?></a>
<a class="link-report" href="<?php /* @escapeNotVerified */ echo $block->getBugreportUrl(); ?>" id="footer_bug_tracking"><?php /* @escapeNotVerified */ echo __('Report a Bug') ?></a>
<?php endif; ?>
4 changes: 0 additions & 4 deletions app/code/Magento/Captcha/Test/Unit/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ protected function setUp()
*/
public function testGetCaptcha()
{
if (!function_exists("imageftbbox")) {
$this->markTestSkipped('imageftbbox is not available on the test environment');
}

$this->configMock->expects(
$this->once()
)->method(
Expand Down
3 changes: 0 additions & 3 deletions app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ class DefaultTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
if (!function_exists("imageftbbox")) {
$this->markTestSkipped('imageftbbox is not available on the test environment');
}
$this->session = $this->_getSessionStub();

$this->_storeManager = $this->getMock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@ public function getCollection(\Magento\Catalog\Model\Product $product, $type)
$products = $this->providers[$type]->getLinkedProducts($product);
$converter = $this->converterPool->getConverter($type);
$output = [];
$sorterItems = [];
foreach ($products as $item) {
$output[$item->getId()] = $converter->convert($item);
}
return $output;

foreach ($output as $item) {
$itemPosition = $item['position'];
if (!isset($sorterItems[$itemPosition])) {
$sorterItems[$itemPosition] = $item;
} else {
$newPosition = $itemPosition + 1;
$sorterItems[$newPosition] = $item;
}
}
ksort($sorterItems);
return $sorterItems;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public function build($productId)
->limit(1);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);

$priceSelectDefault = clone $priceSelect;
$priceSelectDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
$select[] = $priceSelectDefault;

if (!$this->catalogHelper->isPriceGlobal()) {
$priceSelect->where('t.store_id = ?', $this->storeManager->getStore()->getId());
$select[] = $priceSelect;
$priceSelectStore = clone $priceSelect;
$priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
$selects[] = $priceSelectStore;
}

return $select;
$priceSelect->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
$selects[] = $priceSelect;

return $selects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ public function build($productId)
->limit(1);
$specialPrice = $this->baseSelectProcessor->process($specialPrice);

$specialPriceDefault = clone $specialPrice;
$specialPriceDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
$select[] = $specialPriceDefault;

if (!$this->catalogHelper->isPriceGlobal()) {
$specialPrice->where('t.store_id = ?', $this->storeManager->getStore()->getId());
$select[] = $specialPrice;
$priceSelectStore = clone $specialPrice;
$priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
$selects[] = $priceSelectStore;
}

return $select;
$specialPrice->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
$selects[] = $specialPrice;

return $selects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ public function build($productId)
->limit(1);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);

$priceSelectDefault = clone $priceSelect;
$priceSelectDefault->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
$select[] = $priceSelectDefault;

if (!$this->catalogHelper->isPriceGlobal()) {
$priceSelect->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
$select[] = $priceSelect;
$priceSelectStore = clone $priceSelect;
$priceSelectStore->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId());
$selects[] = $priceSelectStore;
}

return $select;
$priceSelect->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
$selects[] = $priceSelect;

return $selects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public function __construct($linkedProductSelectBuilder)
*/
public function build($productId)
{
$select = [];
$selects = [];
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
$select = array_merge($select, $productSelectBuilder->build($productId));
$selects = array_merge($selects, $productSelectBuilder->build($productId));
}

return $select;
return $selects;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\ResourceModel\Product\Website;

use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Store\Model\StoreManagerInterface;

/**
* Filter products that belongs to current website
*/
class SelectProcessor implements BaseSelectProcessorInterface
{
/**
* @var ResourceConnection
*/
private $resource;

/**
* @var MetadataPool
*/
private $metadataPool;

/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* @param MetadataPool $metadataPool
* @param ResourceConnection $resource
* @param StoreManagerInterface $storeManager
*/
public function __construct(
MetadataPool $metadataPool,
ResourceConnection $resource,
StoreManagerInterface $storeManager
) {
$this->metadataPool = $metadataPool;
$this->resource = $resource;
$this->storeManager = $storeManager;
}

/**
* Joins website-product relation table to filter products that are only in current website
*
* {@inheritdoc}
*/
public function process(Select $select)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$select->joinInner(
['pw' => $this->resource->getTableName('catalog_product_website')],
'pw.product_id = ' . BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS . '.' . $linkField
. ' AND pw.website_id = ' . $this->storeManager->getWebsite()->getId(),
[]
);

return $select;
}
}
110 changes: 110 additions & 0 deletions app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Test\Unit\Model;

use Magento\Catalog\Model\ProductLink\CollectionProvider;
use Magento\Catalog\Model\ProductLink\CollectionProviderInterface;
use Magento\Catalog\Model\ProductLink\Converter\ConverterInterface;
use Magento\Catalog\Model\ProductLink\Converter\ConverterPool;
use Magento\Catalog\Model\Product;

class CollectionProviderTest extends \PHPUnit_Framework_TestCase
{
/**
* @var CollectionProvider
*/
private $model;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $converterPoolMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $providerMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $productMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $converterMock;

protected function setUp()
{
$this->productMock = $this->getMock(Product::class, [], [], '', false, false);
$this->converterPoolMock = $this->getMock(ConverterPool::class, [], [], '', false, false);
$this->providerMock = $this->getMock(CollectionProviderInterface::class);
$this->converterMock = $this->getMock(ConverterInterface::class);

$this->model = new CollectionProvider($this->converterPoolMock, ['crosssell' => $this->providerMock]);
}

/**
* Test sort order of linked products based on configured item position.
*/
public function testGetCollection()
{
$linkedProductOneMock = $this->getMock(Product::class, [], [], '', false, false);
$linkedProductTwoMock = $this->getMock(Product::class, [], [], '', false, false);
$linkedProductThreeMock = $this->getMock(Product::class, [], [], '', false, false);

$linkedProductOneMock->expects($this->once())->method('getId')->willReturn(1);
$linkedProductTwoMock->expects($this->once())->method('getId')->willReturn(2);
$linkedProductThreeMock->expects($this->once())->method('getId')->willReturn(3);

$this->converterPoolMock->expects($this->once())
->method('getConverter')
->with('crosssell')
->willReturn($this->converterMock);

$map = [
[$linkedProductOneMock, ['name' => 'Product One', 'position' => 10]],
[$linkedProductTwoMock, ['name' => 'Product Two', 'position' => 2]],
[$linkedProductThreeMock, ['name' => 'Product Three', 'position' => 2]],
];

$this->converterMock->expects($this->exactly(3))->method('convert')->willReturnMap($map);

$this->providerMock->expects($this->once())
->method('getLinkedProducts')
->with($this->productMock)
->willReturn(
[
$linkedProductOneMock,
$linkedProductTwoMock,
$linkedProductThreeMock
]
);

$expectedResult = [
2 => ['name' => 'Product Two', 'position' => 2],
3 => ['name' => 'Product Three', 'position' => 2],
10 => ['name' => 'Product One', 'position' => 10],
];

$actualResult = $this->model->getCollection($this->productMock, 'crosssell');

$this->assertEquals($expectedResult, $actualResult, 'Sort order of linked products in incorrect');
}

/**
* Test exception when collection provider is not configured for product link type.
*
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
* @expectedExceptionMessage Collection provider is not registered
*/
public function testGetCollectionWithMissingProviders()
{
$this->model->getCollection($this->productMock, 'upsell');
}
}
Loading