Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:magento/magento2ce into MPI-bugf…
Browse files Browse the repository at this point in the history
…ixes
  • Loading branch information
YevSent committed Mar 14, 2017
2 parents ed7f6e5 + 24f950d commit 9e86f00
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 20 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function sendPurgeRequest($tagsPattern)
'1.1',
$headers
);
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'tagsPattern'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public function testSendPurgeRequest($hosts)
$this->socketAdapterMock->expects($this->at($i++))
->method('write')
->with('PURGE', $uri, '1.1', ['X-Magento-Tags-Pattern' => 'tags', 'Host' => $uri->getHost()]);
$this->socketAdapterMock->expects($this->at($i++))
->method('read');
$i++;
}
$this->socketAdapterMock->expects($this->exactly(count($uris)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<argument name="at_call" xsi:type="string">getShortDescription</argument>
<argument name="at_code" xsi:type="string">short_description</argument>
<argument name="css_class" xsi:type="string">overview</argument>
<argument name="at_label" translate="true" xsi:type="string">none</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Overview</argument>
<argument name="add_attribute" xsi:type="string">itemprop="description"</argument>
</arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ public function getFinalPrice($qty, $product)
*/
public function getPrice($product)
{
if ($product->getCustomOption('simple_product')) {
return $product->getCustomOption('simple_product')->getProduct()->getPrice();
} else {
return 0;
if (!empty($product)) {
$simpleProductOption = $product->getCustomOption('simple_product');
if (!empty($simpleProductOption)) {
$simpleProduct = $simpleProductOption->getProduct();
if (!empty($simpleProduct)) {
return $simpleProduct->getPrice();
}
}
}
return 0;
}
}
5 changes: 4 additions & 1 deletion app/code/Magento/Quote/Model/ResourceModel/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,17 @@ public function substractProductFromQuotes($product)
}
$connection = $this->getConnection();
$subSelect = $connection->select();
$conditionCheck = $connection->quoteIdentifier('q.items_count') . " > 0";
$conditionTrue = $connection->quoteIdentifier('q.items_count') . ' - 1';
$ifSql = "IF (" . $conditionCheck . "," . $conditionTrue . ", 0)";

$subSelect->from(
false,
[
'items_qty' => new \Zend_Db_Expr(
$connection->quoteIdentifier('q.items_qty') . ' - ' . $connection->quoteIdentifier('qi.qty')
),
'items_count' => new \Zend_Db_Expr($connection->quoteIdentifier('q.items_count') . ' - 1')
'items_count' => new \Zend_Db_Expr($ifSql)
]
)->join(
['qi' => $this->getTable('quote_item')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*
* The original name of this file, as part of the swagger-ui package, was dist/index.html.
*
* Modified by Magento, Modifications Copyright © 2016 Magento.
* Modified by Magento, Modifications Copyright © 2013-2017 Magento.
*/

/** @var \Magento\Framework\View\Element\Template $block */

$schemaUrl = rtrim($block->getBaseUrl(), '/') . '/rest/default/schema?services=all';
$schemaUrl = rtrim($block->getBaseUrl(), '/') . '/rest/all/schema?services=all';
?>

<div id='header'>
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ protected function _addField($parameter)
}
}

$data['value'] = html_entity_decode($data['value']);

// prepare element dropdown values
if ($values = $parameter->getValues()) {
// dropdown options are specified in configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="Magento\Backend\Test\TestCase\NavigateMenuTest">
<variation name="NavigateMenuTest9">
<data name="menuItem" xsi:type="string">Products > Catalog</data>
<data name="pageTitle" xsi:type="string">Catalog</data>
<data name="menuItem" xsi:type="string">Catalog > Products</data>
<data name="pageTitle" xsi:type="string">Products</data>
<constraint name="Magento\Backend\Test\Constraint\AssertBackendPageIsAvailable"/>
</variation>
<variation name="NavigateMenuTest10">
<data name="menuItem" xsi:type="string">Products > Categories</data>
<data name="menuItem" xsi:type="string">Catalog > Categories</data>
<data name="pageTitle" xsi:type="string">Default Category (ID: 2)</data>
<constraint name="Magento\Backend\Test\Constraint\AssertBackendPageIsAvailable"/>
</variation>
Expand Down
15 changes: 11 additions & 4 deletions lib/internal/Magento/Framework/App/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

namespace Magento\Framework\App;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\AppInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Autoload\AutoloaderRegistry;
use Magento\Framework\Autoload\Populator;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Profiler;
use Magento\Framework\Config\File\ConfigFilePool;

/**
* A bootstrap of Magento application
Expand Down Expand Up @@ -284,7 +284,14 @@ protected function assertMaintenance()
$this->initObjectManager();
/** @var \Magento\Framework\App\MaintenanceMode $maintenance */
$this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class);
$isOn = $this->maintenance->isOn(isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : '');

/** @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $phpRemoteAddressEnvironment */
$phpRemoteAddressEnvironment = $this->objectManager->get(
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class
);
$remoteAddress = $phpRemoteAddressEnvironment->getRemoteAddress();
$isOn = $this->maintenance->isOn($remoteAddress ? $remoteAddress : '');

if ($isOn && !$isExpected) {
$this->errorCode = self::ERR_MAINTENANCE;
throw new \Exception('Unable to proceed: the maintenance mode is enabled. ');
Expand Down Expand Up @@ -332,7 +339,7 @@ private function getIsExpected($key, $default)
{
if (array_key_exists($key, $this->server)) {
if (isset($this->server[$key])) {
return (bool)(int)$this->server[$key];
return (bool) (int) $this->server[$key];
}
return null;
}
Expand Down
17 changes: 12 additions & 5 deletions lib/internal/Magento/Framework/App/Test/Unit/BootstrapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

namespace Magento\Framework\App\Test\Unit;

use Magento\Framework\App\Filesystem\DirectoryList;
use \Magento\Framework\App\Bootstrap;
use \Magento\Framework\App\State;
use \Magento\Framework\App\MaintenanceMode;

use Magento\Framework\App\Filesystem\DirectoryList;
use \Magento\Framework\App\State;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -64,6 +63,11 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase
*/
protected $bootstrapMock;

/**
* @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress | \PHPUnit_Framework_MockObject_MockObject
*/
protected $remoteAddress;

protected function setUp()
{
$this->objectManagerFactory = $this->getMock(
Expand All @@ -82,6 +86,7 @@ protected function setUp()
false
);
$this->maintenanceMode = $this->getMock(\Magento\Framework\App\MaintenanceMode::class, ['isOn'], [], '', false);
$this->remoteAddress = $this->getMock('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress', [], [], '', false);
$filesystem = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false);

$this->logger = $this->getMock(\Psr\Log\LoggerInterface::class);
Expand All @@ -91,6 +96,7 @@ protected function setUp()
$mapObjectManager = [
[\Magento\Framework\App\Filesystem\DirectoryList::class, $this->dirs],
[\Magento\Framework\App\MaintenanceMode::class, $this->maintenanceMode],
[\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class, $this->remoteAddress],
[\Magento\Framework\Filesystem::class, $filesystem],
[\Magento\Framework\App\DeploymentConfig::class, $this->deploymentConfig],
['Psr\Log\LoggerInterface', $this->logger],
Expand Down Expand Up @@ -205,7 +211,7 @@ public function testIsDeveloperModeDataProvider()
[State::MODE_DEVELOPER, State::MODE_PRODUCTION, true],
[State::MODE_PRODUCTION, State::MODE_DEVELOPER, false],
[null, State::MODE_DEVELOPER, true],
[null, State::MODE_PRODUCTION, false]
[null, State::MODE_PRODUCTION, false],
];
}

Expand Down Expand Up @@ -260,6 +266,7 @@ public function testAssertMaintenance($isOn, $isExpected)
{
$bootstrap = self::createBootstrap([Bootstrap::PARAM_REQUIRE_MAINTENANCE => $isExpected]);
$this->maintenanceMode->expects($this->once())->method('isOn')->willReturn($isOn);
$this->remoteAddress->expects($this->once())->method('getRemoteAddress')->willReturn(false);
$this->application->expects($this->never())->method('launch');
$this->application->expects($this->once())->method('catchException')->willReturn(true);
$bootstrap->run($this->application);
Expand All @@ -273,7 +280,7 @@ public function assertMaintenanceDataProvider()
{
return [
[true, false],
[false, true]
[false, true],
];
}

Expand Down

0 comments on commit 9e86f00

Please sign in to comment.