queueTest.php

  1. 8.0.x tests/queueTest.php
  2. 6.x tests/queueTest.php
  3. 7.x tests/queueTest.php
  4. 5.x tests/queueTest.php
  5. master tests/queueTest.php

Namespace

Unish

Classes

Namesort descending Description
QueueCase @group commands

File

tests/queueTest.php
View source
  1. <?php
  2. namespace Unish;
  3. /**
  4. * @group commands
  5. */
  6. class QueueCase extends CommandUnishTestCase {
  7. function testQueue() {
  8. if (UNISH_DRUPAL_MAJOR_VERSION == 6) {
  9. $this->markTestSkipped("Queue API not available in Drupal 6.");
  10. }
  11. if (UNISH_DRUPAL_MAJOR_VERSION == 7) {
  12. $expected = 'aggregator_feeds,%items,SystemQueue';
  13. }
  14. else {
  15. $expected = 'aggregator_feeds,%items,Drupal\Core\Queue\DatabaseQueue';
  16. }
  17. $sites = $this->setUpDrupal(1, TRUE);
  18. $options = array(
  19. 'yes' => NULL,
  20. 'root' => $this->webroot(),
  21. 'uri' => key($sites),
  22. );
  23. // Enable aggregator since it declares a queue.
  24. $this->drush('pm-enable', array('aggregator'), $options);
  25. $this->drush('queue-list', array(), $options);
  26. $output = $this->getOutput();
  27. $this->assertContains('aggregator_feeds', $output, 'Queue list shows the declared queue.');
  28. $this->drush('php-script', array('queue_script-D' . UNISH_DRUPAL_MAJOR_VERSION), $options + array('script-path' => dirname(__FILE__) . '/resources'));
  29. $this->drush('queue-list', array(), $options + array('pipe' => TRUE));
  30. $output = trim($this->getOutput());
  31. $parts = explode(",", $output);
  32. $this->assertEquals(str_replace('%items', 1, $expected), $output, 'Item was successfully added to the queue.');
  33. $output = $this->getOutput();
  34. $this->drush('queue-run', array('aggregator_feeds'), $options);
  35. $this->drush('queue-list', array(), $options + array('pipe' => TRUE));
  36. $output = trim($this->getOutput());
  37. $parts = explode(",", $output);
  38. $this->assertEquals(str_replace('%items', 0, $expected), $output, 'Queue item processed.');
  39. }
  40. }