Skip to content

Commit 1814285

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MPI-PR-PayPal
2 parents 00cc167 + 1b719ef commit 1814285

File tree

8 files changed

+144
-37
lines changed

8 files changed

+144
-37
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg/Content.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
use Magento\Backend\Block\Widget\Form;
1515
use Magento\Backend\Block\Widget\Form\Generic;
1616

17+
/**
18+
* Class Content
19+
*
20+
* @deprecated
21+
* @see \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav
22+
*/
1723
class Content extends Generic
1824
{
1925
/**

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,10 @@ private function customizeWysiwyg(ProductAttributeInterface $attribute, array $m
754754
$meta['arguments']['data']['config']['wysiwyg'] = true;
755755
$meta['arguments']['data']['config']['wysiwygConfigData'] = [
756756
'add_variables' => false,
757-
'add_widgets' => false
757+
'add_widgets' => false,
758+
'add_directives' => true,
759+
'use_container' => true,
760+
'container_class' => 'hor-scroll',
758761
];
759762

760763
return $meta;

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Export;
77

8-
use Magento\Framework\DB\Ddl\Table;
98
use Magento\ImportExport\Model\Import;
109
use \Magento\Store\Model\Store;
1110
use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
@@ -850,6 +849,24 @@ public function export()
850849
return $writer->getContents();
851850
}
852851

852+
/**
853+
* {@inheritdoc}
854+
*/
855+
protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection\AbstractCollection $collection)
856+
{
857+
$exportFilter = !empty($this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP]) ?
858+
$this->_parameters[\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP] : [];
859+
860+
if (isset($exportFilter['category_ids'])
861+
&& trim($exportFilter['category_ids'])
862+
&& $collection instanceof \Magento\Catalog\Model\ResourceModel\Product\Collection
863+
) {
864+
$collection->addCategoriesFilter(['in' => explode(',', $exportFilter['category_ids'])]);
865+
}
866+
867+
return parent::_prepareEntityCollection($collection);
868+
}
869+
853870
/**
854871
* Get export data for collection
855872
*

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,34 @@ public function testExportWithFieldsEnclosure()
227227

228228
$this->assertContains('""Option 2""', $exportData);
229229
$this->assertContains('""Option 3""', $exportData);
230-
$this->assertContains('""Option 4 """"!@#$%^&*"""', $exportData);
231-
$this->assertContains('text_attribute=""!@#$%^&*()_+1234567890-=|\:;"""', $exportData);
230+
$this->assertContains('""Option 4 """"!@#$%^&*""', $exportData);
231+
$this->assertContains('text_attribute=""!@#$%^&*()_+1234567890-=|\:;""""\'<,>.?/', $exportData);
232+
}
233+
234+
/**
235+
* Verify that "category ids" filter correctly applies to export result
236+
*
237+
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_categories.php
238+
*/
239+
public function testCategoryIdsFilter()
240+
{
241+
$this->model->setWriter(
242+
$this->objectManager->create(
243+
\Magento\ImportExport\Model\Export\Adapter\Csv::class
244+
)
245+
);
246+
247+
$this->model->setParameters([
248+
\Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP => [
249+
'category_ids' => '2,13'
250+
]
251+
]);
252+
253+
$exportData = $this->model->export();
254+
255+
$this->assertContains('Simple Product', $exportData);
256+
$this->assertContains('Simple Product Three', $exportData);
257+
$this->assertNotContains('Simple Product Two', $exportData);
258+
$this->assertNotContains('Simple Product Not Visible On Storefront', $exportData);
232259
}
233260
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize();
8+
9+
require dirname(dirname(__DIR__)) . '/Catalog/_files/categories.php';

dev/tests/static/get_github_changes.php

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// @codingStandardsIgnoreFile
1313

1414
define(
15-
'USAGE',
16-
<<<USAGE
17-
php -f get_github_changes.php --
15+
'USAGE',
16+
<<<USAGE
17+
php -f get_github_changes.php --
1818
--output-file="<output_file>"
1919
--base-path="<base_path>"
2020
--repo="<main_repo>"
@@ -36,6 +36,8 @@
3636

3737
$mainline = 'mainline_' . (string)rand(0, 9999);
3838
$repo = getRepo($options, $mainline);
39+
$branches = $repo->getBranches('--remotes');
40+
generateBranchesList($options['output-file'], $branches, $options['branch']);
3941
$changes = retrieveChangesAcrossForks($mainline, $repo, $options['branch']);
4042
$changedFiles = getChangedFiles($changes, $fileExtensions);
4143
generateChangedFilesList($options['output-file'], $changedFiles);
@@ -57,6 +59,25 @@ function generateChangedFilesList($outputFile, $changedFiles)
5759
fclose($changedFilesList);
5860
}
5961

62+
/**
63+
* Generates a file containing origin branches
64+
*
65+
* @param string $outputFile
66+
* @param array $branches
67+
* @param string $branchName
68+
* @return void
69+
*/
70+
function generateBranchesList($outputFile, $branches, $branchName)
71+
{
72+
$branchOutputFile = str_replace('changed_files', 'branches', $outputFile);
73+
$branchesList = fopen($branchOutputFile, 'w');
74+
fwrite($branchesList, $branchName . PHP_EOL);
75+
foreach ($branches as $branch) {
76+
fwrite($branchesList, substr(strrchr($branch, '/'), 1) . PHP_EOL);
77+
}
78+
fclose($branchesList);
79+
}
80+
6081
/**
6182
* Gets list of changed files
6283
*
@@ -84,7 +105,7 @@ function getChangedFiles(array $changes, array $fileExtensions)
84105
*
85106
* @param array $options
86107
* @param string $mainline
87-
* @return array
108+
* @return GitRepo
88109
* @throws Exception
89110
*/
90111
function getRepo($options, $mainline)
@@ -203,6 +224,19 @@ public function fetch($remoteAlias)
203224
$this->call(sprintf('fetch %s', $remoteAlias));
204225
}
205226

