Skip to content

Commit

Permalink
Merge pull request #483 from magento-tango/MAGETWO-50892
Browse files Browse the repository at this point in the history
[Tango] Bug fixes
  • Loading branch information
magicbunneh committed Mar 25, 2016
2 parents e03c5ae + baed4c6 commit ff7ea7e
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha">
<block class="Magento\Captcha\Block\Captcha" name="captcha" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">backend_forgotpassword</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha">
<block class="Magento\Captcha\Block\Captcha" name="captcha" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">backend_login</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">contact_us</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_create</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_edit</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_forgotpassword</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="form.additional.info">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-">
<block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
<action method="setFormId">
<argument name="formId" xsi:type="string">user_login</argument>
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
*/
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;

use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Model\Product\Type;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General;

/**
* @method \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images getModel
Expand All @@ -26,47 +24,7 @@ protected function createModel()

public function testModifyData()
{
$productId = 1;
$modelId = 1;

$data = [
$modelId => [
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General::DATA_SOURCE_DEFAULT => [
ProductAttributeInterface::CODE_SKU => 'product_42',
ProductAttributeInterface::CODE_PRICE => '42.00',
ProductAttributeInterface::CODE_STATUS => '1',
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_MEDIA_GALLERY => [
'images' => [
[
'value_id' => '1',
'file' => 'filename.jpg',
'media_type' => 'image',
]
]
],
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_IMAGE => 'filename.jpg',
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_SMALL_IMAGE => 'filename.jpg',
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_THUMBNAIL => 'filename.jpg',
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Images::CODE_SWATCH_IMAGE => 'filename.jpg',
]
]
];

$expectedData = [
$modelId => [
General::DATA_SOURCE_DEFAULT => [
ProductAttributeInterface::CODE_SKU => 'product_42',
ProductAttributeInterface::CODE_PRICE => '42.00',
ProductAttributeInterface::CODE_STATUS => '1',
]
]
];

$this->productMock->expects($this->once())
->method('getId')
->willReturn($productId);

$this->assertSame($expectedData, $this->getModel()->modifyData($data));
$this->assertSame($this->getSampleData(), $this->getModel()->modifyData($this->getSampleData()));
}

public function testModifyMeta()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,51 +41,16 @@ public function __construct(LocatorInterface $locator)
*/
public function modifyMeta(array $meta)
{
return $this->customizeImagesTab($meta);
unset($meta[self::CODE_IMAGE_MANAGEMENT_GROUP]);

return $meta;
}

/**
* {@inheritdoc}
*/
public function modifyData(array $data)
{
$modelId = $this->locator->getProduct()->getId();

if ($modelId != null) {
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_MEDIA_GALLERY])) {
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_MEDIA_GALLERY]);
}
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_IMAGE])) {
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_IMAGE]);
}
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SMALL_IMAGE])) {
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SMALL_IMAGE]);
}
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_THUMBNAIL])) {
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_THUMBNAIL]);
}
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SWATCH_IMAGE])) {
unset($data[$modelId][self::DATA_SOURCE_DEFAULT][self::CODE_SWATCH_IMAGE]);
}
}

return $data;
}

/**
* Remove Images tab from meta because it's block is rendered in layout
*
* @param array $meta
* @return array
*/
protected function customizeImagesTab(array $meta)
{
foreach (array_keys($meta) as $groupName) {
if ($groupName === self::CODE_IMAGE_MANAGEMENT_GROUP) {
unset($meta[self::CODE_IMAGE_MANAGEMENT_GROUP]);
}
}

return $meta;
}
}
20 changes: 19 additions & 1 deletion lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function interpret(
break;

case self::HEAD_META:
$pageConfigStructure->setMetaData($node->getAttribute('name'), $node->getAttribute('content'));
$this->setMetadata($pageConfigStructure, $node);
break;

case self::HEAD_ATTRIBUTE:
Expand Down Expand Up @@ -122,4 +122,22 @@ protected function getAttributes($element)
}
return $attributes;
}

/**
* Set metadata
*
* @param \Magento\Framework\View\Page\Config\Structure $pageConfigStructure
* @param \Magento\Framework\View\Layout\Element $node
* @return void
*/
private function setMetadata($pageConfigStructure, $node)
{
if (!$node->getAttribute('name') && $node->getAttribute('property')) {
$metadataName = $node->getAttribute('property');
} else {
$metadataName = $node->getAttribute('name');
}

$pageConfigStructure->setMetaData($metadataName, $node->getAttribute('content'));
}
}
4 changes: 4 additions & 0 deletions lib/internal/Magento/Framework/View/Page/Config/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ protected function processMetadataContent($name, $content)
*/
protected function getMetadataTemplate($name)
{
if (strpos($name, 'og:') === 0) {
return '<meta property="' . $name . '" content="%content"/>' . "\n";
}

switch ($name) {
case 'charset':
$metadataTemplate = '<meta charset="%content"/>' . "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,36 @@ public function testInterpret()
->willReturnSelf();

$structureMock->expects($this->at(2))
->method('setMetaData')
->with('og:video:secure_url', 'https://secure.example.com/movie.swf')
->willReturnSelf();

$structureMock->expects($this->at(3))
->method('setMetaData')
->with('og:locale:alternate', 'uk_UA')
->willReturnSelf();

$structureMock->expects($this->at(4))
->method('addAssets')
->with('path/file.css', ['src' => 'path/file.css', 'media' => 'all', 'content_type' => 'css'])
->willReturnSelf();

$structureMock->expects($this->at(3))
$structureMock->expects($this->at(5))
->method('addAssets')
->with('path/file.js', ['src' => 'path/file.js', 'defer' => 'defer', 'content_type' => 'js'])
->willReturnSelf();

$structureMock->expects($this->at(4))
$structureMock->expects($this->at(6))
->method('addAssets')
->with('http://url.com', ['src' => 'http://url.com', 'src_type' => 'url'])
->willReturnSelf();

$structureMock->expects($this->at(5))
$structureMock->expects($this->at(7))
->method('removeAssets')
->with('path/remove/file.css')
->willReturnSelf();

$structureMock->expects($this->at(6))
$structureMock->expects($this->at(8))
->method('setElementAttribute')
->with(Config::ELEMENT_TYPE_HEAD, 'head_attribute_name', 'head_attribute_value')
->willReturnSelf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ public function testRenderMetadata()
'content_type' => 'content_type_value',
'x_ua_compatible' => 'x_ua_compatible_value',
'media_type' => 'media_type_value',
'og:video:secure_url' => 'secure_url'
];
$metadataValueCharset = 'newCharsetValue';

$expected = '<meta charset="newCharsetValue"/>' . "\n"
. '<meta name="metadataName" content="metadataValue"/>' . "\n"
. '<meta http-equiv="Content-Type" content="content_type_value"/>' . "\n"
. '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/>' . "\n";
. '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/>' . "\n"
. '<meta property="og:video:secure_url" content="secure_url"/>' . "\n";

$this->stringMock->expects($this->at(0))
->method('upperCaseWords')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<head>
<title>Test title</title>
<meta name="meta_name" content="meta_content"/>
<meta property="og:video:secure_url" content="https://secure.example.com/movie.swf" />
<meta property="og:locale:alternate" content="uk_UA" />
<css src="path/file.css" media="all" />
<script src="path/file.js" defer="defer"/>
<link src="http://url.com" src_type="url"/>
Expand Down

0 comments on commit ff7ea7e

Please sign in to comment.