You are here

public function PushBackControllerTest::testUseCallbackUrlOverrideHost in TMGMT Translator Smartling 8.2

Use callback url. Override host.

File

src/Tests/PushBackControllerTest.php, line 170

Class

PushBackControllerTest
Push back controller tests.

Namespace

Drupal\tmgmt_smartling\Tests

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.");
  }
}