public function ScaldLocalizeTestCase::testAtomTypeTranslation in Scald: Media Management made easy 7
Tests if it is possible to translate atom types.
File
- tests/
scald.test, line 653 - Tests for scald.module.
Class
- ScaldLocalizeTestCase
- Test the Scald localization.
Code
public function testAtomTypeTranslation() {
// Check that the "translate" action is shown for types in the overview.
$this
->drupalGet('admin/structure/scald');
$elements = $this
->xpath('(//table//td)[6]/a[text() = :text]', array(
':text' => t('translate'),
));
$this
->assertTrue($elements, 'The "translate" action is shown in the types table.');
$this
->drupalGet('admin/structure/scald/image/translate');
// Translate the 'Image' type on the translate tab form. Unfortunately this
// word is spelled identically in French, so we opt for "L'image".
$edit = array(
'strings[scald:type:image:title]' => 'L\'image',
'strings[scald:type:image:description]' => 'Une représentation visuelle',
);
$this
->drupalPost('admin/structure/scald/image/translate/fr', $edit, t('Save translation'));
// Check that the type is translated on the overview.
$this
->drupalGet('fr/admin/structure/scald');
$this
->assertText(check_plain('L\'image'), 'The type is translated on the overview.');
// Check that the type is translated on the Add Atom page.
$this
->drupalGet('fr/atom/add');
$this
->assertText(check_plain('L\'image'), 'The type is translated on the Add Atom page.');
// Check that the type is translated on the Add Image page.
$this
->drupalGet('fr/atom/add/image');
$this
->assertText(check_plain('L\'image'), 'The type is translated on the Add Image page.');
// Check that the type is translated in the message that appears when
// creating an atom.
$atom = $this
->createAtom('image', $this->langcode);
$message = t('Atom %title, of type %type has been @op.', array(
'%title' => $atom->title,
'%type' => 'L\'image',
'@op' => t('created'),
));
$this
->assertRaw($message, 'The type is translated in the notification that appears when creating an atom.');
// Check that the type is translated in the message that appears when
// deleting an atom.
$this
->addAtomAction($atom, 'delete');
$this
->drupalPost('fr/atom/' . $atom->sid . '/delete', array(), t('Delete'));
$message = t('@type %title has been deleted.', array(
'@type' => 'L\'image',
'%title' => $atom->title,
));
$this
->assertRaw($message, 'The type is translated in the notification that appears when deleting an atom.');
}