Skip to content

Commit

Permalink
Merge pull request #422 from magento-api/ext-public-pull-requests
Browse files Browse the repository at this point in the history
[API] Public Pull Requests
  • Loading branch information
Korshenko, Oleksii(okorshenko) committed Mar 8, 2016
2 parents 1bda4bf + 7c31129 commit b0bf806
Show file tree
Hide file tree
Showing 23 changed files with 271 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public function render(\Magento\Framework\DataObject $row)
{
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' . __(
'Read Details'
) . '</a>' : '';
) . '</a> | ' : '';

$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
'*/*/markAsRead/',
['_current' => true, 'id' => $row->getId()]
) . '">' . __(
'Mark as Read'
) . '</a>' : '';
) . '</a> | ' : '';

$encodedUrl = $this->_urlHelper->getEncodedUrl();
return sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private function processPaymentConfiguration(array &$configuration, array $eleme
'telephone' => [
'config' => [
'tooltip' => [
'description' => 'For delivery questions.',
'description' => __('For delivery questions.'),
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,47 +87,49 @@ protected function configure()
{
parent::configure();
$this->setDescription('Collects and publishes source files for theme.')
->setDefinition([
new InputArgument(
self::FILE_ARGUMENT,
InputArgument::IS_ARRAY,
'Files to pre-process (file should be specified without extension)',
['css/styles-m', 'css/styles-l']
),
new InputOption(
self::TYPE_ARGUMENT,
null,
InputOption::VALUE_REQUIRED,
'Type of source files: [less]',
'less'
),
new InputOption(
self::LOCALE_OPTION,
null,
InputOption::VALUE_REQUIRED,
'Locale: [en_US]',
'en_US'
),
new InputOption(
self::AREA_OPTION,
null,
InputOption::VALUE_REQUIRED,
'Area: [frontend|adminhtml]',
'frontend'
),
new InputOption(
self::THEME_OPTION,
null,
InputOption::VALUE_REQUIRED,
'Theme: [Vendor/theme]',
'Magento/luma'
),

]);
->setDefinition(
[
new InputArgument(
self::FILE_ARGUMENT,
InputArgument::IS_ARRAY,
'Files to pre-process (file should be specified without extension)',
['css/styles-m', 'css/styles-l']
),
new InputOption(
self::TYPE_ARGUMENT,
null,
InputOption::VALUE_REQUIRED,
'Type of source files: [less]',
'less'
),
new InputOption(
self::LOCALE_OPTION,
null,
InputOption::VALUE_REQUIRED,
'Locale: [en_US]',
'en_US'
),
new InputOption(
self::AREA_OPTION,
null,
InputOption::VALUE_REQUIRED,
'Area: [frontend|adminhtml]',
'frontend'
),
new InputOption(
self::THEME_OPTION,
null,
InputOption::VALUE_REQUIRED,
'Theme: [Vendor/theme]',
'Magento/luma'
),

]
);
}

/**
* @inheritdoc
* {@inheritdoc}
* @throws \InvalidArgumentException
*/
protected function execute(InputInterface $input, OutputInterface $output)
Expand All @@ -144,6 +146,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
$locale . ' argument has invalid value, please run info:language:list for list of available locales'
);
}

if (!preg_match('#^[\w\-]+\/[\w\-]+$#', $theme)) {
throw new \InvalidArgumentException(
'Value "' . $theme . '" of the option "' . self::THEME_OPTION .
'" has invalid format. The format should be "Vendor/theme".'
);
}

$message = sprintf(
'<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>',
$area,
Expand All @@ -164,7 +174,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
]
);

$this->assetPublisher->publish($asset);
try {
$this->assetPublisher->publish($asset);
} catch (\Magento\Framework\View\Asset\File\NotFoundException $e) {
throw new \InvalidArgumentException(
'Verify entered values of the argument and options. ' . $e->getMessage()
);
}

$output->writeln('<comment>-> ' . $asset->getFilePath() . '</comment>');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class SourceThemeDeployCommandTest extends \PHPUnit_Framework_TestCase

const LOCALE_TEST_VALUE = 'locale-test-value';

const THEME_TEST_VALUE = 'theme-test-value';
const THEME_TEST_VALUE = 'Vendor/theme';

const THEME_INCORRECT_FORMAT_VALUE = 'theme-value';

const THEME_NONEXISTING_VALUE = 'NonExistentVendor/theme';

const TYPE_TEST_VALUE = 'type-test-value';

Expand Down Expand Up @@ -128,23 +132,103 @@ public function testExecute()
$this->sourceThemeDeployCommand->run($this->getInputMock(), $outputMock);
}

