You are here

function TMGMTUITestCase::testCheckoutFunction in Translation Management Tool 7

Tests the tmgmt_ui_job_checkout() function.

File

ui/tmgmt_ui.test, line 218

Class

TMGMTUITestCase
Test the UI of tmgmt, for example the checkout form.

Code

function testCheckoutFunction() {
  $job = $this
    ->createJob();

  // Check out a job when only the test translator is available. That one has
  // settings, so a checkout is necessary.
  $redirects = tmgmt_ui_job_checkout_multiple(array(
    $job,
  ));
  $uri = $job
    ->uri();
  $this
    ->assertEqual($uri['path'], $redirects[0]);
  $this
    ->assertTrue($job
    ->isUnprocessed());
  $job
    ->delete();

  // Hide settings on the test translator.
  $default_translator = tmgmt_translator_load('test_translator');
  $default_translator->settings = array(
    'expose_settings' => FALSE,
  );
  $job = $this
    ->createJob();
  $redirects = tmgmt_ui_job_checkout_multiple(array(
    $job,
  ));
  $this
    ->assertFalse($redirects);
  $this
    ->assertTrue($job
    ->isActive());

  // A job without target language needs to be checked out.
  $job = $this
    ->createJob('en', '');
  $redirects = tmgmt_ui_job_checkout_multiple(array(
    $job,
  ));
  $uri = $job
    ->uri();
  $this
    ->assertEqual($uri['path'], $redirects[0]);
  $this
    ->assertTrue($job
    ->isUnprocessed());

  // Create a second file translator. This should check
  // out immediately.
  $job = $this
    ->createJob();
  $second_translator = $this
    ->createTranslator();
  $second_translator->settings = array(
    'expose_settings' => FALSE,
  );
  $second_translator
    ->save();
  $redirects = tmgmt_ui_job_checkout_multiple(array(
    $job,
  ));
  $uri = $job
    ->uri();
  $this
    ->assertEqual($uri['path'], $redirects[0]);
  $this
    ->assertTrue($job
    ->isUnprocessed());
}