예제 #1
0
 public function testUpdatePlayerTeam()
 {
     $new_update = $this->createMockNewUpdate();
     $db = $this->getMockBuilder('stdClass')->setMethods(['newUpdate', 'query'])->getMock();
     $db->expects($this->once())->method('newUpdate')->will($this->returnValue($new_update));
     $expected_values = ['ibl_team' => 'MAD', 'id' => 1];
     $db->expects($this->once())->method('query')->with($new_update, $expected_values)->will($this->returnValue(true));
     $roster = new Roster($db);
     $expected_response = true;
     $response = $roster->updatePlayerTeam('MAD', 1);
     $this->assertEquals($expected_response, $response, 'updatePlayerTeam() did not return expected TRUE response');
 }
예제 #2
0
    if (isset($_POST["ibl_team"])) {
        $ibl_team = $_POST["ibl_team"];
    }
    if (isset($_POST["round"])) {
        $round = $_POST["round"];
    }
    if (isset($_POST["tig_name"])) {
        $tig_name = $_POST["tig_name"];
    }
    // Sanity checks for the data
    if ($id == 0 || $ibl_team == 'FA' || $round == "Undrafted") {
        print "You must submit the correct data to draft someone!";
        $task == "list";
    } else {
        $comments = "{$round} Round (" . YEAR . ")";
        $result = $roster->updatePlayerTeam($ibl_team, $id, $comments);
        if ($result) {
            print "<div align='center'>Assigned {$tig_name} to <b>{$ibl_team}</b></div><br><br>";
            // Add an entry to the transaction log
            transaction_log($ibl_team, "Drafts {$tig_name} {$comments}", $db);
            $task = "list";
        } else {
            print "<div align='center'>Couldn't update record for {$tig_name}.  Please try again later</div><br><br>";
            $task = "list";
        }
    }
}
if ($task == "list") {
    // Show a list of free agents to draft
    $tig_name = array();
    $tig_name = $roster->getByNickname('FA');
예제 #3
0
<?php

include 'DB.php';
include 'db_config.php';
$db = DB::connect(DSN);
// Process the incoming data that we got from our trade page
include './models/rosters.php';
$rosterModel = new Roster($db);
// Grab the data that's been posted into here
$team1 = filter_input(INPUT_POST, 'team1', FILTER_SANITIZE_ENCODED);
$team2 = filter_input(INPUT_POST, 'team2', FILTER_SANITIZE_ENCODED);
$data1 = filter_input(INPUT_POST, 'data1', FILTER_SANITIZE_ENCODED);
$data2 = filter_input(INPUT_POST, 'data2', FILTER_SANITIZE_ENCODED);
// Update roster entries with new updated teams
foreach ($data1 as $playerInfo) {
    list($dataSet, $playerId) = explode('_', $playerInfo);
    $rosterModel->updatePlayerTeam($team1, $playerId);
}
foreach ($data2 as $playerInfo) {
    list($dataSet, $playerId) = explode('_', $playerInfo);
    $rosterModel->updatePlayerTeam($team2, $playerId);
}