function FileEntityPathsConfigurationPageTestCase::testConfigPage in File Entity Paths 7.2
File
- tests/
fe_paths.test, line 154 - Tests for File Entity Paths
Class
- FileEntityPathsConfigurationPageTestCase
- Configuration page tests.
Code
function testConfigPage() {
$configs = fe_paths_config_load_multiple();
// Working on id 1 configuration
$config = $configs[1];
$this
->drupalGet('admin/config/media/fe-paths');
$configs_in_page = $this
->xpath('id("config-order-form")//tbody/tr');
$this
->assertTrue(count($configs_in_page) == 3, 'All 3 generated configuration found on settings page.');
if (!empty($configs)) {
$row_index = 1;
$label = $this
->xpath("id('config-order-form')//tbody/tr[{$row_index}]/td[1]");
//td[2] is the draggable item!!
$machine_name = $this
->xpath("id('config-order-form')//tbody/tr[{$row_index}]/td[3]");
$status = $this
->xpath("id('config-order-form')//tbody/tr[{$row_index}]/td[4]");
$path = $this
->xpath("id('config-order-form')//tbody/tr[{$row_index}]/td[5]");
$filename = $this
->xpath("id('config-order-form')//tbody/tr[{$row_index}]/td[6]");
$this
->assertTrue($label[0] == $config->label, t('Label is the same in the table as in the configuration. Result: @result, Expected: @expected', array(
'@result' => $label[0],
'@expected' => $config->label,
)));
$this
->assertTrue($machine_name[0] == $config->machine_name, t('Machine name is the same in the table as in the configuration. Result: @result, Expected: @expected', array(
'@result' => $machine_name[0],
'@expected' => $config->machine_name,
)));
$status_text = $config->status ? t('Enabled') : t('Disabled');
$this
->assertTrue($status[0] == $status_text, t('Status is the same in the table as in the configuration. Result: @result, Expected: @expected', array(
'@result' => $status[0],
'@expected' => $status_text,
)));
// http://drupal.org/node/1797646
$this
->assertTrue($path[0] == $config->path, t('Path is the same in the table as in the configuration. Result: @result, Expected: @expected', array(
'@result' => $path[0],
'@expected' => $config->path,
)));
$this
->assertTrue($filename[0] == $config->filename, t('Filename is the same in the table as in the configuration. Result: @result, Expected: @expected', array(
'@result' => $filename[0],
'@expected' => $config->filename,
)));
// @todo: figure out $config->data checking.
// Let's go to the edit page
$this
->clickLink('Edit');
$this
->assertFieldById('edit-label', $config->label);
$this
->assertFieldById('edit-machine-name', $config->machine_name);
$this
->assertFieldById('edit-path', $config->path);
$this
->assertFieldById('edit-filename', $config->filename);
foreach ($config->data['file_entity'] as $bundle => $value) {
if ($bundle !== 'default') {
if ($bundle === $value) {
$this
->assertFieldChecked('edit-data-file-entity-' . str_replace('_', '-', $bundle));
}
else {
$this
->assertNoFieldChecked('edit-data-file-entity-' . str_replace('_', '-', $bundle));
}
}
}
}
}