Skip to content

Commit

Permalink
Enable Travis CI for unit tests
Browse files Browse the repository at this point in the history
See build results at http://travis-ci.org/#!/ginatrapani/ThinkUp
* Turn on E_STRICT everywhere and fix warnings
[ci skip]
  • Loading branch information
ginatrapani committed Apr 20, 2012
1 parent 721d5a8 commit 1710a2a
Show file tree
Hide file tree
Showing 29 changed files with 325 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,6 +5,7 @@ data/
!webapp/data/README.md
tests/config.tests.inc.php
.*
!.travis.yml
extras/cron/config
extras/scripts/autodeploy-conf
extras/scripts/migratedb-conf
Expand Down
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
language: php
php:
- 5.3
- 5.2

before_script:
- mysql -e 'create database thinkup'
- cp extras/dev/config/config.inc.php webapp/config.inc.php
- cp extras/dev/config/config.tests.inc.php tests/config.tests.inc.php
- chmod -R 777 webapp/data
- mkdir webapp/data/logs/
- touch webapp/data/logs/stream.log
- touch webapp/data/logs/crawler.log

script: php tests/all_unit_tests.php
12 changes: 6 additions & 6 deletions README.md
@@ -1,21 +1,21 @@
# ThinkUp, social media insights engine
# ThinkUp, social media insights engine [![Build Status](https://secure.travis-ci.org/ginatrapani/ThinkUp.png)](http://travis-ci.org/ginatrapani/ThinkUp)

