Same name in other branches
  1. 8.x-1.x tests/src/Functional/EntityCloneSearchPageTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneSearchPageTest::testSearchPageEntityClone()

Test search page entity clone.

Fichier

tests/src/Functional/EntityCloneSearchPageTest.php, line 62

Classe

EntityCloneSearchPageTest
Create a search page and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

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.');
}