diff options
-rw-r--r-- | node_truncate.info | 1 | ||||
-rw-r--r-- | node_truncate.test | 62 |
2 files changed, 63 insertions, 0 deletions
diff --git a/node_truncate.info b/node_truncate.info index 0942e29..9cfa6c0 100644 --- a/node_truncate.info +++ b/node_truncate.info @@ -4,3 +4,4 @@ description = Delete all posts from content types. package = Development core = 7.x version = "7.x-0.1" +files[] = node_truncate.test diff --git a/node_truncate.test b/node_truncate.test new file mode 100644 index 0000000..fe242d9 --- /dev/null +++ b/node_truncate.test @@ -0,0 +1,62 @@ +<?php +// $Id$ + +/** + * @file + * Test case for Testing the Node Truncate module. + * + * This file contains the test cases to check if module is performing as + * expected. + * + */ +class NodeTruncateTestCase extends DrupalWebTestCase { + protected $web_user; + + public static function getInfo() { + return array( + 'name' => 'Node truncate functionality', + 'description' => 'Verify node truncate batch.', + 'group' => 'Node truncate', + ); + } + + /** + * Enable modules and create user with specific permissions. + */ + function setUp() { + parent::setUp('node_truncate'); + // Create user. + $this->web_user = $this->drupalCreateUser(); + } + + /** + * Login user, create 30 nodes and test batch. + */ + function testNodeTruncateBasic() { + // Login the admin user. + $user = $this->drupalCreateUser(array('administer nodes')); + $this->drupalLogin($user); + + // Content type settings. + $settings = array( + 'type' => 'node_truncate', + ); + + // Create a content type. + $content_type = $this->drupalCreateContentType($settings); + $this->assertEqual($content_type->type, 'node_truncate'); + + // Create 30 nodes. + for ($count = 0; $count < 30; $count++) { + $node = $this->drupalCreateNode($settings); + } + + // Launch Batch. + $result = $this->drupalPost('admin/config/content/node_truncate', + array('node_types[node_truncate]' => TRUE), + t('Truncate')); + + // Check that 30 operations were performed. + $this->assertText('30 old posts processed.'); + } +} |