You are here

public function LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 8 tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  2. 4.0.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  3. 3.0.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  4. 3.1.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  5. 3.2.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  6. 3.3.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  7. 3.4.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  8. 3.5.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  9. 3.6.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  10. 3.7.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()
  11. 3.8.x tests/src/Unit/Controller/LingotekDashboardControllerTest.php \Drupal\Tests\lingotek\Unit\Controller\LingotekDashboardControllerTest::testNoTypesEnabledForLingotekTranslation()

Tests that when no type is enabled, no types are included in the stats.

@covers ::endpoint

File

tests/src/Unit/Controller/LingotekDashboardControllerTest.php, line 140

Class

LingotekDashboardControllerTest
@coversDefaultClass \Drupal\lingotek\Controller\LingotekDashboardController @group lingotek @preserveGlobalState disabled

Namespace

Drupal\Tests\lingotek\Unit\Controller

Code

public function testNoTypesEnabledForLingotekTranslation() {
  $this
    ->setUpConfigurableLanguageMock();
  $this->request
    ->expects($this
    ->any())
    ->method('getMethod')
    ->willReturn('GET');
  $languages = [];
  foreach ([
    'en',
    'fr',
  ] as $langcode) {
    $language = new Language([
      'id' => $langcode,
    ]);
    $languages[$langcode] = $language;
  }
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getLanguages')
    ->will($this
    ->returnValue($languages));
  $this->lingotekConfiguration
    ->expects($this
    ->any())
    ->method('getEnabledEntityTypes')
    ->will($this
    ->returnValue([]));
  $this->languageLocaleMapper
    ->expects($this
    ->any())
    ->method('getLocaleForLangcode')
    ->will($this
    ->returnValueMap([
    [
      'en',
      'en_US',
    ],
    [
      'fr',
      'fr_CA',
    ],
  ]));

  /** @var \Symfony\Component\HttpFoundation\JsonResponse $value */
  $response = $this->controller
    ->endpoint($this->request);
  $content = json_decode($response
    ->getContent(), TRUE);
  $this
    ->assertEquals('GET', $content['method']);
  $this
    ->assertEquals(2, count($content['languages']));
  $this
    ->assertEquals(0, count($content['languages']['en_US']['source']['types']));
  $this
    ->assertEquals(0, count($content['languages']['fr_CA']['source']['types']));
}