コード例 #1
0
 public function testInsertHashtag()
 {
     $ht_exist = 'exist_yet';
     $this->hashtagpost_dao->insertHashtagPost($ht_exist, '1', 'twitter');
     $res = $this->hashtagpost_dao->getHashtagsForPost('1', 'twitter');
     $this->assertEqual(sizeof($res), 1);
     $this->assertEqual($res[0]['post_id'], '1');
     $this->assertEqual($res[0]['hashtag_id'], 1);
     $res = $this->hashtag_dao->getHashtagByID(1);
     $this->assertEqual($res->hashtag, 'exist_yet');
     $this->assertEqual($res->count_cache, 101);
     $ht_not_exist = 'not_exist_yet';
     $this->hashtagpost_dao->insertHashtagPost($ht_not_exist, '1', 'twitter');
     $res = $this->hashtagpost_dao->getHashtagsForPost('1', 'twitter');
     $this->assertEqual(sizeof($res), 2);
     $this->assertEqual($res[1]['post_id'], '1');
     $this->assertEqual($res[1]['hashtag_id'], 2);
     $res = $this->hashtag_dao->getHashtagByID(2);
     $this->assertEqual($res->hashtag, 'not_exist_yet');
     $this->assertEqual($res->count_cache, 1);
 }
コード例 #2
0
 public function testDeleteHashtagByID()
 {
     $this->debug("Begin testDeleteHashtagByHashtagId");
     $res = $this->dao->getHashtagByID(1);
     $this->assertIsA($res, 'Hashtag');
     $res = $this->dao->deleteHashtagByID(1);
     $this->assertTrue($res);
     $res = $this->dao->getHashtagByID(1);
     $this->assertNull($res);
     $res = $this->dao->getHashtagByID(2);
     $this->assertIsA($res, 'Hashtag');
     $res = $this->dao->deleteHashtagByID(2);
     $this->assertTrue($res);
     $res = $this->dao->getHashtagByID(2);
     $this->assertNull($res);
     $res = $this->dao->deleteHashtagByID(256);
     $this->assertFalse($res);
     $this->debug("End testDeleteHashtagByHashtagId");
 }
コード例 #3
0
 public function testDeleteExistingInstanceWithTweetSearchWithPrivilegesWithOtherOwners()
 {
     $this->debug(__METHOD__);
     //Not admin with access privs, with other owners (delete owner instance and NOT instance)
     $builders = array();
     $builders[] = FixtureBuilder::build('instances', array('id' => 2, 'network_user_id' => 12, 'network_username' => 'tuinstance', 'network' => 'twitter'));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 2, 'oauth_access_token' => 'xxx', 'oauth_access_token_secret' => 'yyy'));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 2, 'instance_id' => 2, 'oauth_access_token' => 'xxx', 'oauth_access_token_secret' => 'yyy'));
     $instance_dao = new InstanceMySQLDAO();
     $owner_instance_dao = new OwnerInstanceMySQLDAO();
     $instance_hashtag_dao = new InstanceHashtagMySQLDAO();
     //before builder
     $instance = $instance_dao->get(2);
     $this->assertNotNull($instance);
     $instances_hashtags = $instance_hashtag_dao->getByInstance($instance->id);
     $this->assertEqual(sizeof($instances_hashtags), 0);
     $builder = $this->buildHashtagData(2);
     //after builder
     $hashtag_dao = new HashtagMySQLDAO();
     $hashtagpost_dao = new HashtagPostMySQLDAO();
     $hashtags = $hashtagpost_dao->getHashtagsForPost(1, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     $hashtags = $hashtagpost_dao->getHashtagsForPost(2, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     //instances hashtags should be deleted
     $instances_hashtags = $instance_hashtag_dao->getByInstance(2);
     $this->assertEqual(sizeof($instances_hashtags), 2);
     //hashtag should be deleted
     $hashtag = $hashtag_dao->getHashtagByID(1);
     $this->assertEqual(sizeof($hashtag), 1);
     $hashtag = $hashtag_dao->getHashtagByID(2);
     $this->assertEqual(sizeof($hashtag), 1);
     //Should delete the owner instance but leave the instance alone
     $this->simulateLogin('*****@*****.**', false, true);
     $_POST['action'] = "Delete";
     $_POST["instance_id"] = 2;
     $_POST['csrf_token'] = parent::CSRF_TOKEN;
     $controller = new AccountConfigurationController(true);
     //before
     $instance = $instance_dao->get(2);
     $this->assertNotNull($instance);
     $owner_instances = $owner_instance_dao->getByInstance(2);
     $this->assertNotNull($owner_instances);
     $this->assertIsA($owner_instances, 'Array');
     $this->assertEqual(sizeof($owner_instances), 2);
     //process controller
     $controller->go();
     //hashtags posts should be deleted
     $hashtags = $hashtagpost_dao->getHashtagsForPost(1, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     $hashtags = $hashtagpost_dao->getHashtagsForPost(2, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     //instances hashtags should NOT be deleted
     $instances_hashtags = $instance_hashtag_dao->getByInstance(2);
     $this->assertEqual(sizeof($instances_hashtags), 2);
     //hashtag should NOT be deleted
     $hashtag = $hashtag_dao->getHashtagByID(1);
     $this->assertEqual(sizeof($hashtag), 1);
     $hashtag = $hashtag_dao->getHashtagByID(2);
     $this->assertEqual(sizeof($hashtag), 1);
     $this->debug('Still running');
     //instance should NOT be deleted
     $instance = $instance_dao->get(2);
     $this->assertNotNull($instance);
     //just one owner_instance should be deleted
     $owner_instances = $owner_instance_dao->getByInstance(2);
     $this->assertIsA($owner_instances, 'Array');
     $this->assertEqual(sizeof($owner_instances), 1);
     $v_mgr = $controller->getViewManager();
     $success_msgs = $v_mgr->getTemplateDataItem('success_msgs');
     $this->assertNotNull($success_msgs);
     $this->assertEqual($success_msgs['account'], 'Account deleted.');
     $this->assertNull($v_mgr->getTemplateDataItem('error_msg'));
 }