Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (68 sloc) 3.01 KB
<?php
/**
*
* ThinkUp/tests/TestOfFollowerCountMySQLDAO.php
*
* Copyright (c) 2009-2010 Gina Trapani
*
* LICENSE:
*
* This file is part of ThinkUp (http://thinkupapp.com).
*
* ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
* later version.
*
* ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with ThinkUp. If not, see
* <http://www.gnu.org/licenses/>.
*
*
* @author Gina Trapani <ginatrapani[at]gmail[dot]com>
* @license http://www.gnu.org/licenses/gpl.html
* @copyright 2009-2010 Gina Trapani
*/
require_once dirname(__FILE__).'/init.tests.php';
require_once THINKUP_ROOT_PATH.'webapp/_lib/extlib/simpletest/autorun.php';
require_once THINKUP_ROOT_PATH.'webapp/config.inc.php';
class TestOfFollowerCountMySQLDAO extends ThinkUpUnitTestCase {
public function __construct() {
$this->UnitTestCase('FollowerCountMySQLDAO class test');
}
public function setUp() {
parent::setUp();
}
public function tearDown() {
parent::tearDown();
}
public function testConstructor() {
$dao = new FollowerCountMySQLDAO();
$this->assertTrue(isset($dao));
}
public function testInsert() {
$dao = new FollowerCountMySQLDAO();
$result = $dao->insert(930061, 'twitter', 1001);
$this->assertEqual($result, 1, 'One count inserted');
}
public function testGetHistory() {
$follower_count = array('network_user_id'=>930061, 'network'=>'twitter', 'date'=>'-1d', 'count'=>140);
$builder1 = FixtureBuilder::build('follower_count', $follower_count);
$follower_count = array('network_user_id'=>930061, 'network'=>'twitter', 'date'=>'-2d', 'count'=>100);
$builder2 = FixtureBuilder::build('follower_count', $follower_count);
$follower_count = array('network_user_id'=>930061, 'network'=>'twitter', 'date'=>'-3d', 'count'=>120);
$builder3 = FixtureBuilder::build('follower_count', $follower_count);
$dao = new FollowerCountMySQLDAO();
$result = $dao->getHistory(930061, 'twitter', 'DAY');
$this->assertEqual(sizeof($result), 3, '3 sets of data returned--history, percentages, Y axis');
$this->assertEqual(sizeof($result['history']), 3, '3 counts returned');
$this->assertEqual(sizeof($result['percentages']), 3, '3 percentages returned');
$this->assertEqual(sizeof($result['y_axis']), 4, '4 Y axis points returned');
$this->assertEqual($result['y_axis'][0], 100);
$this->assertEqual($result['y_axis'][1], 110);
$this->assertEqual($result['y_axis'][2], 120);
$this->assertEqual($result['y_axis'][3], 140);
}
}
Something went wrong with that request. Please try again.