ThinkUp is a free, installable web application that captures the insights and expertise of your social network by
collecting and organizing replies to your conversations on Twitter, Facebook and (soon!) other networks.
organizing replies to your conversations on Twitter, Facebook, Google+ and (soon!) other networks.
Find out more at [http://thinkupapp.com](http://thinkupapp.com)

## SUPPORT AND DOCUMENTATION
## Support and Documentation

Refer to [ThinkUp's documentation](http://thinkupapp.com/docs/), or contact the ThinkUp community on the
[project mailing list](http://groups.google.com/group/thinkupapp) for support.

## LICENSE
## License

ThinkUp's source code is licensed under the
[GNU General Public License](http://www.gnu.org/licenses/gpl.html),
except for the external libraries listed below.
except for the external libraries listed below.

## EXTERNAL LIBRARIES
## External Libraries

- [Facebook Platform PHP5 SDK](https://github.com/facebook/php-sdk) (Included)
- [SimpleTest](http://www.simpletest.org/) (Included)
Expand Down
3 changes: 3 additions & 0 deletions extras/dev/config/README.md
@@ -0,0 +1,3 @@
# Sample Config Files

This directory contains basic model developer config files for use on Travis CI http://travis-ci.org/ginatrapani/ThinkUp
92 changes: 92 additions & 0 deletions extras/dev/config/config.inc.php
@@ -0,0 +1,92 @@
<?php
/************************************************/
/*** APPLICATION CONFIG ***/
/************************************************/

// Application title prefix - 'ThinkUp' will be appended to it in page titles
$THINKUP_CFG['app_title_prefix'] = '';

// Public path of thinkup's /webapp/ folder on your web server.
// For example, if the /webapp/ folder is located at http://yourdomain/thinkup/, set to '/thinkup/'.
$THINKUP_CFG['site_root_path'] = '/';

// Server path to /thinkup/ source code folder, dirname( __FILE__ ) . '/'; by default
$THINKUP_CFG['source_root_path'] = dirname(dirname( __FILE__ )) . '/';

// Server path to writable data directory, $THINKUP_CFG['source_root_path'] . 'data/' by default
$THINKUP_CFG['datadir_path'] = $THINKUP_CFG['source_root_path'] . 'webapp/data/';

// Your timezone
$THINKUP_CFG['timezone'] = 'America/Los_Angeles';

// Toggle Smarty caching. true: Smarty caching on, false: Smarty caching off
$THINKUP_CFG['cache_pages'] = false;

// Smarty file cache lifetime in seconds; defaults to 600 (10 minutes)caching
$THINKUP_CFG['cache_lifetime'] = 600;

// The crawler, when triggered by requests to the RSS feed, will only launch if it's been
// 20 minutes or more since the last crawl.
$THINKUP_CFG['rss_crawler_refresh_rate'] = 20;

/************************************************/
/*** DATABASE CONFIG ***/
/************************************************/

$THINKUP_CFG['db_host'] = 'localhost'; //On a shared host? Try mysql.yourdomain.com, or see your web host's documentation.
$THINKUP_CFG['db_type'] = 'mysql';
$THINKUP_CFG['db_user'] = 'root';
$THINKUP_CFG['db_password'] = '';
$THINKUP_CFG['db_name'] = 'thinkup';
$THINKUP_CFG['db_socket'] = '';
$THINKUP_CFG['db_port'] = '';
$THINKUP_CFG['table_prefix'] = 'tu_';

/************************************************/
/*** DEVELOPER CONFIG ***/
/************************************************/

// Full server path to crawler.log.
$THINKUP_CFG['log_location'] = $THINKUP_CFG['datadir_path'] . '/logs/crawler.log';
//$THINKUP_CFG['log_location'] = false;

// Verbosity of log. 0 is everything, 1 is user messages, 2 is errors only
$THINKUP_CFG['log_verbosity'] = 0;

// Full server path to stream processor log.
$THINKUP_CFG['stream_log_location'] = $THINKUP_CFG['datadir_path'] . '/logs/stream.log';
//$THINKUP_CFG['stream_log_location'] = false;

// Full server path to sql.log. To not log queries, set to null.
// $THINKUP_CFG['sql_log_location'] = $THINKUP_CFG['datadir_path'] . '/logs/sql.log';
$THINKUP_CFG['sql_log_location'] = null;

// How many seconds does a query take before it gets logged as a slow query?
$THINKUP_CFG['slow_query_log_threshold'] = 2.0;

$THINKUP_CFG['debug'] = true;

$THINKUP_CFG['enable_profiler'] = false;

// Set this to true if you want your PDO object's database connection's charset to be explicitly set to utf8.
// If false (or unset), the database connection's charset will not be explicitly set.
$THINKUP_CFG['set_pdo_charset'] = false;

//TESTS OVERRIDE: Run against the tests database and use unpackaged developer /thinkup/webapp/ folder structure
if ((isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS") && ! isset($_SESSION["RD_MODE"])
|| (getenv("MODE")=="TESTS" && ! getenv("RD_MODE")=="1")) {
// Full server path to /thinkup/ source code folder.
// $THINKUP_CFG['source_root_path'] = '/your-server-path-to/thinkup/';
// $THINKUP_CFG['db_user'] = 'your_test_database_username';
// $THINKUP_CFG['db_password'] = 'your_test_database_password';
// $THINKUP_CFG['db_name'] = 'your_test_database_name'; //by default, thinkup_tests
$THINKUP_CFG['invalid_db_host'] = 'localcheese';
ini_set('error_reporting', E_STRICT);
}

//Test RAM disk database override: Set this to run tests against the RAM disk tests database
if (isset($_SESSION["RD_MODE"]) || getenv("RD_MODE")=="1") {
$THINKUP_CFG['db_user'] = 'your_ram_disk_test_database_username';
$THINKUP_CFG['db_password'] = 'your_ram_disk_test_database_password';
$THINKUP_CFG['db_name'] = $THINKUP_CFG['db_name'] . '_rd';
}
32 changes: 32 additions & 0 deletions extras/dev/config/config.tests.inc.php
@@ -0,0 +1,32 @@
<?php
/**
*
* ThinkUp/tests/config.tests.sample.inc.php
*
* Copyright (c) 2009-2012 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-2012 Gina Trapani
*/

$TEST_SERVER_DOMAIN = 'http://localhost';

$TEST_DATABASE = 'thinkup';

14 changes: 7 additions & 7 deletions tests/TestOfCrawler.php
Expand Up @@ -115,16 +115,16 @@ public function testCrawlUpgrading() {

private function buildData() {
$admin_owner_builder = FixtureBuilder::build('owners', array(
'id' => 1,
'email' => 'admin@example.com',
'pwd' => 'XXX',
'is_activated' => 1,
'id' => 1,
'email' => 'admin@example.com',
'pwd' => 'XXX',
'is_activated' => 1,
'is_admin' => 1
));
$owner_builder = FixtureBuilder::build('owners', array(
'id' => 2,
'email' => 'me@example.com',
'pwd' => 'XXX',
'id' => 2,
'email' => 'me@example.com',
'pwd' => 'XXX',
'is_activated' => 1
));
return array($admin_owner_builder, $owner_builder);
Expand Down
17 changes: 10 additions & 7 deletions tests/TestOfInstaller.php
Expand Up @@ -68,17 +68,18 @@ public function testGetInstallerInstance() {
public function testInstallerCheckVersion() {
$this->debug("Running testInstallerCheckVersion");
$installer = Installer::getInstance();
$this->assertTrue(Installer::checkVersion());
$this->assertFalse(Installer::checkVersion('4'));
$this->assertTrue($installer->checkVersion());
$this->assertFalse($installer->checkVersion('4'));

$ver = Installer::getRequiredVersion();
$ver = $installer->getRequiredVersion();
$ver = $ver['php'] + 0.1;

$this->assertTrue(Installer::checkVersion($ver));
$this->assertTrue($installer->checkVersion($ver));
}

public function testInstallerCheckDependency() {
$dependency = Installer::checkDependency();
$installer = Installer::getInstance();
$dependency = $installer->checkDependency();
$this->assertTrue($dependency['curl'], 'cURL is installed');
$this->assertTrue($dependency['gd'], 'gd lib is installed');
$this->assertTrue($dependency['pdo'], 'pdo lib is installed');
Expand All @@ -89,13 +90,15 @@ public function testInstallerCheckDependency() {
}

public function testInstallerCheckPermission() {
$perms = Installer::checkPermission();
$installer = Installer::getInstance();
$perms = $installer->checkPermission();
$this->assertTrue($perms['data_dir']);
$this->assertTrue($perms['cache']);
}

public function testInstallerCheckPath() {
$this->assertTrue(Installer::checkPath(array('source_root_path' => THINKUP_ROOT_PATH,
$installer = Installer::getInstance();
$this->assertTrue($installer->checkPath(array('source_root_path' => THINKUP_ROOT_PATH,
'smarty_path' => THINKUP_WEBAPP_PATH . '_lib/extlib/Smarty-2.6.26/libs/')));
}

Expand Down
8 changes: 6 additions & 2 deletions tests/TestOfInstallerController.php
Expand Up @@ -472,6 +472,10 @@ public function testFreshInstallStep3InvalidDatabaseHost() {
$valid_db_user = $config->getValue('db_user');
$valid_db_password = $config->getvalue('db_password');
$valid_db_port = $config->getValue('db_port');
$invalid_db_host = $config->getValue('invalid_db_host');
if (!isset($invalid_db_host)) {
$invalid_db_host = "127.0.0.2";
}

//drop DB
$this->testdb_helper->drop($this->test_database_name);
Expand All @@ -491,7 +495,7 @@ public function testFreshInstallStep3InvalidDatabaseHost() {
$_POST['db_passwd'] = $valid_db_password;
$_POST['db_name'] = "mythinkupdb";
$_POST['db_type'] = "mysql";
$_POST['db_host'] = "127.0.0.2";
$_POST['db_host'] = $invalid_db_host;
$_POST['db_socket'] = $valid_db_socket;
$_POST['db_port'] = $valid_db_port;
$_POST['db_prefix'] = "tu_";
Expand All @@ -511,7 +515,7 @@ public function testFreshInstallStep3InvalidDatabaseHost() {
//$this->assertPattern('/Unknown MySQL server host \'localcheese\'/', $result);
//$this->assertPattern('/php_network_getaddresses: getaddrinfo failed', $result);
$this->restoreConfigFile();
ini_set("error_reporting", E_ALL);
ini_set("error_reporting", E_STRICT);
}

public function testFreshInstallStep3SuccessfulInstall() {
Expand Down
7 changes: 4 additions & 3 deletions tests/TestOfPostAPIController.php
Expand Up @@ -742,6 +742,8 @@ protected static function buildData() {
}

public function testPost() {
$config = Config::getInstance();
$config->setValue('timezone', 'America/Los_Angeles');
$_GET['type'] = 'post';
$_GET['post_id'] = '137';
$_GET['network'] = 'twitter';
Expand All @@ -755,15 +757,14 @@ public function testPost() {
$this->assertEqual($output->protected, false);

// test that the correct tweet was retrieved
$this->assertEqual($output->id, 137, "Incorrect post fetched.");
$this->assertEqual($output->id, '137', "Incorrect post fetched.");

$this->assertEqual(sizeof($output->coordinates->coordinates), 2,
"Size of coordinates is too big or too small. Is " . sizeof($output->coordinates->coordinates) .
" when it should be 2.");

$this->assertEqual($output->thinkup->is_geo_encoded, 1);
$this->assertEqual($output->coordinates, $output->geo,
"Geo and coordinates are meant to be exactly the same.");
$this->assertEqual($output->coordinates, $output->geo, "Geo and coordinates are meant to be exactly the same.");

if (self::isTimeZoneSupported()) { //account for Daylight Saving Time
$this->assertEqual($output->user->last_updated, '2010-03-02 12:45:55');
Expand Down
9 changes: 2 additions & 7 deletions tests/TestOfPostMySQLDAO.php
Expand Up @@ -1889,13 +1889,8 @@ public function testGetMostRepliedToPostsInLastWeek() {
$pdao = new PostMySQLDAO();
$posts = $pdao->getMostRepliedToPostsInLastWeek('user3', 'twitter', 5);
$this->assertEqual(sizeof($posts), 5);
if (self::isTimeZoneSupported()) { //account for Daylight Saving Time
$this->assertEqual($posts[0]->reply_count_cache, 6);
$this->assertEqual($posts[1]->reply_count_cache, 5);
} else {
$this->assertEqual($posts[0]->reply_count_cache, 7);
$this->assertEqual($posts[1]->reply_count_cache, 6);
}
$this->assertEqual($posts[0]->reply_count_cache, 7);
$this->assertEqual($posts[1]->reply_count_cache, 6);

$posts = $pdao->getMostRepliedToPostsInLastWeek('user2', 'twitter', 5);
$this->assertEqual(sizeof($posts), 0);
Expand Down
1 change: 0 additions & 1 deletion tests/TestOfUpgradeDatabaseController.php
Expand Up @@ -382,7 +382,6 @@ public function testRunNewMigrationUpdateCompletedTable() {

public function testGenerateUpgradeToken() {
$this->simulateLogin('me@example.com');
$controller = new UpgradeDatabaseController(true);
UpgradeDatabaseController::generateUpgradeToken();
$this->assertTrue( file_exists($this->token_file) );
$this->assertPattern('/^[\da-f]{32}$/', file_get_contents($this->token_file));
Expand Down
3 changes: 1 addition & 2 deletions tests/TestOfUtils.php
Expand Up @@ -35,8 +35,7 @@ class TestOfUtils extends ThinkUpBasicUnitTestCase {
public function testgetPluginViewDirectory() {
$config = Config::getInstance();
$path = Utils::getPluginViewDirectory('twitter');
$this->assertEqual(realpath($path), realpath($config->getValue('source_root_path').
'/webapp/plugins/twitter/view/'));
$this->assertEqual(realpath($path), realpath(THINKUP_WEBAPP_PATH.'plugins/twitter/view'));

$path = Utils::getPluginViewDirectory('sweetmaryjane');
$this->assertEqual(realpath($path), realpath($config->getValue('source_root_path').
Expand Down

0 comments on commit 1710a2a

Please sign in to comment.