batch_example.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /**
  10. * Functional tests for the Batch Example module.
  11. *
  12. * @ingroup batch_example
  13. */
  14. class BatchExampleTestCase extends DrupalWebTestCase {
  15. protected $webUser;
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function getInfo() {
  20. return array(
  21. 'name' => 'Batch example functionality',
  22. 'description' => 'Verify the defined batches.',
  23. 'group' => 'Examples',
  24. );
  25. }
  26. /**
  27. * Enable modules and create user with specific permissions.
  28. */
  29. public function setUp() {
  30. parent::setUp('batch_example');
  31. // Create user.
  32. $this->webUser = $this->drupalCreateUser();
  33. }
  34. /**
  35. * Login user, create 30 nodes and test both batch examples.
  36. */
  37. public function testBatchExampleBasic() {
  38. // Login the admin user.
  39. $this->drupalLogin($this->webUser);
  40. // Create 30 nodes.
  41. for ($count = 0; $count < 30; $count++) {
  42. $node = $this->drupalCreateNode();
  43. }
  44. // Launch Batch 1
  45. $result = $this->drupalPost('examples/batch_example', array('batch' => 'batch_1'), t('Go'));
  46. // Check that 1000 operations were performed.
  47. $this->assertText('1000 results processed');
  48. // Launch Batch 2
  49. $result = $this->drupalPost('examples/batch_example', array('batch' => 'batch_2'), t('Go'));
  50. // Check that 600 operations were performed.
  51. $this->assertText('600 results processed');
  52. }
  53. }