activateTracking() public static méthode

Activates tracking of a table.
public static activateTracking ( string $dbname, string $tablename, string $version ) : integer
$dbname string name of database
$tablename string name of table
$version string version
Résultat integer result of SQL query
Exemple #1
0
/**
 * Function to activate tracking
 *
 * @return string HTML for the success message
 */
function PMA_activateTracking()
{
    $html = '';
    $activated = Tracker::activateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']);
    if ($activated) {
        $msg = Message::success(sprintf(__('Tracking for %1$s was activated at version %2$s.'), htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table']), htmlspecialchars($_REQUEST['version'])));
        $html .= $msg->getDisplay();
    }
    return $html;
}
 /**
  * Test for Tracker::changeTracking(). This test is also invoked by two
  * other tests: testActivateTracking() and testDeactivateTracking()
  *
  * @param string $dbname    Database name
  * @param string $tablename Table name
  * @param string $version   Version
  * @param string $new_state State to change to
  * @param string $type      Type of test
  *
  * @return void
  *
  * @test
  *
  */
 public function testChangeTracking($dbname = 'pma_db', $tablename = 'pma_tbl', $version = '0.1', $new_state = '1', $type = null)
 {
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $sql_query = " UPDATE `pmadb`.`tracking` SET `tracking_active` = " . "'" . $new_state . "' " . " WHERE `db_name` = '" . $dbname . "' " . " AND `table_name` = '" . $tablename . "' " . " AND `version` = '" . $version . "' ";
     $GLOBALS['controllink'] = null;
     $dbi->expects($this->exactly(1))->method('query')->with($sql_query, null, 0, false)->will($this->returnValue("executed"));
     $GLOBALS['dbi'] = $dbi;
     if ($type == null) {
         $method = new \ReflectionMethod('PMA\\libraries\\Tracker', '_changeTracking');
         $method->setAccessible(true);
         $result = $method->invoke(null, $dbname, $tablename, $version, $new_state);
     } elseif ($type == "activate") {
         $result = Tracker::activateTracking($dbname, $tablename, $version);
     } elseif ($type == "deactivate") {
         $result = Tracker::deactivateTracking($dbname, $tablename, $version);
     }
     $this->assertEquals('executed', $result);
 }