diff --git a/.travis.yml b/.travis.yml index af296e0..13cb81e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,8 @@ branches: matrix: fast_finish: true allow_failures: - - php: hhvm - php: 7 + - php: hhvm env: global: diff --git a/drafty.test b/drafty.test index 49d38ec..6c22f59 100644 --- a/drafty.test +++ b/drafty.test @@ -263,7 +263,7 @@ class DraftyFieldCollectionTest extends DraftyWebTestCase { /** * Test draft revisions with entity translation. */ -class DraftyEtTest extends EntityTranslationTestCase { +class DraftyEtTest extends EntityTranslationTestCase { public static function getInfo() { return array( 'name' => 'Drafty Entity Translation', @@ -281,6 +281,39 @@ class DraftyEtTest extends EntityTranslationTestCase { $this->login($this->getTranslatorUser()); } + /** + + * Create a translation. + * + * This overrides because with drafty, asserting an 'edit' link for a + * translation fails when the revision with the added translation has not yet + * been published. + * + * @param $node + * Node of the basic page to create translation for. + * @param $title + * Title of the basic page in the specified language. + * @param $body + * Body of the basic page in the specified language. + * @param $langcode + * The language code to be assigned to the specified values. + */ + function createTranslation($node, $title, $body, $langcode, $source_langcode = 'en') { + $this->drupalGet('node/' . $node->nid . '/edit/add/' . $source_langcode . '/' . $langcode); + + $body_key = "body[$langcode][0][value]"; + $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[$source_langcode][0]['value'], 'Original body value correctly populated.'); + $this->assertFieldById('edit-body-' . $langcode . '-add-more', t('Add another item'), t('Add another item button found.')); + + $edit = array(); + $edit[$body_key] = $body; + + $this->drupalPost(NULL, $edit, t('Save')); + $this->drupalGet('node/' . $node->nid . '/translate'); + + return $node; + } + /** * Test if field based translation works. * diff --git a/modules/drafty_1992010/drafty_1992010.test b/modules/drafty_1992010/drafty_1992010.test index f57077a..796ff4c 100644 --- a/modules/drafty_1992010/drafty_1992010.test +++ b/modules/drafty_1992010/drafty_1992010.test @@ -21,6 +21,38 @@ class Drafty1992010Test extends EntityTranslationTestCase { $this->login($this->getTranslatorUser()); } + /** + * Create a translation. + * + * This overrides because with drafty, asserting an 'edit' link for a + * translation fails when the revision with the added translation has not yet + * been published. + * + * @param $node + * Node of the basic page to create translation for. + * @param $title + * Title of the basic page in the specified language. + * @param $body + * Body of the basic page in the specified language. + * @param $langcode + * The language code to be assigned to the specified values. + */ + function createTranslation($node, $title, $body, $langcode, $source_langcode = 'en') { + $this->drupalGet('node/' . $node->nid . '/edit/add/' . $source_langcode . '/' . $langcode); + + $body_key = "body[$langcode][0][value]"; + $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[$source_langcode][0]['value'], 'Original body value correctly populated.'); + $this->assertFieldById('edit-body-' . $langcode . '-add-more', t('Add another item'), t('Add another item button found.')); + + $edit = array(); + $edit[$body_key] = $body; + + $this->drupalPost(NULL, $edit, t('Save')); + $this->drupalGet('node/' . $node->nid . '/translate'); + + return $node; + } + /** * Test if field based translation works. *