X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FTests%2FForm%2FCheckboxTest.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FTests%2FForm%2FCheckboxTest.php;h=0000000000000000000000000000000000000000;hp=61e7bd9ba5804cd3567a7408f1add70d09e8715d;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/system/src/Tests/Form/CheckboxTest.php b/web/core/modules/system/src/Tests/Form/CheckboxTest.php deleted file mode 100644 index 61e7bd9ba..000000000 --- a/web/core/modules/system/src/Tests/Form/CheckboxTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getForm('\Drupal\form_test\Form\FormTestCheckboxTypeJugglingForm', $default_value, $return_value); - $form = \Drupal::service('renderer')->renderRoot($form_array); - if ($default_value === TRUE) { - $checked = TRUE; - } - elseif ($return_value === '0') { - $checked = ($default_value === '0'); - } - elseif ($return_value === '') { - $checked = ($default_value === ''); - } - elseif ($return_value === 1 || $return_value === '1') { - $checked = ($default_value === 1 || $default_value === '1'); - } - elseif ($return_value === 'foobar') { - $checked = ($default_value === 'foobar'); - } - elseif ($return_value === '1foobar') { - $checked = ($default_value === '1foobar'); - } - $checked_in_html = strpos($form, 'checked') !== FALSE; - $message = format_string('#default_value is %default_value #return_value is %return_value.', ['%default_value' => var_export($default_value, TRUE), '%return_value' => var_export($return_value, TRUE)]); - $this->assertIdentical($checked, $checked_in_html, $message); - } - } - - // Ensure that $form_state->getValues() is populated correctly for a - // checkboxes group that includes a 0-indexed array of options. - $results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', [], 'Save')); - $this->assertIdentical($results->checkbox_off, [0, 0, 0], 'All three in checkbox_off are zeroes: off.'); - $this->assertIdentical($results->checkbox_zero_default, ['0', 0, 0], 'The first choice is on in checkbox_zero_default'); - $this->assertIdentical($results->checkbox_string_zero_default, ['0', 0, 0], 'The first choice is on in checkbox_string_zero_default'); - $edit = ['checkbox_off[0]' => '0']; - $results = json_decode($this->drupalPostForm('form-test/checkboxes-zero/1', $edit, 'Save')); - $this->assertIdentical($results->checkbox_off, ['0', 0, 0], 'The first choice is on in checkbox_off but the rest is not'); - - // Ensure that each checkbox is rendered correctly for a checkboxes group - // that includes a 0-indexed array of options. - $this->drupalPostForm('form-test/checkboxes-zero/0', [], 'Save'); - $checkboxes = $this->xpath('//input[@type="checkbox"]'); - - $this->assertIdentical(count($checkboxes), 9, 'Correct number of checkboxes found.'); - foreach ($checkboxes as $checkbox) { - $checked = isset($checkbox['checked']); - $name = (string) $checkbox['name']; - $this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', ['%name' => $name])); - } - $edit = ['checkbox_off[0]' => '0']; - $this->drupalPostForm('form-test/checkboxes-zero/0', $edit, 'Save'); - $checkboxes = $this->xpath('//input[@type="checkbox"]'); - - $this->assertIdentical(count($checkboxes), 9, 'Correct number of checkboxes found.'); - foreach ($checkboxes as $checkbox) { - $checked = isset($checkbox['checked']); - $name = (string) $checkbox['name']; - $this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', ['%name' => $name])); - } - } - -}