Skip to content

Commit

Permalink
Merge pull request #1058 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests:

#9129
#5372
  • Loading branch information
Oleksii Korshenko authored Apr 22, 2017
2 parents 0e3a90f + e151a82 commit 2f04074
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public function execute()
$this->productBuilder->build($this->getRequest());

/** @var \Magento\Framework\View\Result\Layout $resultLayout */
$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultLayout->getLayout()->getUpdate()->removeHandle('default');

$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
return $resultLayout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\ConfigurableProduct\Test\Unit\Controller\Adminhtml\Product;

use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

class WizardTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $resultFactory;

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

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

/**
* @var \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Wizard
*/
private $model;

protected function setUp()
{
$this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
->disableOriginalConstructor()
->getMock();
$this->productBuilder = $this->getMockBuilder(\Magento\Catalog\Controller\Adminhtml\Product\Builder::class)
->disableOriginalConstructor()
->setMethods(['build'])
->getMock();
$this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
->disableOriginalConstructor()
->getMock();
$context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
->disableOriginalConstructor()
->getMock();

$context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
$context->expects($this->any())->method('getRequest')->willReturn($this->request);

$objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $objectManagerHelper->getObject(
\Magento\ConfigurableProduct\Controller\Adminhtml\Product\Wizard::class,
[
'context' => $context,
'productBuilder' => $this->productBuilder
]
);
}

public function testExecute()
{
$this->productBuilder->expects($this->once())->method('build')->with($this->request);
$this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_LAYOUT);

$this->model->execute();
}
}
7 changes: 7 additions & 0 deletions lib/internal/Magento/Framework/Filesystem/Driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,13 @@ public function fileUnlock($resource)
*/
public function getAbsolutePath($basePath, $path, $scheme = null)
{
// check if the path given is already an absolute path containing the
// basepath. so if the basepath starts at position 0 in the path, we
// must not concatinate them again because path is already absolute.
if (0 === strpos($path, $basePath)) {
return $this->getScheme($scheme) . $path;
}

return $this->getScheme($scheme) . $basePath . ltrim($this->fixSeparator($path), '/');
}

Expand Down
7 changes: 7 additions & 0 deletions lib/internal/Magento/Framework/Filesystem/Driver/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ public function fileReadLine($resource, $length, $ending = null)
*/
public function getAbsolutePath($basePath, $path, $scheme = null)
{
// check if the path given is already an absolute path containing the
// basepath. so if the basepath starts at position 0 in the path, we
// must not concatinate them again because path is already absolute.
if (0 === strpos($path, $basePath)) {
return $this->getScheme() . $path;
}

return $this->getScheme() . $basePath . $path;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public function testGetAbsolutePath($basePath, $path, $expected)
$file = new File();
$this->assertEquals($expected, $file->getAbsolutePath($basePath, $path));
}

public function dataProviderForTestGetAbsolutePath()
{
return [
['/root/path/', 'sub', '/root/path/sub'],
['/root/path/', '/sub', '/root/path/sub'],
['/root/path/', '../sub', '/root/path/../sub'],
['/root/path/', '/root/path/sub', '/root/path/root/path/sub'],
['/root/path/', '/root/path/sub', '/root/path/sub'],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __destructor()
*/
public function __destruct()
{
if (is_resource($this->_fileHandler)) {
if ($this->_fileHandler !== STDOUT && is_resource($this->_fileHandler)) {
fclose($this->_fileHandler);
}
}
Expand Down

0 comments on commit 2f04074

Please sign in to comment.