Same name in other branches
- 2.x tests/src/Functional/EntityCloneSearchPageTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneSearchPageTest
Create a search page and test a clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneSearchPageTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneSearchPageTest
Fichier
-
tests/
src/ Functional/ EntityCloneSearchPageTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneSearchPageTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'search',
'node',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'administer search',
'clone search_page entity',
];
/**
* An administrative user with permission to configure search pages settings.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* Sets the test up.
*/
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser($this->permissions);
$this->drupalLogin($this->adminUser);
}
/**
* Test search page entity clone.
*/
public function testSearchPageEntityClone() {
$edit = [
'label' => 'Test search page for clone',
'id' => 'test_search_page_for_clone',
'path' => 'test_search_page_for_clone_url',
];
$this->drupalGet("/admin/config/search/pages/add/node_search");
$this->submitForm($edit, $this->t('Save'));
$search_pages = \Drupal::entityTypeManager()->getStorage('search_page')
->loadByProperties([
'id' => $edit['id'],
]);
$search_page = reset($search_pages);
$edit = [
'id' => 'test_search_page_cloned',
'label' => 'Test search page cloned',
];
$this->drupalGet('entity_clone/search_page/' . $search_page->id());
$this->submitForm($edit, $this->t('Clone'));
$search_pages = \Drupal::entityTypeManager()->getStorage('search_page')
->loadByProperties([
'id' => $edit['id'],
]);
$search_page = reset($search_pages);
$this->assertInstanceOf(SearchPage::class, $search_page, 'Test search page cloned found in database.');
}
}
Members
Titre Trier par ordre décroissant | Modifiers | Object type | Résumé |
---|---|---|---|
EntityCloneSearchPageTest::$adminUser | protected | property | An administrative user with permission to configure search pages settings. |
EntityCloneSearchPageTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneSearchPageTest::$modules | protected static | property | Modules to enable. |
EntityCloneSearchPageTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneSearchPageTest::setUp | protected | function | Sets the test up. |
EntityCloneSearchPageTest::testSearchPageEntityClone | public | function | Test search page entity clone. |