-
Notifications
You must be signed in to change notification settings - Fork 132
PR546 with Upgrade script #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d210dcd
#55 Throw Exception when cannot resolve URL attribute
lbajsarowicz e06c188
Amend PHPUnit tests and Static tests
lbajsarowicz 15d61bb
Change Unit Tests to cover the change (including Exception thrown)
lbajsarowicz fd19fb5
Amend PHPUnit tests
lbajsarowicz c8a8ba9
Improve readability of mustache patterns
lbajsarowicz 7d385ce
Merge remote-tracking branch 'origin/develop' into bugfix/55-missing-…
lbajsarowicz 247029e
Merge branch 'develop' into pr546WithUpgradeScript
KevinBKozan 805814b
Add Upgrade Script
KevinBKozan aa14e7b
Add Upgrade Script
KevinBKozan 1416667
Add Upgrade Script
KevinBKozan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/Magento/FunctionalTestingFramework/Upgrade/UpdatePageWithNoUrl.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\FunctionalTestingFramework\Upgrade; | ||
|
||
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; | ||
use Magento\FunctionalTestingFramework\Page\Handlers\PageObjectHandler; | ||
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler; | ||
use Magento\FunctionalTestingFramework\Util\ModuleResolver; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* Class UpgradePageWithNoUrl | ||
* @package Magento\FunctionalTestingFramework\Upgrade | ||
*/ | ||
class UpdatePageWithNoUrl implements UpgradeInterface | ||
{ | ||
/** | ||
* Upgrades all test xml files, replacing {{page}} with {{page.url}} | ||
* | ||
* @param InputInterface $input | ||
* @return string | ||
*/ | ||
public function execute(InputInterface $input) | ||
{ | ||
$testsPath = $input->getArgument('path'); | ||
$finder = new Finder(); | ||
$finder->files()->in($testsPath)->name("*.xml"); | ||
|
||
// Safely ensure we can get test materials to check for existing pages later | ||
try { | ||
MftfApplicationConfig::create(); | ||
ModuleResolver::getInstance()->getModulesPath(); | ||
} catch (\Exception $e) { | ||
//retry with --force | ||
MftfApplicationConfig::create(true); | ||
ModuleResolver::getInstance()->getModulesPath(); | ||
} | ||
|
||
$fileSystem = new Filesystem(); | ||
$testsUpdated = 0; | ||
foreach ($finder->files() as $file) { | ||
$count = 0; | ||
$contents = $file->getContents(); | ||
// Find {{page}} but not {{page.url}} | ||
preg_match_all("/{{([^\.}]*)}}/", $contents, $pageReferences); | ||
if (empty($pageReferences[1])) { | ||
continue; | ||
} | ||
foreach ($pageReferences[1] as $index => $potentialReplace) { | ||
$isPage = PageObjectHandler::getInstance()->getObject($potentialReplace); | ||
if ($isPage === null) { | ||
continue; | ||
} | ||
$contents = str_replace($pageReferences[0][$index], "{{" . $potentialReplace . ".url}}", $contents); | ||
$count++; | ||
} | ||
$fileSystem->dumpFile($file->getRealPath(), $contents); | ||
if ($count > 0) { | ||
$testsUpdated++; | ||
} | ||
} | ||
return ("{{Page}} without specified \".url\" updated in {$testsUpdated} file(s)."); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.