You are here

protected function ContentLanguageAccessTestBase::baseTestContentLanguageAccess in Content Language Access 8

Tests each content in each language.

2 calls to ContentLanguageAccessTestBase::baseTestContentLanguageAccess()
ContentLanguageAccessContentDetectionEnabledTest::testContentLanguageAccess in src/Tests/ContentLanguageAccessContentDetectionEnabledTest.php
Tests each content in each language.
ContentLanguageAccessTest::testContentLanguageAccess in src/Tests/ContentLanguageAccessTest.php
Tests each content in each language.

File

src/Tests/ContentLanguageAccessTestBase.php, line 177

Class

ContentLanguageAccessTestBase
Test the features of content_language_access module.

Namespace

Drupal\content_language_access\Tests

Code

protected function baseTestContentLanguageAccess() {
  $this
    ->drupalLogin($this->visitor);
  $languages = $this
    ->getLanguageList(FALSE);
  foreach ($this->nodes as $node) {
    foreach ($languages as $language) {

      // English is the default language and does not have prefix.
      if ($language
        ->getId() != Drupal::languageManager()
        ->getDefaultLanguage()
        ->getId()) {
        $prefix = $language
          ->getId() . '/';
      }
      else {
        $prefix = '';
      }
      $this
        ->drupalGet($prefix . 'node/' . $node
        ->id());
      $node_language = $node
        ->language()
        ->getId();
      if ($node_language == Language::LANGCODE_NOT_SPECIFIED || $node_language == Language::LANGCODE_NOT_APPLICABLE || $node_language == $language
        ->getId()) {
        $this
          ->assertResponse(200);
      }
      else {
        $this
          ->assertResponse(403);
      }
    }
  }
}