public function ScannerAdminTest::testAdminSettingsEntityTypeFields in Search and Replace Scanner 8
Tests that the supported entity fields are present.
File
- tests/
src/ Functional/ ScannerAdminTest.php, line 74
Class
- ScannerAdminTest
- Tests the default admin settings functionality.
Namespace
Drupal\Tests\scanner\FunctionalCode
public function testAdminSettingsEntityTypeFields() {
// Confirm the settings form loads.
$this
->drupalGet('admin/config/content/scanner');
$session_assert = $this
->assertSession();
// Enable support for the "scanner_test_node_type" and
// "scanner_test_paragraph_type" entity types.
$edit = [
'enabled_content_types[node:scanner_test_node_type]' => 'node:scanner_test_node_type',
'enabled_content_types[paragraph:scanner_test_paragraph_type]' => 'paragraph:scanner_test_paragraph_type',
];
$this
->submitForm($edit, $this
->t('Save configuration'));
// Assert that the enabled entity type is now checked.
$session_assert
->checkboxChecked('enabled_content_types[node:scanner_test_node_type]');
// Assert that the node title and body fields are available.
$session_assert
->fieldExists('fields_of_selected_content_type[node:scanner_test_node_type:title]');
$session_assert
->fieldExists('fields_of_selected_content_type[node:scanner_test_node_type:body]');
// Assert that the paragraph text fields are available.
$session_assert
->fieldExists('fields_of_selected_content_type[paragraph:scanner_test_paragraph_type:field_string]');
$session_assert
->fieldExists('fields_of_selected_content_type[paragraph:scanner_test_paragraph_type:field_text]');
$session_assert
->fieldExists('fields_of_selected_content_type[paragraph:scanner_test_paragraph_type:field_text_long]');
$session_assert
->fieldExists('fields_of_selected_content_type[paragraph:scanner_test_paragraph_type:field_text_with_summary]');
// Assert that unsupported fields are not available.
$session_assert
->fieldNotExists('fields_of_selected_content_type[paragraph:scanner_test_paragraph_type:field_boolean]');
// Assert that disabled entity type fields are not available.
$session_assert
->fieldNotExists('fields_of_selected_content_type[node:scanner_test_ignored_node_type:title]');
$session_assert
->fieldNotExists('fields_of_selected_content_type[node:scanner_test_ignored_node_type:body]');
}