cacheCommandTest.php

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

Classes

Namesort descending Description
cacheCommandCase cache command testing.

File

tests/cacheCommandTest.php
View source
  1. <?php
  2. /**
  3. * cache command testing.
  4. *
  5. * @group base
  6. */
  7. class cacheCommandCase extends Drush_CommandTestCase {
  8. public function testCacheGetSetClear() {
  9. $this->setUpDrupal(1, TRUE);
  10. $options = array(
  11. 'yes' => NULL,
  12. 'root' => $this->webroot(),
  13. 'uri' => key($this->sites),
  14. );
  15. // Test the cache get command.
  16. $this->drush('cache-get', array('schema'), $options + array('format' => 'json'));
  17. $schema = json_decode($this->getOutput());
  18. $this->assertObjectHasAttribute('data', $schema);
  19. // Test that get-ing a non-existant cid fails.
  20. $this->drush('cache-get', array('test-failure-cid'), $options + array('format' => 'json'));
  21. $output = json_decode($this->getOutput());
  22. $this->assertEmpty($output);
  23. // Test setting a new cache item.
  24. $cache_test_value = 'cache test string';
  25. $this->drush('cache-set', array('cache-test-cid', $cache_test_value), $options);
  26. $this->drush('cache-get', array('cache-test-cid'), $options + array('format' => 'json'));
  27. $cache_value = json_decode($this->getOutput());
  28. $this->assertEquals($cache_test_value, $cache_value->data);
  29. // Test cache-clear all.
  30. $this->drush('cache-clear', array('all'), $options);
  31. $this->drush('cache-get', array('cache-test-cid'), $options + array('format' => 'json'));
  32. $output = json_decode($this->getOutput());
  33. $this->assertEmpty($output);
  34. }
  35. }