You are here

function EntityTranslationHookTestCase::testFormWorkflow in Entity Translation 7

Test whether hooks are properly fired in the regular form workflow.

File

tests/entity_translation.test, line 514
Tests for Entity translation module.

Class

EntityTranslationHookTestCase
Test CRUD hook invocation.

Code

function testFormWorkflow() {

  // Create Basic page in English.
  $node_title = $this
    ->randomName();
  $node_body = $this
    ->randomName();
  $node = $this
    ->createPage($node_title, $node_body, 'en');

  // Submit translation in Italian.
  $node_translation_body = $this
    ->randomName();
  $this
    ->createTranslation($node, NULL, $node_translation_body, 'it');
  $info = $this
    ->getHookInfo();
  $this
    ->assertTrue(!empty($info['insert']), t('Insert hook has been properly fired.'));

  // Edit translation in Italian.
  $edit = array(
    "body[it][0][value]" => $this
      ->randomName(),
  );
  $this
    ->drupalPost('node/' . $node->nid . '/edit/it', $edit, t('Save'));
  $info = $this
    ->getHookInfo();
  $this
    ->assertTrue(!empty($info['update']), t('Update hook has been properly fired.'));

  // Delete the Basic page.
  $edit = array();
  $this
    ->drupalPost('node/' . $node->nid . '/delete', $edit, t('Delete'));
  $info = $this
    ->getHookInfo('delete');
  $this
    ->assertTrue(count($info) == 2 && !empty($info['en']) && !empty($info['it']), t('Delete hook has been properly fired.'));
}