aboutsummaryrefslogtreecommitdiff
path: root/node_truncate.test
blob: fe242d967a38a007d45273417949249b70291e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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.');
  }
}