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