Example #1
0
 public function testMagic()
 {
     $EventCacheInst = EventCache::getInstance();
     $EventCacheInst->flush();
     $this->DBCalled = false;
     $events = $EventCacheInst->getEvents();
     $this->assertTrue(empty($events));
     $this->assertEquals('Kevin', $this->heavyDBFunction('Kevin'));
     $this->assertTrue($this->DBCalled);
     $this->assertEquals('van Zonneveld', $this->heavyDBFunction('van Zonneveld', array('url' => array('controller' => 'Customers', 'action' => 'view', 'id' => 5))));
     $this->assertTrue($this->DBCalled);
     $this->assertEquals('van Zonneveld', $this->heavyDBFunction('van Zonneveld', array('url' => array('controller' => 'Customers', 'action' => 'view', 'id' => 6))));
     $this->assertTrue($this->DBCalled);
     $this->assertEquals('van Zonneveld', $this->heavyDBFunction('van Zonneveld', array('url' => array('controller' => 'Customers', 'action' => 'view', 'id' => 6))));
     $this->assertFalse($this->DBCalled);
     $this->assertEquals('van Zonneveld', $this->heavyDBFunction('van Zonneveld', array('url' => array('controller' => 'Customers', 'action' => 'view', 'id' => 6))));
     $this->assertFalse($this->DBCalled);
     $this->assertEquals('Kevin', $this->heavyDBFunction('Kevin'));
     $this->assertTrue(!$this->DBCalled);
     $events = $EventCacheInst->getEvents();
     $this->assertContains('deploy', $events);
     $this->assertContains('Server::afterSave', $events);
     $this->assertTrue(count($events) === 2);
     $this->assertEquals('Kevin', EventCache::read($this->MagicKey));
 }