ScannerAdminTest.php in Search and Replace Scanner 8
File
tests/src/Functional/ScannerAdminTest.php
View source
<?php
namespace Drupal\Tests\scanner\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class ScannerAdminTest extends ScannerTestBase {
use StringTranslationTrait;
protected function setUp() {
parent::setUp();
$this
->createContentTypeNode('Title test', 'Body test', 'scanner_test_node_type', 'Scanner test node type');
$this
->createContentTypeNode('Ignored title', 'Ignored body', 'scanner_test_ignored_node_type', 'Scanner test ignored node type');
$paragraphs_type_id = 'scanner_test_paragraph_type';
$this
->addParagraphsType($paragraphs_type_id);
$this
->addFieldtoParagraphType($paragraphs_type_id, 'field_string', 'string');
$this
->addFieldtoParagraphType($paragraphs_type_id, 'field_text', 'text');
$this
->addFieldtoParagraphType($paragraphs_type_id, 'field_text_long', 'text_long');
$this
->addFieldtoParagraphType($paragraphs_type_id, 'field_text_with_summary', 'text_with_summary');
$this
->addFieldtoParagraphType($paragraphs_type_id, 'field_boolean', 'boolean');
$this
->addParagraphsField('scanner_test_node_type', 'scanner_paragraphs_field', 'node');
$user = $this
->createUser([
'administer scanner settings',
]);
$this
->drupalLogin($user);
}
public function testAdminSettingsForm() {
$this
->drupalGet('admin/config/content/scanner');
$session_assert = $this
->assertSession();
$session_assert
->statusCodeEquals(200);
$session_assert
->fieldExists('scanner_mode');
$session_assert
->fieldExists('scanner_wholeword');
$session_assert
->fieldExists('scanner_regex');
$session_assert
->fieldExists('scanner_published');
$session_assert
->fieldExists('scanner_pathauto');
$session_assert
->fieldExists('scanner_language');
$session_assert
->checkboxNotChecked('enabled_content_types[node:scanner_test_node_type]');
$session_assert
->checkboxNotChecked('enabled_content_types[node:scanner_test_ignored_node_type]');
}
public function testAdminSettingsEntityTypeFields() {
$this
->drupalGet('admin/config/content/scanner');
$session_assert = $this
->assertSession();
$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'));
$session_assert
->checkboxChecked('enabled_content_types[node:scanner_test_node_type]');
$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]');
$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]');
$session_assert
->fieldNotExists('fields_of_selected_content_type[paragraph:scanner_test_paragraph_type:field_boolean]');
$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]');
}
}