Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
clientside_validation
Commits
bc2eb65d
Commit
bc2eb65d
authored
Jan 19, 2019
by
nikunj
Browse files
Issue #3027033: Coding standard issues in tests, demo form
parent
d660624b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
clientside_validation_demo/src/Form/ClientsideValidationDemoForm.php
...validation_demo/src/Form/ClientsideValidationDemoForm.php
+2
-4
tests/src/FunctionalJavascript/ClientsideValidationTest.php
tests/src/FunctionalJavascript/ClientsideValidationTest.php
+7
-5
No files found.
clientside_validation_demo/src/Form/ClientsideValidationDemoForm.php
View file @
bc2eb65d
...
@@ -4,7 +4,6 @@ namespace Drupal\clientside_validation_demo\Form;
...
@@ -4,7 +4,6 @@ namespace Drupal\clientside_validation_demo\Form;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\link\LinkItemInterface
;
/**
/**
* Class ClientsideValidationDemoForm.
* Class ClientsideValidationDemoForm.
...
@@ -108,7 +107,7 @@ class ClientsideValidationDemoForm extends FormBase {
...
@@ -108,7 +107,7 @@ class ClientsideValidationDemoForm extends FormBase {
'#required'
=>
FALSE
,
'#required'
=>
FALSE
,
];
];
$form
[
'phone_1'
]
=
array
(
$form
[
'phone_1'
]
=
[
'#type'
=>
'textfield'
,
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Phone Number'
),
'#title'
=>
t
(
'Phone Number'
),
'#size'
=>
60
,
'#size'
=>
60
,
...
@@ -116,7 +115,7 @@ class ClientsideValidationDemoForm extends FormBase {
...
@@ -116,7 +115,7 @@ class ClientsideValidationDemoForm extends FormBase {
'#pattern'
=>
"[789][0-9]
{
9
}
"
,
'#pattern'
=>
"[789][0-9]
{
9
}
"
,
'#required'
=>
TRUE
,
'#required'
=>
TRUE
,
'#placeholder'
=>
t
(
'Enter Phone Number - [789][0-9]{9}'
),
'#placeholder'
=>
t
(
'Enter Phone Number - [789][0-9]{9}'
),
)
;
]
;
$form
[
'submit'
]
=
[
$form
[
'submit'
]
=
[
'#type'
=>
'submit'
,
'#type'
=>
'submit'
,
...
@@ -139,7 +138,6 @@ class ClientsideValidationDemoForm extends FormBase {
...
@@ -139,7 +138,6 @@ class ClientsideValidationDemoForm extends FormBase {
*/
*/
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
}
}
}
}
tests/src/FunctionalJavascript/ClientsideValidationTest.php
View file @
bc2eb65d
...
@@ -21,6 +21,8 @@ class ClientsideValidationTest extends JavascriptTestBase {
...
@@ -21,6 +21,8 @@ class ClientsideValidationTest extends JavascriptTestBase {
protected
$adminUser
;
protected
$adminUser
;
/**
/**
* DocumentElement object.
*
* @var \Behat\Mink\Element\DocumentElement
* @var \Behat\Mink\Element\DocumentElement
*/
*/
protected
$page
;
protected
$page
;
...
@@ -68,7 +70,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
...
@@ -68,7 +70,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
// Default required field error from email_1.
// Default required field error from email_1.
$assertions
[
'edit-email-1'
]
=
'E-Mail 1 is required.'
;
$assertions
[
'edit-email-1'
]
=
'E-Mail 1 is required.'
;
$this
->
_
validateAssertions
(
$assertions
);
$this
->
validateAssertions
(
$assertions
);
// URL field.
// URL field.
$assertions
=
[];
$assertions
=
[];
...
@@ -77,7 +79,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
...
@@ -77,7 +79,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
$this
->
page
->
findById
(
'edit-url'
)
->
setValue
(
'invalid url'
);
$this
->
page
->
findById
(
'edit-url'
)
->
setValue
(
'invalid url'
);
$assertions
[
'edit-url'
]
=
'URL does not contain a valid url.'
;
$assertions
[
'edit-url'
]
=
'URL does not contain a valid url.'
;
$this
->
_
validateAssertions
(
$assertions
);
$this
->
validateAssertions
(
$assertions
);
// E-Mail field.
// E-Mail field.
$assertions
=
[];
$assertions
=
[];
...
@@ -90,7 +92,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
...
@@ -90,7 +92,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
$this
->
page
->
findById
(
'edit-email-2'
)
->
setValue
(
'asdf'
);
$this
->
page
->
findById
(
'edit-email-2'
)
->
setValue
(
'asdf'
);
$assertions
[
'edit-email-2'
]
=
'E-Mail 2 does not contain a valid email.'
;
$assertions
[
'edit-email-2'
]
=
'E-Mail 2 does not contain a valid email.'
;
$this
->
_
validateAssertions
(
$assertions
);
$this
->
validateAssertions
(
$assertions
);
// Numeric field.
// Numeric field.
$assertions
=
[];
$assertions
=
[];
...
@@ -111,7 +113,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
...
@@ -111,7 +113,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
$this
->
page
->
findById
(
'edit-phone-1'
)
->
setValue
(
'abc'
);
$this
->
page
->
findById
(
'edit-phone-1'
)
->
setValue
(
'abc'
);
$assertions
[
'edit-phone-1'
]
=
'Phone Number does not meet the requirements.'
;
$assertions
[
'edit-phone-1'
]
=
'Phone Number does not meet the requirements.'
;
$this
->
_
validateAssertions
(
$assertions
);
$this
->
validateAssertions
(
$assertions
);
// Set all valid values.
// Set all valid values.
$this
->
page
->
findById
(
'edit-text-1'
)
->
setValue
(
'text 1'
);
$this
->
page
->
findById
(
'edit-text-1'
)
->
setValue
(
'text 1'
);
...
@@ -143,7 +145,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
...
@@ -143,7 +145,7 @@ class ClientsideValidationTest extends JavascriptTestBase {
* @throws \Exception
* @throws \Exception
* Exception if element not found.
* Exception if element not found.
*/
*/
private
function
_
validateAssertions
(
array
$assertions
)
{
private
function
validateAssertions
(
array
$assertions
)
{
// Trigger click of submit button.
// Trigger click of submit button.
$this
->
page
->
findButton
(
'Submit'
)
->
click
();
$this
->
page
->
findButton
(
'Submit'
)
->
click
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment