DrupalBin
Submit Code
About
Recent Posts
Code
12 min 4 sec
ago
admin settings not saving
1 hour 38 min
ago
Code
2 hours 21 min
ago
Code
2 hours 37 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for node.admin.inc test case
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
class NodeAdminTestCase extends DrupalWebTestCase { /** * Implementation of getInfo(). */ function getInfo() { return array( 'name' => t('Node administration tests'), 'description' => t('Tests the node administration screens'), 'group' => t('Node'), ); } function testNodeFilters() { $status_nodes = array(); $promote_nodes = array(); $sticky_nodes = array(); $type_nodes = array(); $all_nodes = array(); $type_map = array('page', 'article'); // Create some nodes. for ($status = 0; $status < 2; $status++) { for ($promote = 0; $promote < 2; $promote++) { for ($sticky = 0; $sticky < 2; $sticky++) { foreach ($type_map as $type_key => $type) { for ($i = 0; $i < 3; $i++) { $node = $this->drupalCreateNode(array('status' => $status, 'promote' => $promote, 'sticky' => $sticky, 'type' => $type)); $status_nodes[$status][] = $promote_nodes[$promote][] = $sticky_nodes[$sticky][] = $type_nodes[$type_key][] = $node; $all_nodes[$node->nid] = $node; } } } } } $user = $this->drupalCreateUser(array('administer nodes')); $this->drupalLogin($user); // Iterate through all of the combinations. -1 = undefined. for ($status = -1; $status < 2; $status++) { for ($promote = -1; $promote < 2; $promote++) { for ($sticky = -1; $sticky < 2; $sticky++) { for ($type = -1; $type < 2; $type++) { $options = array(); foreach (array('status', 'promote', 'sticky', 'type') as $option) { if ($$option != -1) { $options[$option] = $$option; } } $this->drupalGet('admin/content/node'); $first = TRUE; // Iterate through the options, setting them in the form. foreach ($options as $option => $value) { if ($option == 'type') { $edit = array('filter' => 'type', 'type' => $type_map[$value]); } else { $edit = array('filter' => 'status', 'value' => $option . '-' . $value); } if (count($options) > 2) {print_r($edit);} if ($first == TRUE) { $this->drupalPost('admin/content/node', $edit, t('Filter')); $first = FALSE; } else { $this->drupalPost('admin/content/node', $edit, t('Refine')); } } if (count($options) > 2) {var_dump($this->drupalGetContent());exit;} $nodes = array(); $showing_nodes = $hidden_nodes = $all_nodes; if (!empty($options)) { foreach ($options as $option => $value) { $node_variable = $option . '_nodes'; $node_variable = $$node_variable; foreach ($node_variable[(int)!$value] as $node) { if (isset($showing_nodes[$node->nid])) { unset($showing_nodes[$node->nid]); } } } } foreach ($showing_nodes as $nid => $node) { if (isset($hidden_nodes[$nid])) { unset($hidden_nodes[$nid]); } foreach ($type_nodes as $node_type => $nodes) { $this->assertFieldByName('nodes[' . $node->nid . ']', '', t('Node %title shows up when it\'s supposed to.', array('%title' => $node->title))); } } foreach ($hidden_nodes as $node) { $this->assertNoFieldByName('nodes[' . $node->nid . ']', '', t('Node %title doesn\'t show up when it\'s not supposed to.', array('%title' => $node->title))); } $this->drupalPost('admin/content/node', array(), t('Reset')); } } } } } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.