227+
/**
228+
* Returns branches
229+
*
230+
* @param string $source
231+
* @return array|mixed
232+
*/
233+
public function getBranches($source = '--all')
234+
{
235+
$result = $this->call(sprintf('branch ' . $source));
236+
237+
return is_array($result) ? $result : [];
238+
}
239+
206240
/**
207241
* Returns files changes between branch and HEAD
208242
*

dev/tests/static/testsuite/Magento/Test/Legacy/ModuleDBChangeTest.php

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,69 +15,78 @@ class ModuleDBChangeTest extends \PHPUnit_Framework_TestCase
1515
/**
1616
* @var string
1717
*/
18-
protected static $changedFilesPattern = __DIR__ . '/../_files/changed_files*';
18+
private static $branchesFilesPattern = __DIR__ . '/../_files/branches*';
1919

2020
/**
2121
* @var string
2222
*/
23-
protected static $changedFileList = '';
23+
private static $changedFilesPattern = __DIR__ . '/../_files/changed_files*';
2424

2525
/**
26-
* @var string Path for Magento's composer.json
26+
* @var string
2727
*/
28-
protected static $composerFilePath = BP . '/composer.json';
28+
private static $changedFileList = '';
2929

3030
/**
31-
* @var bool Is tests executes on develop branch
31+
* @var bool
3232
*/
33-
protected static $isOnDevVersion = false;
33+
private static $actualBranch = false;
3434

3535
/**
3636
* Set changed files paths and list for all projects
3737
*/
3838
public static function setUpBeforeClass()
3939
{
40-
foreach (glob(self::$changedFilesPattern) as $changedFile) {
41-
self::$changedFileList .= file_get_contents($changedFile) . PHP_EOL;
42-
}
40+
foreach (glob(self::$branchesFilesPattern) as $branchesFile) {
41+
//get the current branchname from the first line
42+
$branchName = trim(file($branchesFile)[0]);
43+
if ($branchName === 'develop') {
44+
self::$actualBranch = true;
45+
} else {
46+
//get current minor branch name
47+
preg_match('|^(\d+\.\d+)|', $branchName, $minorBranch);
48+
$branchName = $minorBranch[0];
49+
50+
//get all version branches
51+
preg_match_all('|^(\d+\.\d+)|m', file_get_contents($branchesFile), $matches);
4352

44-
if (file_exists(self::$composerFilePath)) {
45-
$jsonData = json_decode(file_get_contents(self::$composerFilePath));
46-
if (substr((string) $jsonData->version, -4) == '-dev') {
47-
self::$isOnDevVersion = true;
53+
//check is this a latest release branch
54+
self::$actualBranch = ($branchName == max($matches[0]));
4855
}
4956
}
57+
58+
foreach (glob(self::$changedFilesPattern) as $changedFile) {
59+
self::$changedFileList .= file_get_contents($changedFile) . PHP_EOL;
60+
}
5061
}
5162

5263
/**
5364
* Test changes for module.xml files
5465
*/
5566
public function testModuleXmlFiles()
5667
{
57-
if (self::$isOnDevVersion) {
58-
$this->markTestSkipped('This test isn\'t applicable to the developer version of Magento');
68+
if (!self::$actualBranch) {
69+
preg_match_all('|etc/module\.xml$|mi', self::$changedFileList, $matches);
70+
$this->assertEmpty(
71+
reset($matches),
72+
'module.xml changes for patch releases in non-actual branches are not allowed:' . PHP_EOL .
73+
implode(PHP_EOL, array_values(reset($matches)))
74+
);
5975
}
60-
preg_match_all('|etc/module\.xml$|mi', self::$changedFileList, $matches);
61-
$this->assertEmpty(
62-
reset($matches),
63-
'module.xml changes for patch releases in non-actual branches are not allowed:' . PHP_EOL .
64-
implode(PHP_EOL, array_values(reset($matches)))
65-
);
6676
}
6777

6878
/**
6979
* Test changes for files in Module Setup dir
7080
*/
7181
public function testModuleSetupFiles()
7282
{
73-
if (self::$isOnDevVersion) {
74-
$this->markTestSkipped('This test isn\'t applicable to the developer version of Magento');
83+
if (!self::$actualBranch) {
84+
preg_match_all('|app/code/Magento/[^/]+/Setup/[^/]+$|mi', self::$changedFileList, $matches);
85+
$this->assertEmpty(
86+
reset($matches),
87+
'Code with changes for DB schema or data in non-actual branches are not allowed:' . PHP_EOL .
88+
implode(PHP_EOL, array_values(reset($matches)))
89+
);
7590
}
76-
preg_match_all('|app/code/Magento/[^/]+/Setup/[^/]+$|mi', self::$changedFileList, $matches);
77-
$this->assertEmpty(
78-
reset($matches),
79-
'Code with changes for DB schema or data in non-actual branches are not allowed:' . PHP_EOL .
80-
implode(PHP_EOL, array_values(reset($matches)))
81-
);
8291
}
8392
}

lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ define([
357357
// escape special chars in directives url to use it in regular expression
358358
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1');
359359
var reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));
360+
content = decodeURIComponent(content);
361+
360362
return content.gsub(reg, function(match) {
361363
return Base64.mageDecode(match[1]);
362364
}.bind(this));

0 commit comments

Comments
 (0)