You are here

public function SmartlingTest::testSmartlingProviderSettingsFormValidation in TMGMT Translator Smartling 8

Test Smartling provider plugin form validation.

File

src/Tests/SmartlingTest.php, line 210
Contains \Drupal\tmgmt_smartling\Tests\SmartlingTest.

Class

SmartlingTest
Basic tests for the Smartling translator.

Namespace

Drupal\tmgmt_smartling\Tests

Code

public function testSmartlingProviderSettingsFormValidation() {

  // Validation with wrong parameters.
  $settings = $this->smartlingPluginProviderSettings;
  $settings['settings[project_id]'] = $this
    ->randomString();
  $settings['settings[key]'] = $this
    ->randomString();
  $translator = $this
    ->setUpSmartlingProviderSettings($settings);
  $supported_remote_languages = $translator
    ->getPlugin()
    ->getSupportedRemoteLanguages($translator);
  $this
    ->assertEqual(0, count($supported_remote_languages));

  // Validation with correct parameters
  if (!empty($this->smartlingPluginProviderSettings)) {
    $translator = $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $supported_remote_languages = $translator
      ->getPlugin()
      ->getSupportedRemoteLanguages($translator);
    $this
      ->assertNotEqual(0, count($supported_remote_languages));
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}