diff --git a/extras/scripts/migratedb b/extras/scripts/migratedb index 5624e49a0e..ea6c60f94a 100755 --- a/extras/scripts/migratedb +++ b/extras/scripts/migratedb @@ -51,6 +51,9 @@ VALUES ('Twitter', 'twitter', 'Twitter support', 'Gina Trapani', 'http://thinkup INSERT INTO tu_plugins (name , folder_name, description, author, homepage, version, is_active ) VALUES ('Facebook', 'facebook', 'Facebook support', 'Gina Trapani', 'http://thinkupapp.com', '0.01', '1'); +INSERT INTO tu_plugins (name , folder_name, description, author, homepage, version, is_active ) +VALUES ('Foursquare', 'foursquare', 'Foursquare support', 'Aaron Kalair', 'http://thinkupapp.com', '0.01', '1'); + INSERT INTO tu_plugins (name , folder_name, description, author, homepage, version, is_active ) VALUES ('Google+', 'googleplus', 'Google+ support', 'Gina Trapani', 'http://thinkupapp.com', '0.01', '1'); diff --git a/tests/TestOfPluginMySQLDAO.php b/tests/TestOfPluginMySQLDAO.php index c4479309aa..aa4f1350d4 100644 --- a/tests/TestOfPluginMySQLDAO.php +++ b/tests/TestOfPluginMySQLDAO.php @@ -89,7 +89,7 @@ public function testGetInstalledPlugins() { $this->assertEqual($plugins[7]->folder_name,"twitterrealtime"); } - public function testInsertPugin() { + public function testInsertPlugin() { // build our data $builders_array = $this->buildData(); // init our dao @@ -147,7 +147,7 @@ public function testInsertPugin() { $plugin = $this->createPlugin(); $plugin->name = 'has no home page'; $plugin->homepage = null; - $this->assertEqual($dao->insertPlugin($plugin), 8); + $this->assertEqual($dao->insertPlugin($plugin), 9); $sql = "select * from " . $this->table_prefix . 'plugins where name = "' . $plugin->name . '"'; $stmt = PluginMySQLDAO::$PDO->query($sql); $data = $stmt->fetch(); @@ -157,7 +157,7 @@ public function testInsertPugin() { $plugin = $this->createPlugin(array('is_active' => false)); $plugin->name = 'not active'; $plugin->homepage = null; - $this->assertEqual($dao->insertPlugin($plugin), 9); + $this->assertEqual($dao->insertPlugin($plugin), 10); $sql = "select * from " . $this->table_prefix . 'plugins where name = "' . $plugin->name . '"'; $stmt = PluginMySQLDAO::$PDO->query($sql); $data = $stmt->fetch(); @@ -303,7 +303,7 @@ public function testIsPluginActive() { $this->assertFalse($dao->isPluginActive(15)); } - public function testGetPluginId() { + public function testGetPluginID() { // build our data $builders_array = $this->buildData(); // init our dao @@ -311,7 +311,7 @@ public function testGetPluginId() { $this->assertEqual($dao->getPluginId('twitter'), 1); $this->assertEqual($dao->getPluginId('idontexist'), null); - $this->assertEqual($dao->getPluginId('testpluginact'), 6); + $this->assertEqual($dao->getPluginId('testpluginact'), 7); } public function testGetPluginFolder() { @@ -322,7 +322,7 @@ public function testGetPluginFolder() { $this->assertEqual($dao->getPluginFolder(1), 'twitter'); $this->assertEqual($dao->getPluginFolder(99), null); - $this->assertEqual($dao->getPluginFolder(6), 'testpluginact'); + $this->assertEqual($dao->getPluginFolder(7), 'testpluginact'); } public function testGetAllPlugins() { @@ -332,9 +332,9 @@ public function testGetAllPlugins() { $dao = new PluginMySQLDAO(); $plugins = $dao->getAllPlugins(); - $this->assertEqual(count($plugins), 6); - $this->assertEqual($plugins[4]->name, "My Test Plugin"); - $this->assertEqual($plugins[4]->folder_name, "testplugin"); + $this->assertEqual(count($plugins), 7); + $this->assertEqual($plugins[5]->name, "My Test Plugin"); + $this->assertEqual($plugins[5]->folder_name, "testplugin"); // no plugins? $builders_array = null; @@ -348,7 +348,7 @@ public function testGetActivePlugins() { $dao = new PluginMySQLDAO(); $plugins = $dao->getActivePlugins(); - $this->assertEqual(count($plugins), 5); + $this->assertEqual(count($plugins), 6); $this->assertEqual($plugins[0]->name,"Twitter"); $this->assertEqual($plugins[0]->folder_name,"twitter"); diff --git a/tests/TestOfPluginOptionController.php b/tests/TestOfPluginOptionController.php index 768f4bac3a..27b5715165 100644 --- a/tests/TestOfPluginOptionController.php +++ b/tests/TestOfPluginOptionController.php @@ -188,7 +188,7 @@ public function testSavePluginOption() { $this->assertEqual($json_response->results->inserted->test1, 3); $this->assertEqual($json_response->results->inserted->test2, 4); - $sql = "select * from " . $this->table_prefix . 'options where namespace = \'plugin_options-5\''; + $sql = "select * from " . $this->table_prefix . 'options where namespace = \'plugin_options-6\''; $stmt = $this->pdo->query($sql); $this->assertEqual($stmt->rowCount(), 3); for($i = 0; $i < 3; $i++) { @@ -228,7 +228,7 @@ public function testSavePluginOptionWithWhitespace() { $this->assertEqual($json_response->results->inserted->test1, 3); $this->assertEqual($json_response->results->inserted->test2, 4); - $sql = "select * from " . $this->table_prefix . 'options where namespace = \'plugin_options-5\''; + $sql = "select * from " . $this->table_prefix . 'options where namespace = \'plugin_options-6\''; $stmt = $this->pdo->query($sql); $this->assertEqual($stmt->rowCount(), 3); for($i = 0; $i < 3; $i++) { @@ -287,7 +287,7 @@ public function testUpdatePluginOption() { $this->assertEqual($json_response->status, 'success'); $this->assertEqual($json_response->results->updated, 2); - $sql = "select * from " . $this->table_prefix . "options where namespace = 'plugin_options-5'"; + $sql = "select * from " . $this->table_prefix . "options where namespace = 'plugin_options-6'"; $stmt = $this->pdo->query($sql); $this->assertEqual($stmt->rowCount(), 3); for($i = 0; $i < 3; $i++) { @@ -353,7 +353,7 @@ public function testUpdateDeletePluginOption() { $this->assertEqual($json_response->results->updated, 1); $this->assertEqual($json_response->results->deleted, 1); - $sql = "select * from " . $this->table_prefix . "options where namespace = 'plugin_options-5'"; + $sql = "select * from " . $this->table_prefix . "options where namespace = 'plugin_options-6'"; $stmt = $this->pdo->query($sql); $this->assertEqual($stmt->rowCount(), 2); for($i = 1; $i < 3; $i++) { diff --git a/tests/TestOfPluginOptionMySQLDAO.php b/tests/TestOfPluginOptionMySQLDAO.php index cee86b569b..130f3644d1 100644 --- a/tests/TestOfPluginOptionMySQLDAO.php +++ b/tests/TestOfPluginOptionMySQLDAO.php @@ -131,18 +131,18 @@ public function testOfUpdateOption() { } public function testOfGetOptions() { - $plugin_builder1 = FixtureBuilder::build('plugins', array('id'=>'5', 'folder_name'=>'test_plugin', + $plugin_builder1 = FixtureBuilder::build('plugins', array('id'=>'6', 'folder_name'=>'test_plugin', 'is_active'=>1)); - $plugin_builder2 = FixtureBuilder::build('plugins', array('id'=>'6', 'folder_name'=>'test_plugin1', + $plugin_builder2 = FixtureBuilder::build('plugins', array('id'=>'7', 'folder_name'=>'test_plugin1', 'is_active'=>1)); # init our dao $dao = new PluginOptionMySQLDAO(); $builder1 = $this->buildOptions(1, 'test name', 'test option'); $insert_id1 = $builder1->columns[ 'last_insert_id' ]; - $builder2 = $this->buildOptions(5, 'test name2', 'test option2'); + $builder2 = $this->buildOptions(6, 'test name2', 'test option2'); $insert_id2 = $builder2->columns[ 'last_insert_id' ]; - $builder3 = $this->buildOptions(5, 'test name3', 'test option3'); + $builder3 = $this->buildOptions(6, 'test name3', 'test option3'); $insert_id3 = $builder3->columns[ 'last_insert_id' ]; // bad plugin id @@ -161,10 +161,10 @@ public function testOfGetOptions() { $this->assertNotNull( $options ); $this->assertEqual(count($options), 2); $this->assertIsA($options[0], 'PluginOption'); - $this->assertEqual($options[0]->plugin_id, 5); + $this->assertEqual($options[0]->plugin_id, 6); $this->assertEqual($options[0]->id, 3); $this->assertIsA($options[1], 'PluginOption'); - $this->assertEqual($options[1]->plugin_id, 5); + $this->assertEqual($options[1]->plugin_id, 6); $this->assertEqual($options[1]->id, 4); } diff --git a/tests/TestOfTableStatsMySQLDAO.php b/tests/TestOfTableStatsMySQLDAO.php index f0a25824bd..04178b89be 100644 --- a/tests/TestOfTableStatsMySQLDAO.php +++ b/tests/TestOfTableStatsMySQLDAO.php @@ -56,14 +56,14 @@ public function testGetCounts() { if ($table['table'] == $this->table_prefix . 'options') { $this->assertEqual($table['count'], 1); } else if ($table['table'] == $this->table_prefix . 'plugins') { - $this->assertEqual($table['count'], 4); + $this->assertEqual($table['count'], 5); } else { $this->assertEqual($table['count'], 0); } } // are we sorted by count desc? - $this->assertEqual(4,$counts[0]['count']); + $this->assertEqual(5,$counts[0]['count']); $this->assertEqual(1,$counts[1]['count']); $this->assertEqual(0,$counts[2]['count']); } diff --git a/webapp/install/sql/build-db_mysql.sql b/webapp/install/sql/build-db_mysql.sql index 223f84c773..bce58a4f9c 100644 --- a/webapp/install/sql/build-db_mysql.sql +++ b/webapp/install/sql/build-db_mysql.sql @@ -1,6 +1,6 @@ -- -- ThinkUp Database Creation Script --- Auto-generated by thinkup/extras/scripts/migratedb script on 2012-09-06 +-- Auto-generated by thinkup/extras/scripts/migratedb script on 2012-09-11 -- ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; @@ -517,7 +517,7 @@ CREATE TABLE tu_users ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Service user details.'; --- Dump completed on 2012-09-06 23:52:08 +-- Dump completed on 2012-09-11 17:33:14 -- -- Insert DB Version @@ -535,6 +535,9 @@ VALUES ('Twitter', 'twitter', 'Twitter support', 'Gina Trapani', 'http://thinkup INSERT INTO tu_plugins (name , folder_name, description, author, homepage, version, is_active ) VALUES ('Facebook', 'facebook', 'Facebook support', 'Gina Trapani', 'http://thinkupapp.com', '0.01', '1'); +INSERT INTO tu_plugins (name , folder_name, description, author, homepage, version, is_active ) +VALUES ('Foursquare', 'foursquare', 'Foursquare support', 'Aaron Kalair', 'http://thinkupapp.com', '0.01', '1'); + INSERT INTO tu_plugins (name , folder_name, description, author, homepage, version, is_active ) VALUES ('Google+', 'googleplus', 'Google+ support', 'Gina Trapani', 'http://thinkupapp.com', '0.01', '1'); diff --git a/webapp/plugins/expandurls/tests/TestOfExpandURLsPlugin.php b/webapp/plugins/expandurls/tests/TestOfExpandURLsPlugin.php index 0e8f5f9acc..ea5e7fcbc9 100644 --- a/webapp/plugins/expandurls/tests/TestOfExpandURLsPlugin.php +++ b/webapp/plugins/expandurls/tests/TestOfExpandURLsPlugin.php @@ -39,8 +39,16 @@ class TestOfExpandURLsPlugin extends ThinkUpUnitTestCase { + var $plugin_id; + public function setUp() { parent::setUp(); + + $sql = "select id from " . $this->table_prefix . "plugins where folder_name = 'expandurls'"; + $stmt = PluginMySQLDAO::$PDO->query($sql); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + $this->plugin_id = $data['id']; + $crawler_plugin_registrar = PluginRegistrarCrawler::getInstance(); $crawler_plugin_registrar->registerCrawlerPlugin('ExpandURLsPlugin'); } @@ -318,8 +326,8 @@ public function testFlickrCrawl() { $config = Config::getInstance(); //use fake Flickr API key - $option_builder = FixtureBuilder::build('options', array('namespace' => OptionDAO::PLUGIN_OPTIONS . '-4', - 'option_name' => 'flickr_api_key', 'option_value' => 'dummykey') ); + $option_builder = FixtureBuilder::build('options', array('namespace' => OptionDAO::PLUGIN_OPTIONS . '-'. + $this->plugin_id, 'option_name' => 'flickr_api_key', 'option_value' => 'dummykey') ); $this->simulateLogin('admin@example.com', true); $crawler_plugin_registrar->runRegisteredPluginsCrawl(); @@ -535,12 +543,12 @@ public function testBitlyCrawl() { $config = Config::getInstance(); //use fake Bitly API key - $builders[] = FixtureBuilder::build('options', array('namespace' => OptionDAO::PLUGIN_OPTIONS . '-4', - 'option_name' => 'bitly_api_key', 'option_value' => 'dummykey')); + $builders[] = FixtureBuilder::build('options', array('namespace' => OptionDAO::PLUGIN_OPTIONS . '-'. + $this->plugin_id, 'option_name' => 'bitly_api_key', 'option_value' => 'dummykey')); //use fake Bitly login name - $builder[] = FixtureBuilder::build('options', array('namespace' => OptionDAO::PLUGIN_OPTIONS . '-4', - 'option_name' => 'bitly_login', 'option_value' => 'bitly123')); + $builder[] = FixtureBuilder::build('options', array('namespace' => OptionDAO::PLUGIN_OPTIONS . '-'. + $this->plugin_id, 'option_name' => 'bitly_login', 'option_value' => 'bitly123')); $this->simulateLogin('admin@example.com', true); $crawler_plugin_registrar->runRegisteredPluginsCrawl(); diff --git a/webapp/plugins/foursquare/tests/TestOfFoursquarePluginConfigurationController.php b/webapp/plugins/foursquare/tests/TestOfFoursquarePluginConfigurationController.php index ae8dc5d514..761e78ce73 100644 --- a/webapp/plugins/foursquare/tests/TestOfFoursquarePluginConfigurationController.php +++ b/webapp/plugins/foursquare/tests/TestOfFoursquarePluginConfigurationController.php @@ -58,13 +58,11 @@ public function tearDown() { private function buildController() { // Create an owner $builder_owner = FixtureBuilder::build('owners', array('email' => 'me@example.com', 'user_activated' => 1) ); - // Create a plugin (required as foursquare isn't a default plugin) - $builder_plugin = FixtureBuilder::build('plugins', array('name' => 'foursquare', - 'folder_name' => 'foursquare', 'is_active' => 1) ); - // Set the plugin ID (the id of the last insert to the database (the call above) - $plugin_id = $builder_plugin->columns['last_insert_id']; // Set the name space to plugin_options-pluginid - $namespace = OptionDAO::PLUGIN_OPTIONS . '-' .$plugin_id; + $sql = "select id from " . $this->table_prefix . "plugins where folder_name = 'foursquare'"; + $stmt = PluginMySQLDAO::$PDO->query($sql); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + $namespace = OptionDAO::PLUGIN_OPTIONS . '-'.$data['id']; // Create the client id option $builder_plugin_options[] = FixtureBuilder::build('options', @@ -95,11 +93,11 @@ public function getElementById($doc, $id) { // Insert the plugin options in the database private function buildPluginOptions() { $builders = array(); - // Create a plugin - $builders[] = FixtureBuilder::build('plugins', array('name' => 'Foursquare', 'folder_name' => 'foursquare', - 'is_active' => 1) ); // Set the plugin ID - $namespace = OptionDAO::PLUGIN_OPTIONS . '-' .'5'; + $sql = "select id from " . $this->table_prefix . "plugins where folder_name = 'foursquare'"; + $stmt = PluginMySQLDAO::$PDO->query($sql); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + $namespace = OptionDAO::PLUGIN_OPTIONS . '-'.$data['id']; // Create the client id option $builders[] = FixtureBuilder::build('options', array('namespace' => $namespace, 'option_name' => 'foursquare_client_id', 'option_value' => "test_client_id") ); diff --git a/webapp/plugins/googleplus/tests/TestOfGooglePlusPluginConfigurationController.php b/webapp/plugins/googleplus/tests/TestOfGooglePlusPluginConfigurationController.php index 3e1261c410..dced6e2bde 100644 --- a/webapp/plugins/googleplus/tests/TestOfGooglePlusPluginConfigurationController.php +++ b/webapp/plugins/googleplus/tests/TestOfGooglePlusPluginConfigurationController.php @@ -185,8 +185,11 @@ public function testGetPluginOptions() { private function buildController() { $builder_owner = FixtureBuilder::build('owners', array('email' => 'me@example.com', 'user_activated' => 1) ); - $plugin_id = 3; - $namespace = OptionDAO::PLUGIN_OPTIONS . '-' .$plugin_id; + // Get plugin ID + $sql = "select id from " . $this->table_prefix . "plugins where folder_name = 'googleplus'"; + $stmt = PluginMySQLDAO::$PDO->query($sql); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + $namespace = OptionDAO::PLUGIN_OPTIONS . '-'.$data['id']; $builder_plugin_options[] = FixtureBuilder::build('options', array('namespace' => $namespace, 'option_name' => 'google_plus_client_id', @@ -249,10 +252,12 @@ public function testConfigSet() { } private function buildPluginOptions() { - $namespace = OptionDAO::PLUGIN_OPTIONS . '-3'; + // Get plugin ID + $sql = "select id from " . $this->table_prefix . "plugins where folder_name = 'googleplus'"; + $stmt = PluginMySQLDAO::$PDO->query($sql); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + $namespace = OptionDAO::PLUGIN_OPTIONS . '-'.$data['id']; $builders = array(); - $builders[] = FixtureBuilder::build('plugins', - array('name' => 'Google+', 'folder_name' => 'googleplus', 'description' => "Google+ plugin") ); $builders[] = FixtureBuilder::build('options', array('namespace' => $namespace, 'option_name' => 'google_plus_client_id', 'option_value' => "id") ); $builders[] = FixtureBuilder::build('options',