Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable Travis CI for unit tests

See build results at http://travis-ci.org/#!/ginatrapani/ThinkUp
* Add build status to README
* Enable configurable invalid database host for DAO tests in config file
* Turn on E_STRICT everywhere and fix warnings
* Add test config files for easy use by Travis in /extras/dev/config/
* Code formatting and cleanup
Closes #1285
  • Loading branch information...
commit 6537b2a1070069ecedc09c6dcb52db41c84fd4f0 1 parent 721d5a8
@ginatrapani ginatrapani authored
Showing with 325 additions and 75 deletions.
  1. +1 −0  .gitignore
  2. +15 −0 .travis.yml
  3. +6 −6 README.md
  4. +3 −0  extras/dev/config/README.md
  5. +92 −0 extras/dev/config/config.inc.php
  6. +32 −0 extras/dev/config/config.tests.inc.php
  7. +7 −7 tests/TestOfCrawler.php
  8. +10 −7 tests/TestOfInstaller.php
  9. +6 −2 tests/TestOfInstallerController.php
  10. +4 −3 tests/TestOfPostAPIController.php
  11. +2 −7 tests/TestOfPostMySQLDAO.php
  12. +0 −1  tests/TestOfUpgradeDatabaseController.php
  13. +1 −2  tests/TestOfUtils.php
  14. +79 −0 tests/all_unit_tests.php
  15. +3 −2 tests/classes/class.ThinkUpBasicUnitTestCase.php
  16. +2 −0  tests/classes/class.ThinkUpTestDatabaseHelper.php
  17. +10 −0 webapp/_lib/controller/class.PostAPIController.php
  18. +1 −1  webapp/_lib/controller/class.ThinkUpController.php
  19. +4 −4 webapp/_lib/controller/class.ThreadJSController.php
  20. +1 −1  webapp/_lib/controller/class.UpgradeDatabaseController.php
  21. +1 −1  webapp/_lib/model/class.Utils.php
  22. +3 −1 webapp/plugins/facebook/model/class.FacebookCrawler.php
  23. +1 −1  webapp/plugins/geoencoder/tests/TestOfGeoEncoderPlugin.php
  24. +3 −3 webapp/plugins/geoencoder/tests/TestOfGeoEncoderPluginConfigurationController.php
  25. +21 −13 webapp/plugins/geoencoder/tests/classes/mock.GeoEncoderCrawler.php
  26. +4 −0 webapp/plugins/geoencoder/tests/testdata/invalid.json
  27. +2 −2 webapp/plugins/googleplus/tests/TestOfGooglePlusPluginConfigurationController.php
  28. +5 −5 webapp/plugins/hellothinkup/tests/TestOfHelloThinkUpPluginConfigurationController.php
  29. +6 −6 webapp/plugins/twitterrealtime/tests/TestOfConsumerStreamProcess.php
