fpp.locale.test in Fieldable Panels Panes (FPP) 7
Confirm the language integration works correctly.
File
tests/fpp.locale.testView source
<?php
/**
* @file
* Confirm the language integration works correctly.
*/
/**
* Confirm the language integration works correctly.
*/
class FppLocaleTest extends FppTestHelper {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'FPP tests for language handling',
'description' => 'Confirm that language handling works correctly.',
'group' => 'FPP',
'dependencies' => array(
'ctools',
'panels',
'views',
),
);
}
/**
* {@inheritdoc}
*/
public function setUp(array $modules = array()) {
// Needed.
$modules[] = 'locale';
parent::setUp($modules);
}
/**
* Verify the language selector exists.
*/
public function testLanguageSelector() {
// Create a user with the admin permission.
$this->adminUser = $this
->createAdminUser();
$this
->drupalLogin($this->adminUser);
// Load the fpp-add form.
$this
->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle . '/add');
$this
->assertResponse(200);
// Confirm the language selector is present on the page.
$this
->assertFieldByName('language');
}
/**
* Verify the language selector exists.
*/
public function testNoLanguageSelector() {
module_disable(array(
'locale',
));
// Create a user with the admin permission.
$this->adminUser = $this
->createAdminUser();
$this
->drupalLogin($this->adminUser);
// Load the fpp-add form.
$this
->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle . '/add');
$this
->assertResponse(200);
// Confirm the language selector is present on the page.
$this
->assertNoFieldByName('language');
}
/**
* Verify the language selector works with no language selected.
*/
public function testLanguageNone() {
// Create a user with the admin permission.
$this->adminUser = $this
->createAdminUser();
$this
->drupalLogin($this->adminUser);
// Load the fpp-add form.
$this
->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle . '/add');
$this
->assertResponse(200);
// Confirm the language selector is present on the page.
$this
->assertFieldByName('language');
$edit = array(
'title' => $this->title,
'language' => LANGUAGE_NONE,
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle);
$this
->assertResponse(200);
$this
->assertText($this->title);
// The entity created should have fpid 1.
$fpp = fieldable_panels_panes_load(1);
$this
->assertEqual($this->title, $fpp->title);
// Confirm that the FPP's language is still 'none'.
$language = entity_language('fieldable_panels_pane', $fpp);
$this
->assertEqual($language, LANGUAGE_NONE);
}
/**
* Verify the language selector works with a specific language.
*/
public function testLanguageEnglish() {
// Create a user with the admin permission.
$this->adminUser = $this
->createAdminUser();
$this
->drupalLogin($this->adminUser);
// Load the fpp-add form.
$this
->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle . '/add');
$this
->assertResponse(200);
// Confirm the language selector is present on the page.
$this
->assertFieldByName('language');
$edit = array(
'title' => $this->title,
'language' => 'en',
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle);
$this
->assertResponse(200);
$this
->assertText($this->title);
// The entity created should have fpid 1.
$fpp = fieldable_panels_panes_load(1);
$this
->assertEqual($this->title, $fpp->title);
// Confirm that the FPP's language is still 'none'.
$language = entity_language('fieldable_panels_pane', $fpp);
$this
->assertEqual($language, 'en');
}
}
Classes
Name | Description |
---|---|
FppLocaleTest | Confirm the language integration works correctly. |