useTransaction(TRUE); } /** * Test system flush. */ public function testFlush() { // Note: this operation actually flushes several different caches; we don't // check all of them -- just enough to make sure that the API is doing // something $this->assertTrue(NULL === Civi::cache()->get(CRM_Utils_Cache::cleanKey(self::TEST_CACHE_PATH))); $data = 'abc'; Civi::cache()->set(CRM_Utils_Cache::cleanKey(self::TEST_CACHE_PATH), $data); $this->assertEquals('abc', Civi::cache()->get(CRM_Utils_Cache::cleanKey(self::TEST_CACHE_PATH))); $params = array(); $result = $this->callAPIAndDocument('system', 'flush', $params, __FUNCTION__, __FILE__, "Flush all system caches", 'Flush'); $this->assertTrue(NULL === Civi::cache()->get(CRM_Utils_Cache::cleanKey(self::TEST_CACHE_PATH))); } /** * Test system log function. */ public function testSystemLog() { $this->callAPISuccess('system', 'log', array('level' => 'info', 'message' => 'We wish you a merry Christmas')); $result = $this->callAPISuccess('SystemLog', 'getsingle', array( 'sequential' => 1, 'message' => array('LIKE' => '%Chris%'), )); $this->assertEquals($result['message'], 'We wish you a merry Christmas'); $this->assertEquals($result['level'], 'info'); } /** * Test system log function. */ public function testSystemLogNoLevel() { $this->callAPISuccess('system', 'log', array('message' => 'We wish you a merry Christmas', 'level' => 'alert')); $result = $this->callAPISuccess('SystemLog', 'getsingle', array( 'sequential' => 1, 'message' => array('LIKE' => '%Chris%'), )); $this->assertEquals($result['message'], 'We wish you a merry Christmas'); $this->assertEquals($result['level'], 'alert'); } public function testSystemGet() { $result = $this->callAPISuccess('system', 'get', array()); $this->assertRegExp('/^[0-9]+\.[0-9]+\.[0-9a-z\-]+$/', $result['values'][0]['version']); $this->assertEquals('UnitTests', $result['values'][0]['uf']); } }