Unverified Commit 3ea981a1 authored by alexpott's avatar alexpott
Browse files

Issue #3128814 by longwave, jungle, dww: Replace assert* involving count() and...

Issue #3128814 by longwave, jungle, dww: Replace assert* involving count() and an equality operator with assertCount()
parent b2a10193
......@@ -141,7 +141,7 @@ public function testExistingFormat() {
// Ensure the styles textarea exists and is initialized empty.
$styles_textarea = $this->xpath('//textarea[@name="editor[settings][plugins][stylescombo][styles]"]');
$this->assertFieldByXPath('//textarea[@name="editor[settings][plugins][stylescombo][styles]"]', '', 'The styles textarea exists and is empty.');
$this->assertTrue(count($styles_textarea) === 1, 'The "styles" textarea exists.');
$this->assertCount(1, $styles_textarea, 'The "styles" textarea exists.');
// Submit the form to save the selection of CKEditor as the chosen editor.
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
......@@ -203,7 +203,7 @@ public function testExistingFormat() {
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and not(@checked)]');
$this->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is not checked.');
$this->assertCount(1, $ultra_llama_mode_checkbox, 'The "Ultra llama mode" checkbox exists and is not checked.');
$editor = Editor::load('filtered_html');
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
......@@ -216,7 +216,7 @@ public function testExistingFormat() {
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]');
$this->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is checked.');
$this->assertCount(1, $ultra_llama_mode_checkbox, 'The "Ultra llama mode" checkbox exists and is checked.');
$expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = TRUE;
$editor = Editor::load('filtered_html');
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
......@@ -285,7 +285,7 @@ public function testNewFormat() {
// Ensure the styles textarea exists and is initialized empty.
$styles_textarea = $this->xpath('//textarea[@name="editor[settings][plugins][stylescombo][styles]"]');
$this->assertFieldByXPath('//textarea[@name="editor[settings][plugins][stylescombo][styles]"]', '', 'The styles textarea exists and is empty.');
$this->assertTrue(count($styles_textarea) === 1, 'The "styles" textarea exists.');
$this->assertCount(1, $styles_textarea, 'The "styles" textarea exists.');
// Submit the form to create both a new text format and an associated text
// editor.
......
......@@ -88,10 +88,10 @@ public function testLoading() {
list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
$this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
$this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertCount(0, $format_selector, 'No text format selector exists on the page.');
$hidden_input = $this->xpath('//input[@type="hidden" and contains(@class, "editor")]');
$this->assertTrue(count($hidden_input) === 0, 'A single text format hidden input does not exist on the page.');
$this->assertCount(0, $hidden_input, 'A single text format hidden input does not exist on the page.');
$this->assertNoRaw(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js', 'CKEditor glue JS is absent.');
// On pages where there would never be a text editor, CKEditor JS is absent.
......@@ -120,10 +120,10 @@ public function testLoading() {
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertCount(1, $format_selector, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has a "data-editor-for" attribute with the correct value.');
$this->assertCount(1, $specific_format_selector, 'A single text format selector exists on the page and has a "data-editor-for" attribute with the correct value.');
$this->assertTrue(in_array('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries'])), 'CKEditor glue library is present.');
// Enable the ckeditor_test module, customize configuration. In this case,
......
......@@ -63,7 +63,7 @@ public function testImport() {
// Ensure submit button for \Drupal\config\Form\ConfigImportForm is
// disabled.
$submit_is_disabled = $this->cssSelect('form.config-import-form input[type="submit"]:disabled');
$this->assertTrue(count($submit_is_disabled) === 1, 'The submit button is disabled.');
$this->assertCount(1, $submit_is_disabled, 'The submit button is disabled.');
}
}
......@@ -371,7 +371,8 @@ protected function doTestTranslationDeletion() {
$entity = $storage->load($this->entityId, TRUE);
if ($this->assertTrue(is_object($entity), 'Entity found')) {
$translations = $entity->getTranslationLanguages();
$this->assertTrue(count($translations) == 2 && empty($translations[$langcode]), 'Translation successfully deleted.');
$this->assertCount(2, $translations, 'Translation successfully deleted.');
$this->assertEmpty($translations[$langcode], 'Translation successfully deleted.');
}
// Check that the translator cannot delete the original translation.
......
......@@ -68,9 +68,9 @@ public function testNoEditorAvailable() {
$select = $this->xpath('//select[@name="editor[editor]"]');
$select_is_disabled = $this->xpath('//select[@name="editor[editor]" and @disabled="disabled"]');
$options = $this->xpath('//select[@name="editor[editor]"]/option');
$this->assertTrue(count($select) === 1, 'The Text Editor select exists.');
$this->assertTrue(count($select_is_disabled) === 1, 'The Text Editor select is disabled.');
$this->assertTrue(count($options) === 1, 'The Text Editor select has only one option.');
$this->assertCount(1, $select, 'The Text Editor select exists.');
$this->assertCount(1, $select_is_disabled, 'The Text Editor select is disabled.');
$this->assertCount(1, $options, 'The Text Editor select has only one option.');
$this->assertTrue(($options[0]->getText()) === 'None', 'Option 1 in the Text Editor select is "None".');
$this->assertRaw('This option is disabled because no modules that provide a text editor are currently enabled.', 'Description for select present that tells users to install a text editor module.');
}
......@@ -94,7 +94,7 @@ public function testAddEditorToExistingFormat() {
];
$this->drupalPostForm(NULL, $edit, 'Configure');
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertTrue(count($unicorn_setting) === 0, "Unicorn Editor's settings form is no longer present.");
$this->assertCount(0, $unicorn_setting, "Unicorn Editor's settings form is no longer present.");
}
/**
......@@ -196,9 +196,9 @@ protected function selectUnicornEditor() {
$select = $this->xpath('//select[@name="editor[editor]"]');
$select_is_disabled = $this->xpath('//select[@name="editor[editor]" and @disabled="disabled"]');
$options = $this->xpath('//select[@name="editor[editor]"]/option');
$this->assertTrue(count($select) === 1, 'The Text Editor select exists.');
$this->assertTrue(count($select_is_disabled) === 0, 'The Text Editor select is not disabled.');
$this->assertTrue(count($options) === 2, 'The Text Editor select has two options.');
$this->assertCount(1, $select, 'The Text Editor select exists.');
$this->assertCount(0, $select_is_disabled, 'The Text Editor select is not disabled.');
$this->assertCount(2, $options, 'The Text Editor select has two options.');
$this->assertTrue(($options[0]->getText()) === 'None', 'Option 1 in the Text Editor select is "None".');
$this->assertTrue(($options[1]->getText()) === 'Unicorn Editor', 'Option 2 in the Text Editor select is "Unicorn Editor".');
$this->assertTrue($options[0]->hasAttribute('selected'), 'Option 1 ("None") is selected.');
......@@ -233,9 +233,9 @@ protected function verifyUnicornEditorConfiguration($format_id, $ponies_too = TR
$select = $this->xpath('//select[@name="editor[editor]"]');
$select_is_disabled = $this->xpath('//select[@name="editor[editor]" and @disabled="disabled"]');
$options = $this->xpath('//select[@name="editor[editor]"]/option');
$this->assertTrue(count($select) === 1, 'The Text Editor select exists.');
$this->assertTrue(count($select_is_disabled) === 0, 'The Text Editor select is not disabled.');
$this->assertTrue(count($options) === 2, 'The Text Editor select has two options.');
$this->assertCount(1, $select, 'The Text Editor select exists.');
$this->assertCount(0, $select_is_disabled, 'The Text Editor select is not disabled.');
$this->assertCount(2, $options, 'The Text Editor select has two options.');
$this->assertTrue($options[1]->hasAttribute('selected'), 'Option 2 ("Unicorn Editor") is selected.');
}
......
......@@ -136,8 +136,8 @@ public function testLoading() {
list(, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck('body');
$this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
$this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page because the user only has access to a single format.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertCount(0, $format_selector, 'No text format selector exists on the page because the user only has access to a single format.');
$this->drupalLogout($this->normalUser);
// The privileged user:
......@@ -160,10 +160,10 @@ public function testLoading() {
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $settings['editor'], "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertCount(1, $format_selector, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has a "data-editor-for" attribute with the correct value.');
$this->assertCount(1, $specific_format_selector, 'A single text format selector exists on the page and has a "data-editor-for" attribute with the correct value.');
// Load the editor image dialog form and make sure it does not fatal.
$this->drupalGet('editor/dialog/image/full_html');
......@@ -198,10 +198,10 @@ public function testLoading() {
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $settings['editor'], "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertCount(0, $format_selector, 'No text format selector exists on the page.');
$hidden_input = $this->xpath('//input[@type="hidden" and @value="plain_text" and @data-editor-for="edit-body-0-value"]');
$this->assertTrue(count($hidden_input) === 1, 'A single text format hidden input exists on the page and has a "data-editor-for" attribute with the correct value.');
$this->assertCount(1, $hidden_input, 'A single text format hidden input exists on the page and has a "data-editor-for" attribute with the correct value.');
// Create an "article" node that uses the full_html text format, then try
// to let the untrusted user edit it.
......@@ -219,11 +219,11 @@ public function testLoading() {
list(, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck('body');
$this->assertTrue($editor_settings_present, 'Text Editor module settings.');
$this->assertTrue($editor_js_present, 'Text Editor JavaScript.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertCount(1, $body, 'A body field exists.');
$this->assertFieldByXPath('//textarea[@id="edit-body-0-value" and @disabled="disabled"]', t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
$this->assertCount(0, $format_selector, 'No text format selector exists on the page.');
$hidden_input = $this->xpath('//input[@type="hidden" and contains(@class, "editor")]');
$this->assertTrue(count($hidden_input) === 0, 'A single text format hidden input does not exist on the page.');
$this->assertCount(0, $hidden_input, 'A single text format hidden input does not exist on the page.');
}
/**
......@@ -258,10 +258,10 @@ public function testSupportedElementTypes() {
list(, $editor_settings_present, $editor_js_present, $field, $format_selector) = $this->getThingsToCheck('field-text', 'input');
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(count($field) === 1, 'A text field exists.');
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$this->assertCount(1, $field, 'A text field exists.');
$this->assertCount(1, $format_selector, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-field-text-0-value"]');
$this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
$this->assertCount(1, $specific_format_selector, 'A single text format selector exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
// Associate the trex text editor with the "Full HTML" text format.
$editor->delete();
......@@ -274,10 +274,10 @@ public function testSupportedElementTypes() {
list(, $editor_settings_present, $editor_js_present, $field, $format_selector) = $this->getThingsToCheck('field-text', 'input');
$this->assertFalse($editor_settings_present, "Text Editor module's JavaScript settings are not on the page.");
$this->assertFalse($editor_js_present, 'Text Editor JavaScript is not present.');
$this->assertTrue(count($field) === 1, 'A text field exists.');
$this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
$this->assertCount(1, $field, 'A text field exists.');
$this->assertCount(1, $format_selector, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and contains(@class, "editor") and @data-editor-for="edit-field-text-0-value"]');
$this->assertFalse(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has the "editor" class and a "data-editor-for" attribute with the correct value.');
$this->assertCount(0, $specific_format_selector, 'No text format selector exists on the page with the "editor" class and a "data-editor-for" attribute with the expected value.');
}
protected function getThingsToCheck($field_name, $type = 'textarea') {
......
......@@ -215,11 +215,13 @@ public function testRead() {
// Check that 'single column' criteria works.
$field_storage_config_storage = \Drupal::entityTypeManager()->getStorage('field_storage_config');
$fields = $field_storage_config_storage->loadByProperties(['field_name' => $field_storage_definition['field_name']]);
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
$this->assertCount(1, $fields, 'The field was properly read.');
$this->assertArrayHasKey($id, $fields, 'The field has the correct key.');
// Check that 'multi column' criteria works.
$fields = $field_storage_config_storage->loadByProperties(['field_name' => $field_storage_definition['field_name'], 'type' => $field_storage_definition['type']]);
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
$this->assertCount(1, $fields, 'The field was properly read.');
$this->assertArrayHasKey($id, $fields, 'The field has the correct key.');
$fields = $field_storage_config_storage->loadByProperties(['field_name' => $field_storage_definition['field_name'], 'type' => 'foo']);
$this->assertTrue(empty($fields), 'No field was found.');
......
......@@ -74,7 +74,7 @@ public function testFieldUIRoutes() {
$this->drupalGet('admin/config/people/accounts/form-display/register');
$this->assertTitle('Manage form display | Drupal');
$this->assertLocalTasks();
$this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', [':text' => 'Default'])) == 1, 'Default secondary tab is in first position.');
$this->assertCount(1, $this->xpath('//ul/li[1]/a[contains(text(), :text)]', [':text' => 'Default']), 'Default secondary tab is in first position.');
// Create new view mode and verify it's available on the Manage Display
// screen after enabling it.
......
......@@ -166,7 +166,7 @@ public function testMultiValuedWidget() {
// Ensure we have the expected number of Remove buttons, and that they
// are numbered sequentially.
$buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
$this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons]));
$this->assertCount($num_expected_remove_buttons, $buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons]));
foreach ($buttons as $i => $button) {
$key = $i >= $remaining ? $i - $remaining : $i;
$check_field_name = $field_name2;
......@@ -187,12 +187,12 @@ public function testMultiValuedWidget() {
// correct name.
$upload_button_name = $current_field_name . '_' . $remaining . '_upload_button';
$buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', [':name' => $upload_button_name]);
$this->assertTrue(is_array($buttons) && count($buttons) == 1, 'The upload button is displayed with the correct name.');
$this->assertCount(1, $buttons, 'The upload button is displayed with the correct name.');
// Ensure only at most one button per field is displayed.
$buttons = $this->xpath('//input[@type="submit" and @value="Upload"]');
$expected = $current_field_name == $field_name ? 1 : 2;
$this->assertTrue(is_array($buttons) && count($buttons) == $expected, 'After removing a file, only one "Upload" button for each possible field is displayed.');
$this->assertCount($expected, $buttons, 'After removing a file, only one "Upload" button for each possible field is displayed.');
}
}
......
......@@ -89,7 +89,7 @@ public function testMultiValuedWidget() {
// Ensure we have the expected number of Remove buttons, and that they
// are numbered sequentially.
$buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
$this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons]));
$this->assertCount($num_expected_remove_buttons, $buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons]));
foreach ($buttons as $i => $button) {
$key = $i >= $remaining ? $i - $remaining : $i;
$check_field_name = $field_name2;
......@@ -112,12 +112,12 @@ public function testMultiValuedWidget() {
$upload_button_name = $current_field_name . '_' . $remaining . '_upload_button';
$this->assertNotNull($assert_session->waitForButton($upload_button_name));
$buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', [':name' => $upload_button_name]);
$this->assertTrue(is_array($buttons) && count($buttons) == 1, 'The upload button is displayed with the correct name.');
$this->assertCount(1, $buttons, 'The upload button is displayed with the correct name.');
// Ensure only at most one button per field is displayed.
$buttons = $this->xpath('//input[@type="submit" and @value="Upload"]');
$expected = $current_field_name == $field_name ? 1 : 2;
$this->assertTrue(is_array($buttons) && count($buttons) == $expected, 'After removing a file, only one "Upload" button for each possible field is displayed.');
$this->assertCount($expected, $buttons, 'After removing a file, only one "Upload" button for each possible field is displayed.');
}
}
}
......
......@@ -158,7 +158,9 @@ public function testConfigTranslation() {
// Check the right single translation has been created.
$translations = $this->storage->getTranslations(['language' => $this->langcode, 'type' => 'configuration', 'name' => 'image.style.medium']);
$translation = reset($translations);
$this->assertTrue(count($translations) == 1 && $translation->source == $string->source && $translation->translation == $image_style_label, 'Got only one translation for image configuration.');
$this->assertCount(1, $translations, 'Got only one translation for image configuration.');
$this->assertEquals($string->source, $translation->source);
$this->assertEquals($image_style_label, $translation->translation);
// Try more complex configuration data.
$translation = \Drupal::languageManager()->getLanguageConfigOverride($this->langcode, 'image.style.medium')->get();
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\node\Entity\Node;
/**
......@@ -50,13 +49,11 @@ public function testNodeMultipleLoad() {
->loadByProperties(['promote' => 0]);
$this->assertEqual($node3->label(), $nodes[$node3->id()]->label(), 'Node was loaded.');
$this->assertEqual($node4->label(), $nodes[$node4->id()]->label(), 'Node was loaded.');
$count = count($nodes);
$this->assertTrue($count == 2, new FormattableMarkup('@count nodes loaded.', ['@count' => $count]));
$this->assertCount(2, $nodes);
// Load nodes by nid. Nodes 1, 2 and 4 will be loaded.
$nodes = Node::loadMultiple([1, 2, 4]);
$count = count($nodes);
$this->assertTrue(count($nodes) == 3, new FormattableMarkup('@count nodes loaded', ['@count' => $count]));
$this->assertCount(3, $nodes);
$this->assertTrue(isset($nodes[$node1->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node2->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node4->id()]), 'Node is correctly keyed in the array');
......
......@@ -41,11 +41,11 @@ public function testFieldOverrides() {
$type->save();
node_add_body_field($type);
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$this->assertTrue(count($field_storage->getBundles()) == 1, 'Node body field storage is being used on the new node type.');
$this->assertCount(1, $field_storage->getBundles(), 'Node body field storage is being used on the new node type.');
$field = FieldConfig::loadByName('node', 'ponies', 'body');
$field->delete();
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$this->assertTrue(count($field_storage->getBundles()) == 0, 'Node body field storage exists after deleting the only instance of a field.');
$this->assertCount(0, $field_storage->getBundles(), 'Node body field storage exists after deleting the only instance of a field.');
\Drupal::service('module_installer')->uninstall(['node']);
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$this->assertNull($field_storage, 'Node body field storage does not exist after uninstalling the Node module.');
......
......@@ -62,7 +62,7 @@ public function testMultilingualFormCRUD() {
public function testEntityFormDisplayAlter() {
$this->drupalGet('entity_test/add');
$altered_field = $this->xpath('//input[@name="field_test_text[0][value]" and @size="42"]');
$this->assertTrue(count($altered_field) === 1, 'The altered field has the correct size value.');
$this->assertCount(1, $altered_field, 'The altered field has the correct size value.');
}
/**
......
......@@ -144,8 +144,8 @@ public function testWrapperIds() {
foreach (['checkboxes', 'radios'] as $type) {
$element_ids = $this->xpath('//div[@id=:id]', [':id' => 'edit-' . $type]);
$wrapper_ids = $this->xpath('//fieldset[@id=:id]', [':id' => 'edit-' . $type . '--wrapper']);
$this->assertTrue(count($element_ids) == 1, new FormattableMarkup('A single element id found for type %type', ['%type' => $type]));
$this->assertTrue(count($wrapper_ids) == 1, new FormattableMarkup('A single wrapper id found for type %type', ['%type' => $type]));
$this->assertCount(1, $element_ids, new FormattableMarkup('A single element id found for type %type', ['%type' => $type]));
$this->assertCount(1, $wrapper_ids, new FormattableMarkup('A single wrapper id found for type %type', ['%type' => $type]));
}
}
......@@ -169,18 +169,18 @@ public function testButtonClasses() {
public function testGroupElements() {
$this->drupalGet('form-test/group-details');
$elements = $this->xpath('//div[@class="details-wrapper"]//div[@class="details-wrapper"]//label');
$this->assertTrue(count($elements) == 1);
$this->assertCount(1, $elements);
$this->drupalGet('form-test/group-container');
$elements = $this->xpath('//div[@id="edit-container"]//div[@class="details-wrapper"]//label');
$this->assertTrue(count($elements) == 1);
$this->assertCount(1, $elements);
$this->drupalGet('form-test/group-fieldset');
$elements = $this->xpath('//fieldset[@id="edit-fieldset"]//div[@id="edit-meta"]//label');
$this->assertTrue(count($elements) == 1);
$this->assertCount(1, $elements);
$this->drupalGet('form-test/group-vertical-tabs');
$elements = $this->xpath('//div[@data-vertical-tabs-panes]//details[@id="edit-meta"]//label');
$this->assertTrue(count($elements) == 1);
$this->assertCount(1, $elements);
$elements = $this->xpath('//div[@data-vertical-tabs-panes]//details[@id="edit-meta-2"]//label');
$this->assertTrue(count($elements) == 1);
$this->assertCount(1, $elements);
}
/**
......
......@@ -89,7 +89,7 @@ public function testBreadcrumbsFrontPageCache() {
$this->drupalGet($this->nodeWithAlias->path->alias);
$breadcrumbs = $this->assertSession()->elementExists('css', '.block-system-breadcrumb-block');
$crumbs = $breadcrumbs->findAll('css', 'ol li');
$this->assertTrue(count($crumbs) === 1);
$this->assertCount(1, $crumbs);
$this->assertTrue($crumbs[0]->getText() === 'Home');
}
......
......@@ -296,7 +296,7 @@ public function testBreadCrumbs() {
':menu' => 'block-bartik-tools',
':href' => Url::fromUri('base:' . $link_path)->toString(),
]);
$this->assertTrue(count($elements) == 1, "Link to {$link_path} appears only once.");
$this->assertCount(1, $elements, "Link to {$link_path} appears only once.");
// Next iteration should expect this tag as parent link.
// Note: Term name, not link name, due to taxonomy_term_page().
......
......@@ -65,7 +65,7 @@ public function testMissingModules() {
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]), 'A module with missing dependencies is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
}
/**
......@@ -80,7 +80,7 @@ public function testIncompatibleModuleVersionDependency() {
'@version' => '1.0',
]), 'A module that depends on an incompatible version of a module is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_module_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
}
/**
......@@ -94,7 +94,7 @@ public function testIncompatibleCoreVersionDependency() {
'@module' => 'System core incompatible semver test',
]), 'A module that depends on a module with an incompatible core version is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_core_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
}
/**
......@@ -104,7 +104,7 @@ public function testIncompatiblePhpVersionDependency() {
$this->drupalGet('admin/modules');
$this->assertRaw('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.', 'User is informed when the PHP dependency requirement of a module is not met.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_php_version_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
}
/**
......@@ -202,7 +202,7 @@ public function testUninstallDependents() {
// Check that the comment module cannot be uninstalled.
$this->drupalGet('admin/modules/uninstall');
$checkbox = $this->xpath('//input[@type="checkbox" and @name="uninstall[comment]" and @disabled="disabled"]');
$this->assert(count($checkbox) == 1, 'Checkbox for uninstalling the comment module is disabled.');
$this->assertCount(1, $checkbox, 'Checkbox for uninstalling the comment module is disabled.');
// Delete any forum terms.
$vid = $this->config('forum.settings')->get('vocabulary');
......
......@@ -30,7 +30,7 @@ public function testThemeHtmlAttributes() {
$this->drupalGet('');
$this->assertSession()->responseContains('<html lang="en" dir="ltr" theme_test_html_attribute="theme test html attribute value">');
$attributes = $this->xpath('/body[@theme_test_body_attribute="theme test body attribute value"]');
$this->assertTrue(count($attributes) == 1, "Attribute set in the 'body' element via hook_preprocess_HOOK() found.");
$this->assertCount(1, $attributes, "Attribute set in the 'body' element via hook_preprocess_HOOK() found.");
}
}
......@@ -150,7 +150,7 @@ public function testTemplateOverride() {
public function testPreprocessHtml() {
$this->drupalGet('');
$attributes = $this->xpath('/body[@theme_test_page_variable="Page variable is an array."]');
$this->assertTrue(count($attributes) == 1, 'In template_preprocess_html(), the page variable is still an array (not rendered yet).');
$this->assertCount(1, $attributes, 'In template_preprocess_html(), the page variable is still an array (not rendered yet).');
$this->assertText('theme test page bottom markup', 'Modules are able to set the page bottom region.');
}
......
Supports Markdown
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