/**
* Run test for execute method with incorrect theme value
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Value "theme-value" of the option "theme" has invalid format. The format should be
*/
public function testExecuteIncorrectThemeFormat()
{
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
$outputMock = $this->getMockBuilder(OutputInterface::class)
->getMockForAbstractClass();
$this->validatorMock->expects(self::once())
->method('isValid')
->with(self::LOCALE_TEST_VALUE)
->willReturn(true);

$valueMap = [
['area', self::AREA_TEST_VALUE],
['locale', self::LOCALE_TEST_VALUE],
['theme', self::THEME_INCORRECT_FORMAT_VALUE],
['type', self::TYPE_TEST_VALUE]
];

$this->sourceThemeDeployCommand->run(
$this->getInputMock($valueMap),
$outputMock
);
}

/**
* Run test for execute method with non existing theme
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Verify entered values of the argument and options.
*/
public function testExecuteNonExistingValue()
{
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
$outputMock = $this->getMockBuilder(OutputInterface::class)
->getMockForAbstractClass();
$assetMock = $this->getMockBuilder(LocalInterface::class)
->getMockForAbstractClass();

$this->validatorMock->expects(self::once())
->method('isValid')
->with(self::LOCALE_TEST_VALUE)
->willReturn(true);

$this->assetRepositoryMock->expects(self::once())
->method('createAsset')
->with(
'file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE,
[
'area' => self::AREA_TEST_VALUE,
'theme' => self::THEME_NONEXISTING_VALUE,
'locale' => self::LOCALE_TEST_VALUE,
]
)->willReturn($assetMock);

$this->assetPublisherMock->expects(self::once())
->method('publish')
->with($assetMock)
->willThrowException(new \Magento\Framework\View\Asset\File\NotFoundException);

$valueMap = [
['area', self::AREA_TEST_VALUE],
['locale', self::LOCALE_TEST_VALUE],
['theme', self::THEME_NONEXISTING_VALUE],
['type', self::TYPE_TEST_VALUE]
];

$this->sourceThemeDeployCommand->run(
$this->getInputMock($valueMap),
$outputMock
);
}

/**
* @return InputInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private function getInputMock()
private function getInputMock(array $valueMap = [])
{
$inputMock = $this->getMockBuilder(InputInterface::class)
->getMockForAbstractClass();

$defaultValueMap = [
['area', self::AREA_TEST_VALUE],
['locale', self::LOCALE_TEST_VALUE],
['theme', self::THEME_TEST_VALUE],
['type', self::TYPE_TEST_VALUE]
];
$valueMap = empty($valueMap) ? $defaultValueMap : $valueMap;

$inputMock->expects(self::exactly(4))
->method('getOption')
->willReturnMap(
[
['area', self::AREA_TEST_VALUE],
['locale', self::LOCALE_TEST_VALUE],
['theme', self::THEME_TEST_VALUE],
['type', self::TYPE_TEST_VALUE]
]
$valueMap
);
$inputMock->expects(self::once())
->method('getArgument')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
class Webservicex extends \Magento\Directory\Model\Currency\Import\AbstractImport
{
/**
* @var string
* Currency converter url
*/
const CURRENCY_CONVERTER_URL = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?' .
'FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}';
// @codingStandardsIgnoreStart
const CURRENCY_CONVERTER_URL = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}';
// @codingStandardsIgnoreEnd

/**
* Http Client Factory
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Email/Model/Template/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ public function getCssFilesContent(array $files)
}
} catch (ContentProcessorException $exception) {
$css = $exception->getMessage();
} catch (\Magento\Framework\View\Asset\File\NotFoundException $exception) {
$css = '';
}

return $css;
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/Store/Ui/Component/Listing/Column/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ public function prepareDataSource(array $dataSource)
protected function prepareItem(array $item)
{
$content = '';
if (!empty($item[$this->storeKey])) {
$origStores = $item[$this->storeKey];
}

if (empty($item[$this->storeKey])) {
if (empty($origStores)) {
return '';
}
$origStores = $item[$this->storeKey];

if (!is_array($origStores)) {
$origStores = [$origStores];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestFramework\Authentication\Rest;

use OAuth\Common\Http\Uri\UriInterface;

/**
* Custom Client implementation for cURL
*/
class CurlClient extends \OAuth\Common\Http\Client\CurlClient
{
/**
* {@inheritdoc}
*/
public function retrieveResponse(
UriInterface $endpoint,
$requestBody,
array $extraHeaders = [],
$method = 'POST'
) {
$this->setCurlParameters([CURLOPT_FAILONERROR => true]);
return parent::retrieveResponse($endpoint, $requestBody, $extraHeaders, $method);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
UriInterface $baseApiUri = null
) {
if (!isset($httpClient)) {
$httpClient = new \OAuth\Common\Http\Client\StreamClient();
$httpClient = new \Magento\TestFramework\Authentication\Rest\CurlClient();
$httpClient->setTimeout(self::DEFAULT_TIMEOUT);
}
if (!isset($storage)) {
Expand Down
Loading

0 comments on commit b0bf806

Please sign in to comment.