You are here

public function EntityCloneSearchPageTest::testSearchPageEntityClone in Entity Clone 8

Test search page entity clone.

File

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

Class

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
    ->drupalPostForm("/admin/config/search/pages/add/node_search", $edit, 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
    ->drupalPostForm('entity_clone/search_page/' . $search_page
    ->id(), $edit, 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.');
}