#542206 by asimmonds: Fix admin/content filters (with tests).
parent
041d8ee5a8
commit
22a5a73ddf
|
@ -145,7 +145,6 @@ function node_filter_form() {
|
||||||
'#title' => t('Show only items where'),
|
'#title' => t('Show only items where'),
|
||||||
'#theme' => 'node_filters',
|
'#theme' => 'node_filters',
|
||||||
);
|
);
|
||||||
$form['#submit'][] = 'node_filter_form_submit';
|
|
||||||
foreach ($session as $filter) {
|
foreach ($session as $filter) {
|
||||||
list($type, $value) = $filter;
|
list($type, $value) = $filter;
|
||||||
if ($type == 'term') {
|
if ($type == 'term') {
|
||||||
|
@ -160,10 +159,10 @@ function node_filter_form() {
|
||||||
$value = $filters[$type]['options'][$value];
|
$value = $filters[$type]['options'][$value];
|
||||||
}
|
}
|
||||||
if ($i++) {
|
if ($i++) {
|
||||||
$form['filters']['current'][] = array('#markup' => t('<em>and</em> where <strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
|
$form['filters']['current'][] = array('#markup' => t('<em>and</em> where <strong>%type</strong> is <strong>%value</strong>', array('%type' => $filters[$type]['title'], '%value' => $value)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$form['filters']['current'][] = array('#markup' => t('<strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
|
$form['filters']['current'][] = array('#markup' => t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => $filters[$type]['title'], '%value' => $value)));
|
||||||
}
|
}
|
||||||
if (in_array($type, array('type', 'language'))) {
|
if (in_array($type, array('type', 'language'))) {
|
||||||
// Remove the option if it is already being filtered on.
|
// Remove the option if it is already being filtered on.
|
||||||
|
@ -377,7 +376,7 @@ function node_admin_content($form_state) {
|
||||||
'#markup' => theme('links', array(array('title' => t('Add new content'), 'href' => 'node/add')), array('class' => array('action-links'))),
|
'#markup' => theme('links', array(array('title' => t('Add new content'), 'href' => 'node/add')), array('class' => array('action-links'))),
|
||||||
);
|
);
|
||||||
$form[] = node_filter_form();
|
$form[] = node_filter_form();
|
||||||
|
$form['#submit'][] = 'node_filter_form_submit';
|
||||||
$form['#theme'] = 'node_filter_form';
|
$form['#theme'] = 'node_filter_form';
|
||||||
$form['admin'] = node_admin_nodes();
|
$form['admin'] = node_admin_nodes();
|
||||||
|
|
||||||
|
|
|
@ -846,3 +846,57 @@ class NodeAccessRebuildTestCase extends DrupalWebTestCase {
|
||||||
$this->assertText(t('Content permissions have been rebuilt.'));
|
$this->assertText(t('Content permissions have been rebuilt.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test node administration page functionality.
|
||||||
|
*/
|
||||||
|
class NodeAdminTestCase extends DrupalWebTestCase {
|
||||||
|
protected $admin_user;
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Node administration',
|
||||||
|
'description' => 'Test node administration page functionality.',
|
||||||
|
'group' => 'Node'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
$this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content'));
|
||||||
|
$this->drupalLogin($this->admin_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create 3 nodes and test if they are listed on the node admistration page.
|
||||||
|
*/
|
||||||
|
function testNodeAdmin() {
|
||||||
|
$node1 = $this->drupalCreateNode(array('type' => 'article', 'status' => 1));
|
||||||
|
$node2 = $this->drupalCreateNode(array('type' => 'article', 'status' => 0));
|
||||||
|
$node3 = $this->drupalCreateNode(array('type' => 'page'));
|
||||||
|
|
||||||
|
$this->drupalGet('admin/content');
|
||||||
|
$this->assertText($node1->title, t('Node appears on the node administration listing.'));
|
||||||
|
|
||||||
|
// Filter the node listing by status.
|
||||||
|
$edit = array(
|
||||||
|
'filter' => 'status',
|
||||||
|
'status' => 'status-1',
|
||||||
|
);
|
||||||
|
$this->drupalPost('admin/content', $edit, t('Filter'));
|
||||||
|
$this->assertRaw(t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => t('status'), '%value' => t('published'))), t('The node administration listing is filtered by status.'));
|
||||||
|
$this->assertText($node1->title, t('Published node appears on the node administration listing.'));
|
||||||
|
$this->assertNoText($node2->title, t('Unpublished node does not appear on the node administration listing.'));
|
||||||
|
|
||||||
|
// Filter the node listing by content type.
|
||||||
|
$edit = array(
|
||||||
|
'filter' => 'type',
|
||||||
|
'type' => 'article',
|
||||||
|
);
|
||||||
|
$this->drupalPost('admin/content', $edit, t('Refine'));
|
||||||
|
$this->assertRaw(t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => t('status'), '%value' => t('published'))), t('The node administration listing is filtered by status.'));
|
||||||
|
$this->assertRaw(t('<strong>%type</strong> is <strong>%value</strong>', array('%type' => t('type'), '%value' => 'Article')), t('The node administration listing is filtered by content type.'));
|
||||||
|
$this->assertText($node1->title, t('Article node appears on the node administration listing.'));
|
||||||
|
$this->assertNoText($node3->title, t('Page node does not appear on the node administration listing.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue