function TranslationTest::createPage

Creates a "Basic page" in the specified language.

Parameters

$title: The title of a basic page in the specified language.

$body: The body of a basic page in the specified language.

$langcode: (optional) Language code.

Return value

A node object.

4 calls to TranslationTest::createPage()
TranslationTest::testContentTranslation in drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
Creates, modifies, and updates a basic page with a translation.
TranslationTest::testLanguageSwitcherBlockIntegration in drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
Tests that the language switcher block alterations work as intended.
TranslationTest::testLanguageSwitchLinks in drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
Checks that the language switch links behave properly.
TranslationTest::testTranslateOwnContentRole in drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
Checks that users with "translate own content" role only can translate own content.

File

drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php, line 344
Definition of Drupal\translation\Tests\TranslationTest.

Class

TranslationTest
Functional tests for the Translation module.

Namespace

Drupal\translation\Tests

Code

function createPage($title, $body, $langcode = NULL) {
  $edit = array();
  $field_langcode = Language::LANGCODE_NOT_SPECIFIED;
  $edit["title"] = $title;
  $edit["body[{$field_langcode}][0][value]"] = $body;
  if (!empty($langcode)) {
    $edit['langcode'] = $langcode;
  }
  $this
    ->drupalPost('node/add/page', $edit, t('Save'));
  $this
    ->assertRaw(t('Basic page %title has been created.', array(
    '%title' => $title,
  )), 'Basic page created.');

  // Check to make sure the node was created.
  $node = $this
    ->drupalGetNodeByTitle($title);
  $this
    ->assertTrue($node, 'Node found in database.');
  return $node;
}