t('Node revisions'), 'description' => t('Creates a node of type Page and then a user tries various revision actions such as viewing, reverting to, and deleting revisions.'), 'group' => t('Node') ); } /** * Implementation of setUp(). */ function setUp() { parent::setUp(); // Create and login user. $test_user = $this->drupalCreateUser(array('view revisions', 'revert revisions', 'edit any page content', 'delete revisions', 'delete any page content')); $this->drupalLogin($test_user); // Create initial node. $node = $this->drupalCreateNode(); $settings = get_object_vars($node); $settings['revision'] = 1; $nodes = array(); $logs = array(); // Get original node. $nodes[] = $node; // Create three revisions. $revision_count = 3; for ($i = 0; $i < $revision_count; $i++) { $logs[] = $settings['log'] = $this->randomName(32); // Create revision with random title and body and update variables. $this->drupalCreateNode($settings); $node = node_load($node->nid); // Make sure we get revision information. $settings = get_object_vars($node); $nodes[] = $node; } $this->nodes = $nodes; $this->logs = $logs; } /** * Check node revision related opperations. */ function testRevisions() { $nodes = $this->nodes; $logs = $this->logs; // Get last node for simple checks. $node = $nodes[3]; // Confirm the correct revision text appears on "view revisions" page. $this->drupalGet("node/$node->nid/revisions/$node->vid/view"); $this->assertText($node->body, t('Correct text displays for version.')); // Confirm the correct log message appears on "revisions overview" page. $this->drupalGet("node/$node->nid/revisions"); foreach ($logs as $log) { $this->assertText($log, t('Log message found.')); } // Confirm that revisions revert properly. $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/revert", array(), t('Revert')); $this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => 'Page', '%title' => $nodes[1]->title, '%revision-date' => format_date($nodes[1]->revision_timestamp))), t('Revision reverted.')); $reverted_node = node_load($node->nid); $this->assertTrue(($nodes[1]->body == $reverted_node->body), t('Node reverted correctly.')); // Confirm revisions delete properly. $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/delete", array(), t('Delete')); $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($nodes[1]->revision_timestamp), '@type' => 'Page', '%title' => $nodes[1]->title)), t('Revision deleted.')); $this->assertTrue(db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d and vid = %d', $node->nid, $nodes[1]->vid)) == 0, t('Revision not found.')); } } class NodeTeaserTestCase extends DrupalWebTestCase { /** * Implementation of getInfo() for information */ function getInfo() { return array( 'name' => t('Node teaser'), 'description' => t('Calls node_teaser() with different strings and lengths.'), 'group' => t('Node') ); } function setUp() { parent::setUp(); } function tearDown() { parent::tearDown(); } /** * Tests an edge case where if the first sentence is a question and * subsequent sentences are not. */ function testFirstSentenceQuestion() { $body = 'A question? A sentence. Another sentence.'; $expectedTeaser = 'A question? A sentence.'; $this->callNodeTeaser($body, $expectedTeaser, NULL, 30); } /** * Simpletest test. A real-life example of the above edge case. */ function testFirstSentenceQuestion2() { $body = 'Are you an UberBabe? (Or an appreciator of UberBabes?) I am most definitely an UberBabe, and I\'m proud of it. Now, before anyone screams "sexism" or "bias" or "cheap" or anything more profane, let me clarify. An UberBabe is not someone who\'s playfully pierced navel protrudes from a belly bearing top. Not necessarily anyway. An UberBabe is a woman who likes being totally feminine, but is also smart as hell, brave, a rule breaker, speaks her mind, finds her own way, goes up against "the system" in a way that allows the system to evolve, and so on. UberBabes, frankly, kick booty - and they just may save the world.'; $expectedTeaser = 'Are you an UberBabe? (Or an appreciator of UberBabes?) I am most definitely an UberBabe, and I\'m proud of it. Now, before anyone screams "sexism" or "bias" or "cheap" or anything more profane, let me clarify.'; $this->callNodeTeaser($body, $expectedTeaser, NULL, 300); } /** * Test various teaser length edge cases. */ function testLength() { // This body string tests a number of edge cases. $body = "
\nHi\n
\n\nfolks\n
\n!\n
\nHi\n
\n\nfolks\n
\n!\n
", "
\n", "
\nH", "
\nHi", "
\nHi\n", "
\nHi\n<", "
\nHi\n", "
\nHi\n
\nHi\n", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
\n\nfolks\n
\n!\n
\nHi\n
\n\nfolks\n
\n!\n
\nHi\n
\n\nfolks\n
\n!\n
\nHi\n
\n\nfolks\n
\n!\n
", "
", "
", "
", "
\nHi", "
\nHi", "
\nHi", "
\nHi", "
\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
", "\nHi\n
\n\nfolks\n
\n!\n
\nHi\n
\n\nfolks\n
\n!\n
\nHi\n
\n\nfolks\n
\n!\n