/** * Test getTriggerDefinition($trigger) */ function testGetTriggerDefinition() { //setup $trigger_name = 'test_trigger'; include_once 'MDB2_nonstandard.php'; $nonstd =& MDB2_nonstandard::factory($this->db, $this); if (PEAR::isError($nonstd)) { $this->assertTrue(false, 'Cannot create trigger: ' . $nonstd->getMessage()); return; } $result = $nonstd->createTrigger($trigger_name, $this->table); if (PEAR::isError($result)) { $this->assertTrue(false, 'Cannot create trigger: ' . $result->getMessage()); return; } //test $def = $this->db->reverse->getTriggerDefinition($trigger_name); if (PEAR::isError($def)) { $this->assertTrue(false, 'getTriggerDefinition: ' . $def->getMessage()); } else { $nonstd->checkTrigger($trigger_name, $this->table, $def); } //cleanup $result = $nonstd->dropTrigger($trigger_name, $this->table); if (PEAR::isError($result)) { $this->assertTrue(false, 'Error dropping the trigger: ' . $result->getMessage()); return; } }
/** * Test listFunctions() */ function testListFunctions() { //setup $function_name = 'test_add'; include_once 'MDB2_nonstandard.php'; $nonstd =& MDB2_nonstandard::factory($this->db, $this); if (PEAR::isError($nonstd)) { $this->assertTrue(false, 'Cannot instanciate MDB2_nonstandard object: ' . $nonstd->getMessage()); return; } $result = $nonstd->createFunction($function_name); if (PEAR::isError($result)) { $this->assertTrue(false, 'Cannot create function: ' . $result->getMessage() . ' :: ' . $result->getUserInfo()); return; } //test $functions = $this->db->manager->listFunctions(); if (PEAR::isError($functions)) { $this->assertTrue(false, 'Error listing the functions: ' . $functions->getMessage()); } else { $this->assertTrue(in_array($function_name, $functions), 'Error: function not found'); } //cleanup $result = $nonstd->dropFunction($function_name); if (PEAR::isError($result)) { $this->assertTrue(false, 'Error dropping the function: ' . $result->getMessage()); } }
/** * Test listFunctions() */ function testListFunctions() { //setup $function_name = 'test_add'; include_once 'MDB2_nonstandard.php'; $nonstd =& MDB2_nonstandard::factory($this->db, $this); if (PEAR::isError($nonstd)) { $this->fail('Cannot instanciate MDB2_nonstandard object: ' . $nonstd->getMessage()); return; } $this->db->pushErrorHandling(PEAR_ERROR_RETURN); $this->db->expectError('*'); $result = $nonstd->createFunction($function_name); $this->db->popExpect(); $this->db->popErrorHandling(); if (PEAR::isError($result)) { if ($result->getCode() == MDB2_ERROR_NOT_CAPABLE) { $this->markTestSkipped('createFunction() not supported'); } $this->fail('Cannot create function: ' . $result->getMessage() . ' :: ' . $result->getUserInfo()); return; } //test $functions = $this->db->manager->listFunctions(); if (PEAR::isError($functions)) { $this->fail('Error listing the functions: ' . $functions->getMessage()); } else { $this->assertTrue(in_array($function_name, $functions), 'Error: function not found'); } //cleanup $result = $nonstd->dropFunction($function_name); if (PEAR::isError($result)) { $this->fail('Error dropping the function: ' . $result->getMessage()); } }