-
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.
Merge pull request #10643 from creative-commoners/pulls/5/replace-sim…
…pletest DEP Replace thirdparty simpletest with symfony domcrawler
- Loading branch information
Showing
20 changed files
with
89 additions
and
6,771 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -33,8 +33,6 @@ | |
/** | ||
* Tests for the dependency injector | ||
* | ||
* Note that these are SS conversions of the existing Simpletest unit tests | ||
* | ||
* @author [email protected] | ||
* @license BSD License http://silverstripe.org/bsd-license/ | ||
*/ | ||
|
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,7 +593,7 @@ public function testDisableSecurityTokenDoesntAddTokenFormField() | |
); | ||
} | ||
|
||
public function testDisableSecurityTokenAcceptsSubmissionWithoutToken() | ||
public function testDisableSecurityTokenAcceptsSubmissionWithoutToken(): void | ||
{ | ||
SecurityToken::enable(); | ||
$expectedToken = SecurityToken::inst()->getValue(); | ||
|
@@ -646,16 +646,55 @@ public function testDisableSecurityTokenAcceptsSubmissionWithoutToken() | |
count($tokenEls ?? []), | ||
'Token form field added for controller without disableSecurityToken()' | ||
); | ||
$token = (string)$tokenEls[0]; | ||
$response = $this->submitForm( | ||
'Form_Form', | ||
null, | ||
[ | ||
'Email' => '[email protected]', | ||
'SecurityID' => $token | ||
] | ||
); | ||
$this->assertEquals(200, $response->getStatusCode(), 'Submission succeeds with security token'); | ||
} | ||
|
||
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], | ||
null, | ||
"Can't find button 'undefined' to submit as part of test.", | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideFormsSet | ||
*/ | ||
public function testSubmitFormWithSpecifiedParameters( | ||
array $formData, | ||
?int $statusCode, | ||
string $testMessage | ||
): void { | ||
|
||
$this->get('FormTest_ControllerWithSecurityToken'); | ||
|
||
[ $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($testMessage); | ||
|
||
$this->submitForm($form, $button, $data, $withSecurityToken); | ||
} | ||
} | ||
|
||
public function testStrictFormMethodChecking() | ||
|
Oops, something went wrong.