public function testFindByNickname()
 {
     $mapper = new \IBL\FranchiseMapper($this->_conn);
     $result = $mapper->findByNickname('MAD');
     $this->assertNotNull($result);
     $this->assertEquals('Monrovia Madness', $result->getName());
 }
 public function testSaveUpdatesDatabase()
 {
     $mapper = new \IBL\FranchiseMapper($this->_conn);
     $franchise = new \IBL\Franchise();
     $franchise->setId(25);
     $franchise->setNickname('TST');
     $franchise->setName('Test Team');
     $franchise->setConference('Conference');
     $franchise->setDivision('Division');
     $franchise->setIp(0);
     $mapper->save($franchise);
     // Update existing model
     $franchise->setIp(35);
     $mapper->save($franchise);
     // Reload Franchise record and compare them
     $franchise2 = $mapper->findById($franchise->getId());
     $this->assertEquals(35, $franchise2->getIp());
     // Clean up the franchise
     $mapper->delete($franchise);
 }
<?php

include 'test_bootstrap.php';
$conn = new PDO('pgsql:host=localhost;dbname=ibl_stats', 'stats', 'st@ts=Fun');
echo "Collecting all games in our season...\n";
$mapper = new \IBL\FranchiseMapper($conn);
$allFranchises = $mapper->findAll();
echo "Writing franchise objects into fixture file...\n";
file_put_contents('./fixtures/franchises.txt', serialize($allFranchises));
echo "Done\n";
<?php

include 'bootstrap.php';
// Load data that we will need for the front page
$gameMapper = new \IBL\GameMapper($container['db_connection']);
$franchiseMapper = new \IBL\FranchiseMapper($container['db_connection']);
$rotationMapper = new \IBL\RotationMapper($container['db_connection']);
$scheduleMapper = new \IBL\ScheduleMapper($container['db_connection']);
$games = $gameMapper->findAll();
$franchises = $franchiseMapper->findAll();
$standings = new \IBL\Standings($games, $franchises);
$regularStandings = $standings->generateRegular();
$currentWeek = $gameMapper->getCurrentWeek();
$currentResults = $gameMapper->generateResults($gameMapper->findByWeek($currentWeek), $franchises);
/**
 * If we don't have any rotations for the current week, make sure to grab
 * rotations for the previous week
 */
$rotations = $rotationMapper->findByWeek($currentWeek);
$rotationWeek = $currentWeek;
if (count($rotations) == 0) {
    $rotations = $rotationMapper->findByWeek($currentWeek - 1);
    $rotationWeek = $currentWeek - 1;
}
$currentRotations = $rotationMapper->generateRotations($rotations, $franchises);
/**
 * We need to use some intelligence in deciding what schedules we need to
 * show. If we have less than half the results in, show the schedule
 * from the previous week
 */
if (count($currentResults) < 12) {