Skip to content

Commit

Permalink
Merge pull request #1 from magento/develop
Browse files Browse the repository at this point in the history
Merged mg2 develop into develop
  • Loading branch information
koenner01 authored Feb 21, 2017
2 parents ad9c8e3 + b180d87 commit 52405c5
Show file tree
Hide file tree
Showing 53 changed files with 1,422 additions and 177 deletions.
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

0 comments on commit 52405c5

Please sign in to comment.