batch_example.test

  1. examples
    1. 7 batch_example/batch_example.test
    2. 8 batch_example/batch_example.test

Test case for Testing the batch example module.

This file contains the test cases to check if module is performing as expected.

Classes

NameDescription
BatchExampleTestCase@file Test case for Testing the batch example module.

File

batch_example/batch_example.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Test case for Testing the batch example module.
  5. *
  6. * This file contains the test cases to check if module is performing as
  7. * expected.
  8. */
  9. class BatchExampleTestCase extends DrupalWebTestCase {
  10. protected $web_user;
  11. public static function getInfo() {
  12. return array(
  13. 'name' => 'Batch example functionality',
  14. 'description' => 'Verify the defined batches.',
  15. 'group' => 'Examples',
  16. );
  17. }
  18. /**
  19. * Enable modules and create user with specific permissions.
  20. */
  21. function setUp() {
  22. parent::setUp('batch_example');
  23. // Create user.
  24. $this->web_user = $this->drupalCreateUser();
  25. }
  26. /**
  27. * Login user, create 30 nodes and test both batch examples.
  28. */
  29. function testBatchExampleBasic() {
  30. // Login the admin user.
  31. $this->drupalLogin($this->web_user);
  32. // Create 30 nodes
  33. for ($count = 0; $count < 30; $count++) {
  34. $node = $this->drupalCreateNode();
  35. }
  36. // Launch Batch 1
  37. $result = $this->drupalPost('examples/batch_example', array('batch' => 'batch_1'), t('Go'));
  38. // Check that 1000 operations were performed.
  39. $this->assertText('1000 results processed');
  40. // Launch Batch 2
  41. $result = $this->drupalPost('examples/batch_example', array('batch' => 'batch_2'), t('Go'));
  42. // Check that 600 operations were performed.
  43. $this->assertText('600 results processed');
  44. }
  45. }
Login or register to post comments