Esempio n. 1
0
 /**
  * Create dependent objects before running each test
  */
 public final function setUp()
 {
     //run the default setUp() method first
     parent::setUp();
     //create and insert a Sport to own the test TeamStatistic
     $this->sport = new Sport(null, "sportName", "sportLeague");
     $this->sport->insert($this->getPDO());
     //create and insert a team to own the test TeamStatistic
     $this->team = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID, "TeamCity", "TeamName");
     $this->team->insert($this->getPDO());
     $this->team2 = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID2, "TeamCity2", "TeamName2");
     $this->team2->insert($this->getPDO());
     //create and insert a Game to own the test playerStatistic
     $this->game = new Game(null, $this->team->getTeamId(), $this->team2->getTeamId(), "2015-03-23 15:23:04");
     $this->game->insert($this->getPDO());
     // calculate the date (same as unit test)
     $this->VALID_GAMETIME = \DateTime::createFromFormat("Y-m-d H:i:s", "2015-03-23 15:23:04");
     $this->VALID_GAMETIME2 = \DateTime::createFromFormat("Y-m-d H:i:s", "2015-03-23 16:23:04");
     //create and insert a Statistic to own the test playerStatistic
     $this->statistic = new Statistic(null, "statisticName");
     $this->statistic->insert($this->getPDO());
 }
Esempio n. 2
0
$status = 'ok';
if (isset($_POST['id_hidden'])) {
    //Update
    if (!$team->update($connection)) {
        //Error
        $error = $connection->lastError();
        if ($error['errno'] == 1062) {
            //UQ value error
            $status = "repeat";
        } else {
            $status = "Error {$error['errno']}: {$error['error']}";
        }
    }
} else {
    //Insert
    if (!$team->insert($connection)) {
        //Error
        $error = $connection->lastError();
        if ($error['errno'] == 1062) {
            //UQ value error
            $status = "repeat";
        } else {
            $status = "Error {$error['errno']}: {$error['error']}";
        }
    }
}
/*XML transaction result.*/
header('Content-Type: text/xml');
echo '<transaction>
<status>' . $status . '</status>
</transaction>