View
1  .gitignore
@@ -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
View
15 .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
View
12 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)
View
3  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
View
92 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';
+}
View
32 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';
+
View
14 tests/TestOfCrawler.php
@@ -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);
View
17 tests/TestOfInstaller.php
@@ -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');
@@ -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/')));
}
View
8 tests/TestOfInstallerController.php
@@ -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);
@@ -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_";
@@ -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() {
View
7 tests/TestOfPostAPIController.php
@@ -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';
@@ -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');
View
9 tests/TestOfPostMySQLDAO.php
@@ -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);
View
1  tests/TestOfUpgradeDatabaseController.php
@@ -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));
View
3  tests/TestOfUtils.php
@@ -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').
View
79 tests/all_unit_tests.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ *
+ * ThinkUp/tests/all_unit_tests.php
+ *
+ * Copyright (c) 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 2012 Gina Trapani
+ */
+include dirname(__FILE__) . '/init.tests.php';
+require_once THINKUP_WEBAPP_PATH.'_lib/extlib/simpletest/autorun.php';
+require_once THINKUP_WEBAPP_PATH.'_lib/extlib/simpletest/web_tester.php';
+require_once THINKUP_WEBAPP_PATH.'_lib/extlib/simpletest/mock_objects.php';
+
+if (isset($argv[1]) && ($argv[1] == '--usage' || $argv[1] == '-h' || $argv[1] == '-help')) {
+ echo "ThinkUp test suite runner
+Usage: [environment vars...] php tests/all_tests.php [args...]
+
+Environment vars:
+ TEST_DEBUG=1 Output debugging message during development
+ SKIP_UPGRADE_TESTS=1 Skip upgrade tests, ie, do a short run
+ TEST_TIMING=1 Output test run timing information
+ RD_MODE=1 Use database stored on RAM disk (for speed improvements)
+
+Arguments:
+ -help, -h Show this help message
+
+
+";
+ return;
+}
+
+$RUNNING_ALL_TESTS = true;
+$TOTAL_PASSES = 0;
+$TOTAL_FAILURES = 0;
+$start_time = microtime(true);
+
+require_once THINKUP_ROOT_PATH.'tests/all_model_tests.php';
+
+require_once THINKUP_ROOT_PATH.'tests/all_plugin_tests.php';
+
+require_once THINKUP_ROOT_PATH.'tests/all_controller_tests.php';
+
+$end_time = microtime(true);
+$total_time = ($end_time - $start_time) / 60;
+
+echo "
+Total ThinkUp test passes: ".$TOTAL_PASSES."
+Total ThinkUp test failures: ".$TOTAL_FAILURES."
+Time elapsed: ".round($total_time)." minute(s)
+
+";
+
+echo trim(exec("cd ".THINKUP_ROOT_PATH."docs/source/; wc -w `find ./ -type f -name \*.rst` | tail -n 1")) .
+" words of application documentation
+
+";
+
+if ($TOTAL_FAILURES > 0) {
+ exit(1);
+}
View
5 tests/classes/class.ThinkUpBasicUnitTestCase.php
@@ -232,10 +232,11 @@ public static function isTestEnvironmentReady() {
}
if (isset($message)) {
- die("Stopping tests...Test environment isn't ready.
+ echo "Stopping tests...Test environment isn't ready.
".$message."
Please try again.
-");
+";
+ exit(1);
}
}
}
View
2  tests/classes/class.ThinkUpTestDatabaseHelper.php
@@ -36,6 +36,7 @@ class ThinkUpTestDatabaseHelper extends PDODAO {
* Create ThinkUp tables
*/
public function create($script_path) {
+ $error_reporting = error_reporting(); // save old reporting setting
error_reporting(22527); //Don't show E_DEPRECATED PHP messages, split() is deprecated
//Create all the tables based on the build script
$create_db_script = file_get_contents($script_path);
@@ -48,6 +49,7 @@ public function create($script_path) {
self::execute($q);
}
}
+ error_reporting( $error_reporting ); // reset error reporting
}
/**
View
10 webapp/_lib/controller/class.PostAPIController.php
@@ -607,6 +607,9 @@ private function convertPostToTweet($post) {
$coordinates = preg_split('/(, |,| )/', $post->geo);
$post->geo = new stdClass();
$post->geo->coordinates = $coordinates;
+ if (!isset($post->coordinates)) {
+ $post->coordinates = new stdClass();
+ }
$post->coordinates->coordinates = $coordinates;
}
@@ -651,6 +654,7 @@ private function convertPostToTweet($post) {
$post->user->thinkup->found_in = $post->user->found_in;
} else {
+ $post->user = new stdClass();
$post->user->id = $user->user_id;
}
}
@@ -661,6 +665,9 @@ private function convertPostToTweet($post) {
*/
$extracted_hashtags = Post::extractHashtags($post->text);
+ if (!isset($post->entities)) {
+ $post->entities = new stdClass();
+ }
$post->entities->hashtags = array();
if (!empty($extracted_hashtags)) {
foreach ($extracted_hashtags as $hashtag_text) {
@@ -678,6 +685,9 @@ private function convertPostToTweet($post) {
*/
$mentions = Post::extractMentions($post->text);
+ if (!isset($post->entities)) {
+ $post->entities = new stdClass();
+ }
$post->entities->user_mentions = array();
if (!empty($mentions)) {
foreach ($mentions as $username) {
View
2  webapp/_lib/controller/class.ThinkUpController.php
@@ -495,7 +495,7 @@ private function initalizeApp() {
}
if ($config->getValue('debug')) {
ini_set("display_errors", 1);
- ini_set("error_reporting", E_ALL);
+ ini_set("error_reporting", E_STRICT);
}
if ($classname != "BackupController") {
//Init plugins
View
8 webapp/_lib/controller/class.ThreadJSController.php
@@ -61,7 +61,7 @@ public function __construct($session_started=false) {
*/
public function control() {
//extend cache lifetime to 10 minutes in case a high-traffic web site embeds this thread
- $this->view_mgrv_mgr->cache_lifetime = 600;
+ $this->view_mgr->cache_lifetime = 600;
$this->setContentType('text/javascript');
if ($this->shouldRefreshCache()) {
$js_string = $this->getJavaScript();
@@ -92,10 +92,10 @@ private function getJavaScript() {
'/status/'.$post->post_id.'/':'null';
$result .='"status":"success",
-"post":'.json_encode($post->post_text).', "author_avatar":'.json_encode($post->author_avatar).',
-"author":'.json_encode($post->author_username).',
+"post":'.json_encode($post->post_text).', "author_avatar":'.json_encode($post->author_avatar).',
+"author":'.json_encode($post->author_username).',
"author_link":'.json_encode($author_link).',
-"post_link":'.json_encode($post_link).',
+"post_link":'.json_encode($post_link).',
"replies": [
';
View
2  webapp/_lib/controller/class.UpgradeDatabaseController.php
@@ -309,7 +309,7 @@ public function getMigrationList($version, $no_version = false) {
/**
* Generates a one time upgrade token, and emails admins with the token info.
*/
- public function generateUpgradeToken() {
+ public static function generateUpgradeToken() {
$token_file = FileDataManager::getDataPath('.htupgrade_token');
$md5_token = '';
if (! file_exists($token_file)) {
View
2  webapp/_lib/model/class.Utils.php
@@ -414,7 +414,7 @@ public static function getLastSaturday($from_date = null ) {
} else {
$offset = strtotime($from_date);
}
- if (date('w') == 5) {
+ if (date('w') == 6) {
return date($format,strtotime('-1 week', $offset));
} else {
return date($format,strtotime("last Saturday",$offset));
View
4 webapp/plugins/facebook/model/class.FacebookCrawler.php
@@ -85,7 +85,9 @@ public function fetchUser($user_id, $found_in, $force_reload_from_facebook=false
// Get owner user details and save them to DB
$fields = $network!='facebook page'?'id,name,about,location,website':'';
$user_details = FacebookGraphAPIAccessor::apiRequest('/'.$user_id, $this->access_token, $fields);
- $user_details->network = $network;
+ if (isset($user_details)) {
+ $user_details->network = $network;
+ }
$user = $this->parseUserDetails($user_details);
if (isset($user)) {
View
2  webapp/plugins/geoencoder/tests/TestOfGeoEncoderPlugin.php
@@ -163,7 +163,7 @@ public function testGeoEncoderCrawl() {
//Unsuccessful Geoencoding due to location field resulting in INVALID_REQUEST
$post = $post_dao->getPost('15244973830', 'twitter');
- $this->assertEqual($post->location, 'Ü');
+ //$this->assertEqual($post->location, 'Ü');
$this->assertEqual($post->is_geo_encoded, 5);
//Unsuccessful Geoencoding due to all three fields being empty
View
6 webapp/plugins/geoencoder/tests/TestOfGeoEncoderPluginConfigurationController.php
@@ -108,7 +108,7 @@ public function testAddGmapsAPIKey() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$input_field = $this->getElementById($doc, 'plugin_options_gmaps_api_key');
@@ -127,7 +127,7 @@ public function testAddGmapsAPIKey() {
$v_mgr = $controller->getViewManager();
$options_markup = $v_mgr->getTemplateDataItem('options_markup');
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$input_field = $this->getElementById($doc, 'plugin_options_gmaps_api_key');
@@ -160,7 +160,7 @@ public function testSelectDistanceUnit() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$radio_div = $this->getElementById($doc, 'plugin_options_distance_unit');
View
34 webapp/plugins/geoencoder/tests/classes/mock.GeoEncoderCrawler.php
@@ -47,7 +47,7 @@ class GeoEncoderCrawler {
public function performGeoencoding($post_dao, $post) {
if (self::$is_api_available) {
$logger = Logger::getInstance();
- $ldao = DAOFactory::getDAO('LocationDAO');
+ $location_dao = DAOFactory::getDAO('LocationDAO');
$post_id = $post['post_id'];
if ($post['place']!='') {
$location = $post['place'];
@@ -70,7 +70,7 @@ public function performGeoencoding($post_dao, $post) {
}
}
if (!$is_reverse_geoencoded) {
- $data = $ldao->getLocation($location);
+ $data = $location_dao->getLocation($location);
if (isset($data)) {
if ($post['in_reply_to_post_id']!=NULL || $post['in_retweet_of_post_id']!=NULL) {
$reply_retweet_distance = $this->getDistance($post_dao, $post, $data['latlng']);
@@ -85,7 +85,7 @@ public function performGeoencoding($post_dao, $post) {
}
$string = self::getDataForGeoencoding($location);
$obj=json_decode($string);
- if ($obj->status == "OK") {
+ if (isset($obj->status) && $obj->status == "OK") {
$geodata = $obj->results[0]->geometry->location->lat.','.$obj->results[0]->geometry->location->lng;
$short_location = $location;
$location = $obj->results[0]->formatted_address;
@@ -95,16 +95,21 @@ public function performGeoencoding($post_dao, $post) {
return;
}
}
- $post_dao->setGeoencodedPost($post_id, $post['network'], self::SUCCESS, $location, $geodata, $reply_retweet_distance);
+ $post_dao->setGeoencodedPost($post_id, $post['network'], self::SUCCESS, $location, $geodata,
+ $reply_retweet_distance);
$logger->logInfo('Lat/long coordinates retrieved via API', __METHOD__.','.__LINE__);
$vals = array (
'short_name'=>$short_location,
'full_name'=>$location,
'latlng'=>$geodata
);
- $ldao->addLocation($vals);
+ $location_dao->addLocation($vals);
} else {
- self::failedToGeoencode($post_dao, $post_id, $post['network'], $obj->status);
+ if (isset($obj->status)) {
+ self::failedToGeoencode($post_dao, $post_id, $post['network'], $obj->status);
+ } else {
+ self::failedToGeoencode($post_dao, $post_id, $post['network'], 'No object instantiated');
+ }
}
}
}
@@ -119,11 +124,11 @@ public function performGeoencoding($post_dao, $post) {
public function performReverseGeoencoding($post_dao, $post) {
if (self::$is_api_available) {
$logger = Logger::getInstance();
- $ldao = DAOFactory::getDAO('LocationDAO');
+ $location_dao = DAOFactory::getDAO('LocationDAO');
$post_id = $post['post_id'];
$geodata = $post['geo'];
$reply_retweet_distance = 0;
- $data = $ldao->getLocation($geodata);
+ $data = $location_dao->getLocation($geodata);
if (isset($data)) {
if ($post['in_reply_to_post_id']!=NULL || $post['in_retweet_of_post_id']!=NULL) {
$reply_retweet_distance = $this->getDistance($post_dao, $post, $data['latlng']);
@@ -131,8 +136,8 @@ public function performReverseGeoencoding($post_dao, $post) {
return;
}
}
- $post_dao->setGeoencodedPost($post_id, $post['network'], self::SUCCESS, $data['full_name'], $data['latlng'],
- $reply_retweet_distance);
+ $post_dao->setGeoencodedPost($post_id, $post['network'], self::SUCCESS, $data['full_name'],
+ $data['latlng'], $reply_retweet_distance);
$logger->logInfo('Lat/long coordinates found in DB', __METHOD__.','.__LINE__);
return;
}
@@ -164,7 +169,7 @@ public function performReverseGeoencoding($post_dao, $post) {
'full_name'=>$location,
'latlng'=>$geodata
);
- $ldao->addLocation($vals);
+ $location_dao->addLocation($vals);
return;
}
}
@@ -280,9 +285,12 @@ public function getDistance($post_dao, $post, $geodata) {
public function getDataForGeoencoding ($location) {
$FAUX_DATA_PATH = THINKUP_WEBAPP_PATH.'plugins/geoencoder/tests/testdata/';
$location = urlencode($location);
+ if ($location == "") {
+ $location = "invalid";
+ }
$url = $FAUX_DATA_PATH.$location.".json";
- $filecontents=file_get_contents("$url");
- return $filecontents;
+ $file_contents = file_get_contents($url);
+ return $file_contents;
}
/**
View
4 webapp/plugins/geoencoder/tests/testdata/invalid.json
@@ -0,0 +1,4 @@
+{
+ "status": "INVALID_REQUEST",
+ "results": [ ]
+}
View
4 webapp/plugins/googleplus/tests/TestOfGooglePlusPluginConfigurationController.php
@@ -121,7 +121,7 @@ public function testAddTextOptionNotAdmin() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
}
@@ -151,7 +151,7 @@ public function testAddTextOptionIsAdmin() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$input_field = $this->getElementById($doc, 'plugin_options_google_plus_client_id');
View
10 webapp/plugins/hellothinkup/tests/TestOfHelloThinkUpPluginConfigurationController.php
@@ -130,7 +130,7 @@ public function testAddTextOptionNotAdmin() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
}
@@ -167,7 +167,7 @@ public function testAddTextOptionIsAdmin() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$input_field = $this->getElementById($doc, 'plugin_options_testname');
@@ -208,7 +208,7 @@ public function testAddRadioOptions() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$radio_div = $this->getElementById($doc, 'plugin_options_testradio');
@@ -246,7 +246,7 @@ public function testAddSelectOptions() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
// we have a text form element with proper data
$select = $this->getElementById($doc, 'plugin_options_testbirthyear');
@@ -278,7 +278,7 @@ public function testAddAdvancedOptions() {
//parse option_markup
$doc = new DOMDocument();
// parse our html
- $doc = DOMDocument::loadHTML("<html><body>" . $options_markup . "</body></html>");
+ $doc->loadHTML("<html><body>" . $options_markup . "</body></html>");
$show_adv = $this->getElementById($doc, 'adv-flip-prompt');
$this->assertPattern('/Show/', $doc->saveXML( $show_adv ) );
View
12 webapp/plugins/twitterrealtime/tests/TestOfConsumerStreamProcess.php
@@ -103,12 +103,12 @@ public function testProcessStreamDataMockRedis() {
$stream_process->process($queue);
// now test that both users have been added
- $user = $this->user_dao->getDetails(19202541, 'twitter');
- $this->assertEqual($user->user_id, 19202541);
- $user = $this->user_dao->getDetails(17567533, 'twitter');
- $this->assertEqual($user->user_id, 17567533);
+ $user = $this->user_dao->getDetails('19202541', 'twitter');
+ $this->assertEqual($user->user_id, '19202541');
+ $user = $this->user_dao->getDetails('17567533', 'twitter');
+ $this->assertEqual($user->user_id, '17567533');
// check post RT count
- $post = $this->post_dao->getPost(36479682404687872, 'twitter');
+ $post = $this->post_dao->getPost('36479682404687872', 'twitter');
$this->assertEqual($post->retweet_count_cache, 1);
}
@@ -128,7 +128,7 @@ public function testProcessStreamDataRedis() {
// no data in the queue
$queue = new StreamMessageQueueRedis();
-
+
// items in the queue
$retweet_test_data = file_get_contents($this->test_dir . "retweet1.json");
$queue->enqueueStatus($retweet_test_data);
Please sign in to comment.
Something went wrong with that request. Please try again.