public function testWithReason()
 {
     $markerId = "f78ds9f79sd87f9sd";
     $sourceId = "df9dsf80sdf8ds0fd";
     $change = -1;
     $reason = "falsehood";
     Modules\DataContext\MySql_V1\DataContext::RecordSourceScoreChange($sourceId, $markerId, $change, $reason);
 }
 public function testAllAPIKeyFunctions()
 {
     $result = Modules\DataContext\MySql_V1\DataContext::AddRegisteredCoreAPIKey("testkey");
     $this->assertEquals(true, $result);
     $this->assertEquals(true, Modules\DataContext\MySql_V1\DataContext::IsRegisterdCoreAPIKey("testkey"));
     $result = Modules\DataContext\MySql_V1\DataContext::RemoveRegisteredCoreAPIKey("testkey");
     $this->assertEquals(true, $result);
     $this->assertEquals(false, Modules\DataContext\MySql_V1\DataContext::IsRegisterdCoreAPIKey("testkey"));
 }
 public function testRedbean()
 {
     $c1 = new ObjectModel\Content();
     $c1->SetId("testid1");
     $c1->SetTitle("testtitle1");
     $c1->SetLink("testlink");
     $c1->SetText(array("id1text1", "id1text2"));
     $c1->SetTags(array(new ObjectModel\Tag("id1tag1", "who"), new ObjectModel\Tag("di1tag2", "what")));
     $dif1 = new ObjectModel\DuplicationIdentificationField("unique_tweet_id", "d87f8d7fdsg7dfgdfgfd89g7as");
     $dif2 = new ObjectModel\DuplicationIdentificationField("tweet_text", "jdhjsdfy jhfjdsf ksjhf kdjf ksdjfhsd ");
     $c1->SetDifs(array(new ObjectModel\DuplicationIdentificationFieldCollection("collection1", array($dif1, $dif2))));
     Modules\DataContext\MySql_V1\DataContext::SaveContent(array($c1));
 }
 public function test()
 {
     $channel = new ObjectModel\Channel();
     $channel->id = "testId";
     $channel->type = "test";
     $channel->updatePeriod = 5;
     $channel->parameters = array("feedUrl" => "http://something", "something" => "elshdjsh87d7f76&^&*^SHGGT^&");
     Modules\DataContext\MySql_V1\DataContext::SaveChannelProgessingJob($channel);
     $channel = Modules\DataContext\MySql_V1\DataContext::SelectNextDueChannelProcessingJob(time());
     $this->assertEquals(true, isset($channel));
     $channels = Modules\DataContext\MySql_V1\DataContext::ListAllChannelProcessingJobs();
     $found = false;
     foreach ($channels as $c) {
         if ($c->GetId() == $channel->GetId()) {
             $found = true;
         }
     }
     Modules\DataContext\MySql_V1\DataContext::MarkChannelProcessingJobAsComplete($channel);
     $channels = Modules\DataContext\MySql_V1\DataContext::ListAllChannelProcessingJobs();
     $found = false;
     foreach ($channels as $c) {
         if ($c->GetId() == $channel->GetId()) {
             $lastsucess = $c->lastSucess;
             $this->assertEquals(true, isset($lastsucess));
             if (isset($lastsucess)) {
                 $this->assertEquals(true, $lastsucess <= time());
             }
             $found = true;
         }
     }
     $this->assertEquals(true, $found);
     Modules\DataContext\MySql_V1\DataContext::RemoveChannelProcessingJob($channel);
     $channels = Modules\DataContext\MySql_V1\DataContext::ListAllChannelProcessingJobs();
     $found = false;
     foreach ($channels as $c) {
         if ($c->GetId() == $channel->GetId()) {
             $found = true;
         }
     }
     $this->assertEquals(false, $found);
 }
 public function testIsRegisteredCoreAPIKeyWithNoneExistantAPIKey()
 {
     $result = Modules\DataContext\MySql_V1\DataContext::IsRegisterdCoreAPIKey("none-existant-key");
     $this->assertEquals(false, $result);
 }
 public function testRedbean()
 {
     $time = time();
     $c1 = new ObjectModel\Content();
     $c1->id = "testid1";
     $c1->link = "testlink";
     $c1->state = StateTransition\StateController::$defaultState;
     $c1->date = $time;
     $c1->text = array(new ObjectModel\LanguageSpecificText("en", "testtitle1", array("id1text1", "id1text2")));
     $c1->tags = array(new ObjectModel\Tag("id1tag1", "who"), new ObjectModel\Tag("id1tag2", "what"));
     $dif1 = new ObjectModel\DuplicationIdentificationField("unique_tweet_id", "d87f8d7fdsg7dfgdfgfd89g7as");
     $dif2 = new ObjectModel\DuplicationIdentificationField("tweet_text", "jdhjsdfy jhfjdsf ksjhf kdjf ksdjfhsd ");
     $c1->difs = array(new ObjectModel\DuplicationIdentificationFieldCollection("collection1", array($dif1, $dif2)));
     $s = ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier("thisisatestidforatestsource");
     $s->score = 10;
     $c1->source = $s;
     Modules\DataContext\MySql_V1\DataContext::SaveContent(array($c1));
     $cOutArray = Modules\DataContext\MySql_V1\DataContext::GetContent(array($c1->id));
     $this->assertEquals(true, isset($cOutArray));
     $this->assertEquals(true, is_array($cOutArray));
     $this->assertEquals(1, count($cOutArray));
     $content = $cOutArray[0];
     $this->assertEquals("testid1", $content->id);
     $this->assertEquals("testlink", $content->link);
     $this->assertEquals($time, $content->date);
     $text = reset($content->text);
     //get the first element
     $this->assertEquals("testtitle1", $text->title);
     $this->assertEquals("en", $text->languageCode);
     $this->assertEquals("id1text1", $text->text[0]);
     $this->assertEquals("id1text2", $text->text[1]);
     $tags = $content->tags;
     $this->assertEquals(true, isset($tags));
     $this->assertEquals(true, is_array($tags));
     $this->assertEquals(2, count($tags));
     $tag1 = $tags[0];
     $this->assertEquals("id1tag1", $tag1->text);
     $this->assertEquals("who", $tag1->type);
     $tag2 = $tags[1];
     $this->assertEquals("id1tag2", $tag2->text);
     $this->assertEquals("what", $tag2->type);
     $difCollections = $content->difs;
     $this->assertEquals(true, isset($difCollections));
     $this->assertEquals(true, is_array($difCollections));
     $this->assertEquals(1, count($difCollections));
     $difCollection = $difCollections[0];
     $this->assertEquals(true, isset($difCollection));
     $this->assertEquals("collection1", $difCollection->name);
     $difs = $difCollection->difs;
     $this->assertEquals(true, isset($difs));
     $this->assertEquals(true, is_array($difs));
     $this->assertEquals(2, count($difs));
     $d1 = $difs[0];
     $this->assertEquals("unique_tweet_id", $d1->type);
     $this->assertEquals("d87f8d7fdsg7dfgdfgfd89g7as", $d1->value);
     $d2 = $difs[1];
     $this->assertEquals("tweet_text", $d2->type);
     $this->assertEquals("jdhjsdfy jhfjdsf ksjhf kdjf ksdjfhsd ", $d2->value);
     $source = $content->source;
     $this->assertEquals(true, isset($source));
     $this->assertEquals(10, $source->score);
     $sId = $source->id;
     $this->assertEquals(true, isset($sId));
     $state = StateTransition\StateController::$defaultState;
     $array = Modules\DataContext\MySql_V1\DataContext::GetContentList(array("state" => $state, "pagesize" => 10, "pagestart" => 0));
     $this->assertEquals(true, is_array($array));
     $totalCout = $array["totalCount"];
     $this->assertEquals(true, $totalCout > 0);
     $contentArray = $array["contentItems"];
     $this->assertEquals(true, isset($contentArray));
     $this->assertEquals(true, is_array($contentArray));
     foreach ($contentArray as $c) {
         if ($c->id == "testid1") {
             $content = $c;
         }
     }
     $this->assertEquals("testid1", $content->id);
     $this->assertEquals("testlink", $content->link);
     $text = reset($content->text);
     //get the first element
     $this->assertEquals("testtitle1", $text->title);
     $this->assertEquals("en", $text->languageCode);
     $this->assertEquals("id1text1", $text->text[0]);
     $this->assertEquals("id1text2", $text->text[1]);
     $tags = $content->tags;
     $this->assertEquals(true, isset($tags));
     $this->assertEquals(true, is_array($tags));
     $this->assertEquals(2, count($tags));
     $tag1 = $tags[0];
     $this->assertEquals("id1tag1", $tag1->text);
     $this->assertEquals("who", $tag1->type);
     $tag2 = $tags[1];
     $this->assertEquals("id1tag2", $tag2->text);
     $this->assertEquals("what", $tag2->type);
     $difCollections = $content->difs;
     $this->assertEquals(true, isset($difCollections));
     $this->assertEquals(true, is_array($difCollections));
     $this->assertEquals(1, count($difCollections));
     $difCollection = $difCollections[0];
     $this->assertEquals(true, isset($difCollection));
     $this->assertEquals("collection1", $difCollection->name);
     $difs = $difCollection->difs;
     $this->assertEquals(true, isset($difs));
     $this->assertEquals(true, is_array($difs));
     $this->assertEquals(2, count($difs));
     $d1 = $difs[0];
     $this->assertEquals("unique_tweet_id", $d1->type);
     $this->assertEquals("d87f8d7fdsg7dfgdfgfd89g7as", $d1->value);
     $d2 = $difs[1];
     $this->assertEquals("tweet_text", $d2->type);
     $this->assertEquals("jdhjsdfy jhfjdsf ksjhf kdjf ksdjfhsd ", $d2->value);
     $source = $content->source;
     $this->assertEquals(true, isset($source));
     $this->assertEquals(10, $source->score);
     $sId = $source->id;
     $this->assertEquals(true, isset($sId));
     Modules\DataContext\MySql_V1\DataContext::DeleteContent(array($content));
     $contentArray = Modules\DataContext\MySql_V1\DataContext::GetContent(array($content->id));
     $this->assertEquals(true, isset($contentArray));
     $this->assertEquals(0, count($contentArray));
 }