-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Normalize new line symbols in Product Text Option (type=area) #26033
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
Merged
magento-engcom-team
merged 4 commits into
magento:2.4-develop
from
Leone:feature-issue-25974
Dec 29, 2019
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
284e3ed
[issue-25974] Fix for "Amount of characters on a 'Area' Customizable …
Leone 2ae6838
Adjusted code after MR
Leone d2a4865
Added @SuppressWarnings(PHPMD.CookieAndSessionMisuse) to Text class
Leone 6e68a47
Organized imports in test class
Leone 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
79 changes: 79 additions & 0 deletions
79
dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/TextTest.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,79 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\Product\Option\Type; | ||
|
||
use Magento\Catalog\Model\Product\Option; | ||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test for customizable product option with "Text" type | ||
*/ | ||
class TextTest extends TestCase | ||
{ | ||
const STUB_OPTION_DATA = ['id' => 11, 'type' => 'area']; | ||
|
||
/** | ||
* @var Text | ||
*/ | ||
protected $optionText; | ||
|
||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->objectManager = Bootstrap::getObjectManager(); | ||
$this->optionText = $this->objectManager->create(Text::class); | ||
} | ||
|
||
/** | ||
* Check if newline symbols are normalized in option value | ||
* | ||
* @dataProvider optionValueDataProvider | ||
* @param array $productOptionData | ||
* @param string $optionValue | ||
* @param string $expectedOptionValue | ||
*/ | ||
public function testNormalizeNewlineSymbols( | ||
array $productOptionData, | ||
string $optionValue, | ||
string $expectedOptionValue | ||
) { | ||
$productOption = $this->objectManager->create( | ||
Option::class, | ||
['data' => $productOptionData] | ||
); | ||
|
||
$this->optionText->setOption($productOption); | ||
$this->optionText->setUserValue($optionValue); | ||
$this->optionText->validateUserValue([]); | ||
|
||
$this->assertSame($expectedOptionValue, $this->optionText->getUserValue()); | ||
} | ||
|
||
/** | ||
* Data provider for testNormalizeNewlineSymbols | ||
* | ||
* @return array | ||
*/ | ||
public function optionValueDataProvider() | ||
{ | ||
return [ | ||
[self::STUB_OPTION_DATA, 'string string', 'string string'], | ||
[self::STUB_OPTION_DATA, "string \r\n string", "string \n string"], | ||
[self::STUB_OPTION_DATA, "string \n\r string", "string \n string"], | ||
[self::STUB_OPTION_DATA, "string \r string", "string \n string"] | ||
]; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can organize imports (CTRL + SHIFT + O in PHPStorm)