You are here

public function PushBackControllerTest::testUseCallbackUrlOverrideHost in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/PushBackControllerTest.php \Drupal\Tests\tmgmt_smartling\Functional\PushBackControllerTest::testUseCallbackUrlOverrideHost()

Use callback url. Override host.

File

tests/src/Functional/PushBackControllerTest.php, line 160

Class

PushBackControllerTest
Push back controller tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testUseCallbackUrlOverrideHost() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    global $base_url;
    $testHost = 'https://example.com';
    $providerSettings = $this->smartlingPluginProviderSettings;
    $providerSettings['settings[callback_url_use]'] = TRUE;
    $providerSettings['settings[callback_url_host]'] = $testHost;
    $translator = $this
      ->setUpSmartlingProviderSettings($providerSettings);
    $job = $this
      ->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
    $translatorPlugin = $job
      ->getTranslatorPlugin();
    $callbackUrl = $this
      ->invokeMethod($translatorPlugin, 'getCallbackUrl', [
      $job,
    ]);
    $this
      ->assertNotEqual($base_url, $testHost);
    $this
      ->assertTrue($testHost . '/tmgmt-smartling-callback/1', $callbackUrl);
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}