You are here

public function LanguageIntegrationTest::setUp in Search API Pages 8

Overrides FunctionalTestBase::setUp

File

tests/src/Functional/LanguageIntegrationTest.php, line 24

Class

LanguageIntegrationTest
Provides web tests for Search API Pages with language integration.

Namespace

Drupal\Tests\search_api_page\Functional

Code

public function setUp() {
  parent::setUp();
  $this
    ->drupalLogin($this->adminUser);
  $assert_session = $this
    ->assertSession();
  ConfigurableLanguage::create([
    'id' => 'nl',
    'label' => 'Dutch',
  ])
    ->save();
  ConfigurableLanguage::create([
    'id' => 'es',
    'label' => 'Spanish',
  ])
    ->save();
  $bird_node = $this
    ->drupalCreateNode([
    'title' => 'bird: Hawk',
    'language' => 'en',
    'type' => 'article',
    'body' => [
      [
        'value' => 'Body translated',
      ],
    ],
  ]);
  $bird_node
    ->addTranslation('nl', [
    'title' => 'bird: Havik',
  ])
    ->addTranslation('es', [
    'title' => 'bird: Halcon',
  ])
    ->save();

  // Setup search api server and index.
  $this
    ->setupSearchAPI();
  $this
    ->drupalGet('admin/config/search/search-api-pages');
  $assert_session
    ->statusCodeEquals(200);
  $step1 = [
    'label' => 'Search',
    'id' => 'search',
    'index' => $this->index
      ->id(),
  ];
  $this
    ->drupalPostForm('admin/config/search/search-api-pages/add', $step1, 'Next');
  $step2 = [
    'path' => 'search',
  ];
  $this
    ->drupalPostForm(NULL, $step2, 'Save');
}