diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php index a688ffac5ac019627c137fcb678c56f374599c8b..071604e9cde32e5c8c83484a582ab95099256203 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php @@ -95,6 +95,7 @@ class View extends \Magento\Catalog\Test\Block\Product\View ); $this->_rootElement->find($this->customizeButton)->click(); $this->waitForElementVisible($this->addToCart); + $this->waitForElementVisible($this->visibleOptions, Locator::SELECTOR_XPATH); } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml index 356f6a52d6b0c296abc0eb857fe2d8b3dccc4b84..ecced21254cdc113b5f0d5d3d46be1dbd3a4386e 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml @@ -8,8 +8,7 @@ <mapping strict="1"> <fields> <qty> - <selector>//input[contains(@class,"qty")]</selector> - <strategy>xpath</strategy> + <selector>input.qty</selector> <class>Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option\Element\Qty</class> </qty> </fields> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php index d9b843cc37a0f2ac109ac662183b93119d3e1edc..9a2304c876f89ca8598e47b720154642f9b96ca0 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php @@ -52,6 +52,7 @@ class AssertBundleProductForm extends AssertProductForm protected function prepareBundleOptions(array $bundleSelections) { foreach ($bundleSelections as &$item) { + unset($item['frontend_type']); foreach ($item['assigned_products'] as &$selection) { $selection['data']['getProductName'] = $selection['search_data']['name']; $selection = $selection['data']; diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml index 3bf2e7b7f2ad1387c89752282148fc582d65a0e1..e694b65110e89cd1840ad1249e6c14a61302a877 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml @@ -353,6 +353,7 @@ <item name="3" xsi:type="array"> <item name="title" xsi:type="string">Multiple Select Option</item> <item name="type" xsi:type="string">Multiple</item> + <item name="frontend_type" xsi:type="string">Multiple</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -367,6 +368,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">Test simple product</item> </item> diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/ChangedFiles.php b/dev/tests/static/framework/Magento/TestFramework/Utility/ChangedFiles.php index 571b663067151db4eb05d1484f38e1e10cd9527e..a25b16c2277f3e7052840e9cf1fbbe2660cc4462 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/ChangedFiles.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/ChangedFiles.php @@ -3,6 +3,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\TestFramework\Utility; use Magento\Framework\App\Utility\Files; @@ -15,6 +16,11 @@ use Magento\TestFramework\Utility\File\RegexIteratorFactory; */ class ChangedFiles { + /** + * File path with changed files content. + */ + const CHANGED_FILES_CONTENT_FILE = '/dev/tests/static/testsuite/Magento/Test/_files/changed_%s_files_content.json'; + /** * Returns array of PHP-files, that use or declare Magento application classes and Magento libs * @@ -45,4 +51,36 @@ class ChangedFiles return $phpFiles; } + + /** + * Get changed content. + * + * @param string $fileName + * @return string + */ + public static function getChangedContent($fileName) + { + $data = []; + $extension = self::getFileExtension($fileName); + $fileName = ltrim(str_replace(BP, '', $fileName), DIRECTORY_SEPARATOR); + $changedFilesContentFile = BP . sprintf(self::CHANGED_FILES_CONTENT_FILE, $extension); + if (file_exists($changedFilesContentFile)) { + $changedContent = file_get_contents($changedFilesContentFile); + $data = json_decode($changedContent, true); + } + + return isset($data[$fileName]) ? $data[$fileName] : ''; + } + + /** + * Get file extension. + * + * @param string $fileName + * @return string + */ + public static function getFileExtension($fileName) + { + $fileInfo = pathinfo($fileName); + return isset($fileInfo['extension']) ? $fileInfo['extension'] : 'unknown'; + } } diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/FunctionDetector.php b/dev/tests/static/framework/Magento/TestFramework/Utility/FunctionDetector.php index 17310404e372097169f7cc36dcd8bb125349565d..69162d3dfba2e6d67acb9c9bad48dbb03fc3c41a 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/FunctionDetector.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/FunctionDetector.php @@ -35,19 +35,65 @@ class FunctionDetector { $result = []; $regexp = $this->composeRegexp($functions); - if ($regexp) { - $file = file($filePath); - array_unshift($file, ''); - $lines = preg_grep( - $regexp, - $file - ); - foreach ($lines as $lineNumber => $line) { - if (preg_match_all($regexp, $line, $matches)) { - $result[$lineNumber] = $matches[1]; + + if (!$regexp) { + return $result; + } + + $fileContent = \Magento\TestFramework\Utility\ChangedFiles::getChangedContent($filePath); + $file = file($filePath); + + return $fileContent + ? $this->grepChangedContent($file, $regexp, $functions, $fileContent) + : $this->grepFile($file, $regexp); + } + + /** + * Grep only changed content. + * + * @param array $file + * @param string $regexp + * @param string[] $functions + * @param string $fileContent + * @return array + */ + public function grepChangedContent(array $file, $regexp, $functions, $fileContent) + { + $result = []; + $matches = preg_grep($regexp, explode("\n", $fileContent)); + if (!empty($matches)) { + foreach ($matches as $line) { + $actualFunctions = []; + foreach ($functions as $function) { + if (false !== strpos($line, $function)) { + $actualFunctions[] = $function; + } } + $result[array_search($line . "\n", $file) + 1] = $actualFunctions; } } + + return $result; + } + + /** + * Grep File. + * + * @param array $file + * @param string $regexp + * @return array + */ + public function grepFile(array $file, $regexp) + { + $result = []; + array_unshift($file, ''); + $lines = preg_grep($regexp, $file); + foreach ($lines as $lineNumber => $line) { + if (preg_match_all($regexp, $line, $matches)) { + $result[$lineNumber] = $matches[1]; + } + } + return $result; } diff --git a/dev/tests/static/get_github_changes.php b/dev/tests/static/get_github_changes.php index f332208cd17d0861dd1b28bd7096a0b3fe0066a5..16a4f7d8e090de40c4881f1e3a60015bb377396b 100644 --- a/dev/tests/static/get_github_changes.php +++ b/dev/tests/static/get_github_changes.php @@ -34,6 +34,8 @@ if (!validateInput($options, $requiredOptions)) { $fileExtensions = explode(',', isset($options['file-extensions']) ? $options['file-extensions'] : 'php'); +include_once __DIR__ . '/framework/autoload.php'; + $mainline = 'mainline_' . (string)rand(0, 9999); $repo = getRepo($options, $mainline); $branches = $repo->getBranches('--remotes'); @@ -41,8 +43,27 @@ generateBranchesList($options['output-file'], $branches, $options['branch']); $changes = retrieveChangesAcrossForks($mainline, $repo, $options['branch']); $changedFiles = getChangedFiles($changes, $fileExtensions); generateChangedFilesList($options['output-file'], $changedFiles); +saveChangedFileContent($repo); cleanup($repo, $mainline); +/** + * Save changed file content. + * + * @param GitRepo $repo + * @return void + */ +function saveChangedFileContent(GitRepo $repo) +{ + $changedFilesContentFileName = BP . Magento\TestFramework\Utility\ChangedFiles::CHANGED_FILES_CONTENT_FILE; + foreach ($repo->getChangedContentFiles() as $key => $changedContentFile) { + $filePath = sprintf($changedFilesContentFileName, $key); + $oldContent = file_exists($filePath) ? file_get_contents($filePath) : '{}'; + $oldData = json_decode($oldContent, true); + $data = array_merge($oldData, $changedContentFile); + file_put_contents($filePath, json_encode($data)); + } +} + /** * Generates a file containing changed files * @@ -170,6 +191,18 @@ class GitRepo */ private $remoteList = []; + /** + * Array of changed content files. + * + * Example: + * 'extension' => + * 'path_to_file/filename' => 'Content that was edited', + * 'path_to_file/filename2' => 'Content that was edited', + * + * @var array + */ + private $changedContentFiles = []; + /** * @param string $workTree absolute path to git project */ @@ -285,6 +318,9 @@ class GitRepo 'diff HEAD %s/%s -- %s', $remoteAlias, $remoteBranch, $this->workTree . '/' . $fileName) ); if ($result) { + if (!(isset($this->changedContentFiles[$fileName]))) { + $this->setChangedContentFile($result, $fileName); + } $filteredChanges[] = $fileName; } } @@ -295,6 +331,38 @@ class GitRepo return $filteredChanges; } + /** + * Set changed content for file. + * + * @param array $content + * @param string $fileName + * @return void + */ + private function setChangedContentFile(array $content, $fileName) + { + $changedContent = ''; + $extension = Magento\TestFramework\Utility\ChangedFiles::getFileExtension($fileName); + + foreach ($content as $item) { + if (strpos($item, '---') !== 0 && strpos($item, '-') === 0 && $line = ltrim($item, '-')) { + $changedContent .= $line . "\n"; + } + } + if ($changedContent !== '') { + $this->changedContentFiles[$extension][$fileName] = $changedContent; + } + } + + /** + * Get changed content files collection. + * + * @return array + */ + public function getChangedContentFiles() + { + return $this->changedContentFiles; + } + /** * Makes call ro git cli *