You are here

public function Fast404LocaleTestCase::testLocalisedContent in Fast 404 7

File

./fast_404.test, line 189
Tests for fast_404.module.

Class

Fast404LocaleTestCase
Class Fast404LocaleTestCase

Code

public function testLocalisedContent() {
  variable_set('fast_404_path_check', TRUE);
  variable_set('language_content_type_article', 1);

  // Set the site up to use locale. Mainly cribbed from locale.test.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer languages',
    'access administration pages',
    'create article content',
    'edit own article content',
    'administer url aliases',
    'create url aliases',
  ));
  $this
    ->drupalLogin($admin_user);

  // Add predefined language.
  $edit = array(
    'langcode' => 'fr',
  );
  $this
    ->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));

  // Set language negotiation.
  $edit = array(
    'language[enabled][locale-url]' => TRUE,
  );
  $this
    ->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));

  // Set the article path alias.
  $alias = $this
    ->randomName();

  // Create a localised article.
  $edit = array(
    'type' => 'article',
    'title' => $this
      ->randomName(),
    'body' => array(
      'fr' => array(
        array(
          'value' => $this
            ->randomName(),
        ),
      ),
    ),
    'language' => 'fr',
    'path' => array(
      'alias' => $alias,
    ),
  );
  $node = $this
    ->drupalCreateNode($edit);
  $this
    ->drupalGet('fr/node/' . $node->nid . '/edit');

  // Check the potential URLs the node is available from.
  $this
    ->drupalGet('fr/node/' . $node->nid);
  $this
    ->assertResponse(200);
  $this
    ->drupalGet('fr/' . $alias);
}