-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MNT Update strong typization, tests cases
- Loading branch information
Sabina Talipova
committed
Feb 2, 2023
1 parent
7c20ade
commit d23191b
Showing
3 changed files
with
61 additions
and
28 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
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 |
---|---|---|
|
@@ -593,8 +593,39 @@ public function testDisableSecurityTokenDoesntAddTokenFormField() | |
); | ||
} | ||
|
||
public function testDisableSecurityTokenAcceptsSubmissionWithoutToken() | ||
public function provideFormsSet() | ||
{ | ||
return [ | ||
'with security token' => | ||
[ | ||
['Form_Form', null,[ 'Email' => '[email protected]' ], true], | ||
200, | ||
'Submission succeeds with security token', | ||
], | ||
'without security token' => | ||
[ | ||
['Form_Form', null,[ 'Email' => '[email protected]' ], false], | ||
200, | ||
'Cannot submit form without security token', | ||
], | ||
'button with wrong name' => | ||
[ | ||
['Form_Form', 'undefined',[ 'Email' => '[email protected]' ], true], | ||
404, | ||
"Can't find button 'undefined' to submit as part of test.", | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideFormsSet | ||
*/ | ||
public function testDisableSecurityTokenAcceptsSubmissionWithoutToken( | ||
array $formData, | ||
int $statusCode, | ||
string $testMessage, | ||
?string $wrongPage = null | ||
): void { | ||
SecurityToken::enable(); | ||
$expectedToken = SecurityToken::inst()->getValue(); | ||
|
||
|
@@ -646,15 +677,19 @@ public function testDisableSecurityTokenAcceptsSubmissionWithoutToken() | |
count($tokenEls ?? []), | ||
'Token form field added for controller without disableSecurityToken()' | ||
); | ||
$response = $this->submitForm( | ||
'Form_Form', | ||
null, | ||
[ | ||
'Email' => '[email protected]', | ||
], | ||
withSecurityToken: true | ||
); | ||
$this->assertEquals(200, $response->getStatusCode(), 'Submission succeeds with security token'); | ||
|
||
[ $form, $button, $data, $withSecurityToken ] = [ ...$formData ]; | ||
|
||
if (is_null($button)) { | ||
$response = $this->submitForm($form, $button, $data, $withSecurityToken); | ||
$this->assertEquals($statusCode, $response->getStatusCode(), $testMessage); | ||
} else { | ||
// Test nonexistent button Exceptions | ||
$this->expectException(\Exception::class); | ||
$this->expectExceptionMessage("Can't find button 'undefined' to submit as part of test."); | ||
|
||
$response = $this->submitForm($form, $button, $data, $withSecurityToken); | ||
} | ||
} | ||
|
||
public function testStrictFormMethodChecking() | ||
|