forked from shopware5/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request shopware5#2549 from shopware5/fix/sw-27151/seperat…
…e-emails-before-validation fix(SW-27151): split emails before validation
- Loading branch information
Showing
2 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -26,8 +26,10 @@ | |
|
||
use Enlight_Components_Test_Controller_TestCase; | ||
use Enlight_Controller_Request_RequestTestCase; | ||
use Enlight_Controller_Response_ResponseTestCase; | ||
use Enlight_Template_Manager; | ||
use Enlight_View_Default; | ||
use Generator; | ||
use Shopware\Tests\Functional\Traits\ContainerTrait; | ||
use Shopware\Tests\Functional\Traits\DatabaseTransactionBehaviour; | ||
use Shopware_Controllers_Backend_Base; | ||
|
@@ -214,6 +216,42 @@ public function provideSearchString(): array | |
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideEmails | ||
*/ | ||
public function testValidateEmailAction(string $emails, bool $expectedIsValid): void | ||
{ | ||
$request = new Enlight_Controller_Request_RequestTestCase(); | ||
$response = new Enlight_Controller_Response_ResponseTestCase(); | ||
$request->setParam('value', $emails); | ||
|
||
$controller = $this->createController(); | ||
$controller->setRequest($request); | ||
$controller->setResponse($response); | ||
$controller->validateEmailAction(); | ||
|
||
static::assertSame($expectedIsValid, (bool) $response->getContent()); | ||
} | ||
|
||
/** | ||
* @return Generator<string, array{emails: string, expectedIsValid: bool}> | ||
*/ | ||
public function provideEmails(): Generator | ||
{ | ||
yield '1 mail shall be valid' => [ | ||
'emails' => '[email protected]', | ||
'expectedIsValid' => true, | ||
]; | ||
yield '3 mails shall be valid' => [ | ||
'emails' => '[email protected],[email protected],[email protected]', | ||
'expectedIsValid' => true, | ||
]; | ||
yield '3 mail shall be invalid' => [ | ||
'emails' => '[email protected],[email protected],[email protected]||test', | ||
'expectedIsValid' => false, | ||
]; | ||
} | ||
|
||
private function createController(): Shopware_Controllers_Backend_Base | ||
{ | ||
$controller = $this->getContainer()->get('shopware_controllers_backend_base'); | ||
|