Commit bc2eb65d authored by nikunj's avatar nikunj
Browse files

Issue #3027033: Coding standard issues in tests, demo form

parent d660624b
...@@ -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) {
} }
} }
...@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment