ActiveRecordCacheTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. include 'helpers/config.php';
  3. use ActiveRecord\Cache;
  4. class ActiveRecordCacheTest extends DatabaseTest
  5. {
  6. public function set_up($connection_name=null)
  7. {
  8. if (!extension_loaded('memcache'))
  9. {
  10. $this->markTestSkipped('The memcache extension is not available');
  11. return;
  12. }
  13. parent::set_up($connection_name);
  14. ActiveRecord\Config::instance()->set_cache('memcache://localhost');
  15. }
  16. public function tear_down()
  17. {
  18. Cache::flush();
  19. Cache::initialize(null);
  20. }
  21. public function test_default_expire()
  22. {
  23. $this->assert_equals(30,Cache::$options['expire']);
  24. }
  25. public function test_explicit_default_expire()
  26. {
  27. ActiveRecord\Config::instance()->set_cache('memcache://localhost',array('expire' => 1));
  28. $this->assert_equals(1,Cache::$options['expire']);
  29. }
  30. public function test_caches_column_meta_data()
  31. {
  32. Author::first();
  33. $table_name = Author::table()->get_fully_qualified_table_name(!($this->conn instanceof ActiveRecord\PgsqlAdapter));
  34. $value = Cache::$adapter->read("get_meta_data-$table_name");
  35. $this->assert_true(is_array($value));
  36. }
  37. }
  38. ?>