public function testSyncWithCli() { Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); Kwf_Model_MirrorCache_TestController::setup(); Kwf_Model_MirrorCache_TestController::$proxyModel->synchronize(Kwf_Model_MirrorCache::SYNC_ONCE); $this->assertEquals(1, (int) Kwf_Benchmark::getCounterValue('mirror sync')); $url = 'http://' . Kwf_Registry::get('testDomain') . '/kwf/test/kwf_model_mirror-cache_test'; $this->assertEquals(0, file_get_contents($url)); sleep(6); //sync delay ist 5 sec $this->assertEquals(1, file_get_contents($url)); $this->assertEquals(0, file_get_contents($url)); Kwf_Benchmark::reset(); Kwf_Model_MirrorCache_TestController::$proxyModel->countRows(); $this->assertEquals(0, (int) Kwf_Benchmark::getCounterValue('mirror sync')); sleep(6); //sync delay ist 5 sec Kwf_Benchmark::reset(); Kwf_Model_MirrorCache_TestController::$proxyModel->synchronize(Kwf_Model_MirrorCache::SYNC_ALWAYS); $this->assertEquals(1, (int) Kwf_Benchmark::getCounterValue('mirror sync')); $this->assertEquals(0, file_get_contents($url)); }
static function setup() { self::$sourceModel = new Kwf_Model_FnF(array('uniqueIdentifier' => 'unique', 'columns' => array('id', 'firstname', 'lastname', 'timefield'), 'uniqueColumns' => array('id'), 'data' => array(array('id' => 1, 'firstname' => 'Max', 'timefield' => '2008-06-09 00:00:00'), array('id' => 2, 'firstname' => 'Susi', 'timefield' => '2008-07-09 10:00:00'), array('id' => 3, 'firstname' => 'Kurt', 'timefield' => '2008-07-15 20:00:00')))); self::$mirrorModel = new Kwf_Model_FnF(array('uniqueIdentifier' => 'unique', 'columns' => array('id', 'firstname', 'lastname', 'timefield'), 'uniqueColumns' => array('id'), 'data' => array(array('id' => 1, 'firstname' => 'Max', 'timefield' => '2008-06-09 00:00:00'), array('id' => 2, 'firstname' => 'Susi', 'timefield' => '2008-07-09 10:00:00')))); self::$proxyModel = new Kwf_Model_MirrorCache(array('proxyModel' => self::$mirrorModel, 'sourceModel' => self::$sourceModel, 'syncTimeField' => 'timefield', 'maxSyncDelay' => 5)); }