Beispiel #1
0
 /**
  * Test the insertion of a duplicate payment.
  */
 public function testAddDuplicatePayment()
 {
     $db = SingletonFactory::getInstance()->getSingleton($this->className);
     $this->assertType($this->className, $db);
     $this->validFieldset['txn_id'] = rand();
     $txn = new Transaction($this->validFieldset);
     $status = $db->addTransaction($txn);
     $this->assertEquals($status, Constants::STATUS_OK, "Status not OK after first insertion!");
     $status = $db->addTransaction($txn);
     $this->assertEquals($status, Constants::STATUS_ERROR, "Status not ERROR after second insertion attempt!");
 }
Beispiel #2
0
/**
 * Checks the database for an existing transaction ID.
 * @return true if it's duplicate, false if not.
 */
function isDuplicateTxnId($txn_id)
{
    $db = SingletonFactory::getInstance()->getSingleton(DB_MANAGER_CLASS_NAME);
    $dupFound = $db->checkDuplicateRow('txn_id', $txn_id);
    if ($dupFound == Constants::DUPLICATE_FOUND) {
        Logger::error("Duplicate transaction id: {$txn_id}!");
        return true;
    } else {
        return false;
    }
}
Beispiel #3
0
    // end while
    return $out;
}
if (true === isset($_GET['export']) && false === empty($_GET['export'])) {
    $host = Config::$dbHost;
    $user = Config::$dbUser;
    $pass = Config::$dbPass;
    $db = Config::$dbDatabase;
    $table = Config::$dbTable;
    $from_date = $_GET['from_date'];
    $sql_query = "select * from {$table} where add_ts >= '{$from_date}'";
    Logger::debug("Connecting to DB {$db} table {$table} user {$user} host {$host}");
    Logger::debug("SQL query: {$sql_query}");
    $link = mysql_connect($host, $user, $pass);
    mysql_select_db($db);
    $db = SingletonFactory::getInstance()->getSingleton(DB_MANAGER_CLASS_NAME);
    $dateString = date("Y-m-d-Hi");
    $filename = "pa_ipn_export_{$dateString}_from_{$from_date}.csv";
    $csvData = exportMysqlToCsv($table, $sql_query);
    if (true === empty($csvData)) {
        echo "An error occurred, your data is either empty or there's something wrong with the system. Please try again or e-mail dafydd@cantab.net";
    } else {
        //Logger::debug("CSV data: " . print_r($csvData, true));
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Length: " . strlen($csvData));
        header("Content-type: text/csv");
        //header("Content-type: application/csv");
        header("Content-Disposition: attachment; filename={$filename}");
        echo $csvData;
    }
} else {
Beispiel #4
0
<?php

include_once "../include/includes.php";
$db = SingletonFactory::getInstance()->getSingleton('PrepayDatabase');
$result = $db->executeQuery("select count(*) from prepay_tickets");
var_dump($result);
$result = $db->checkDuplicateRow('txn_id', '1H686265E6317124J');
var_dump($result);
//$txn = new Transaction();
//$result = $db->addTransaction($txn);
//var_dump($result);
Beispiel #5
0
 /**
  * Retrieves an instance of the MailManager from the SingletonFactory.
  */
 public function testMailManagerSingleton()
 {
     $m = SingletonFactory::getInstance()->getSingleton($this->className);
     $this->assertType($this->className, $m);
 }