DefinitionCacheTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. class HTMLPurifier_DefinitionCacheTest extends HTMLPurifier_Harness
  3. {
  4. function test_isOld() {
  5. // using null subclass because parent is abstract
  6. $cache = new HTMLPurifier_DefinitionCache_Null('Test');
  7. generate_mock_once('HTMLPurifier_Config');
  8. $config = new HTMLPurifier_ConfigMock();
  9. $config->version = '1.0.0'; // hopefully no conflicts
  10. $config->setReturnValue('get', 10, array('Test.DefinitionRev'));
  11. $config->setReturnValue('getBatchSerial', 'hash', array('Test'));
  12. $this->assertIdentical($cache->isOld('1.0.0,hash,10', $config), false);
  13. $this->assertIdentical($cache->isOld('1.5.0,hash,1', $config), true);
  14. $this->assertIdentical($cache->isOld('0.9.0,hash,1', $config), true);
  15. $this->assertIdentical($cache->isOld('1.0.0,hash,1', $config), true);
  16. $this->assertIdentical($cache->isOld('1.0.0beta,hash,11', $config), true);
  17. $this->assertIdentical($cache->isOld('0.9.0,hash2,1', $config), true);
  18. $this->assertIdentical($cache->isOld('1.0.0,hash2,1', $config), false); // if hash is different, don't touch!
  19. $this->assertIdentical($cache->isOld('1.0.0beta,hash2,11', $config), true);
  20. $this->assertIdentical($cache->isOld('1.0.0-dev,hash2,11', $config), true);
  21. }
  22. }
  23. // vim: et sw=4 sts=4