public function testRunWorkflowWithValidParams()
 {
     $content = new ObjectModel\Content();
     $content->id = "testId1";
     $content->state = "new_content";
     $content->date = time();
     $content->tags = array(new ObjectModel\Tag("text1", "type"), new ObjectModel\Tag("text2", "type"));
     $source = new ObjectModel\Source();
     $source->id = "testId1";
     $source->parent = "testParentId";
     $source->score = 1;
     $source->name = "testName";
     $source->type = "testType";
     $source->subType = "testSubType";
     $content->source = $source;
     Modules\DataContext\MySql_V2\DataContext::SaveContent(array($content));
     $json = '{"id":"testId1","tagsRemoved":[{"text":"text1","type":"type"},{"text":"text2","type":"type"}],"tagsAdded":[{"text":"text3","type":"type"}]}';
     $workflow = new Workflows\ContentServices\UpdateContentTagging();
     $result = $workflow->RunWorkflow($json, "swiftriver_dev");
     $content = Modules\DataContext\MySql_V2\DataContext::GetContent(array("testId1"));
     $pdo = Modules\DataContext\MySql_V2\DataContext::PDOConnection();
     $pdo->exec("DELETE FROM SC_Content");
     $pdo->exec("DELETE FROM SC_Sources");
     $pdo->exec("DELETE FROM SC_Content_Tags");
     $pdo->exec("DELETE FROM SC_Tags");
     $pdo = null;
     $tags = $content[0]->tags;
     $this->assertEquals(1, \count($tags));
     $this->assertEquals("text3", $tags[0]->text);
     $this->assertEquals("type", $tags[0]->type);
 }
 public function testCreateSourceFromIdentifyerWithExistingSourceTrusted()
 {
     $db = Modules\DataContext\MySql_V2\DataContext::PDOConnection();
     $id = md5("testId");
     $db->exec("INSERT INTO SC_Sources VALUES ('{$id}', 'testParentId', 10, 'testName', 'testType', 'testSubType', '{\"id\":\"{$id}\",\"score\":10,\"name\":\"testName\",\"parent\":\"testParentId\",\"email\":null,\"link\":\"http:\\/\\/twitter.com\\/datninja12\",\"type\":\"testType\",\"subType\":\"testSubType\"}')");
     $s = ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier("testId", true);
     $db->exec("DELETE FROM SC_Sources");
     $db = null;
     $this->assertEquals($id, $s->id);
     $this->assertEquals(10, $s->score);
 }
 public function testListAllSources()
 {
     $db = Modules\DataContext\MySql_V2\DataContext::PDOConnection();
     $db->exec("INSERT INTO SC_Sources VALUES ('testId1', 'testParentId', 100, 10, 'testName', 'testType', 'testSubType', '{\"id\":\"testId1\",\"score\":10,\"name\":\"testName\",\"parent\":\"testParentId\",\"email\":null,\"link\":\"http:\\/\\/twitter.com\\/datninja12\",\"type\":\"testType\",\"subType\":\"testSubType\"}')");
     $db->exec("INSERT INTO SC_Sources VALUES ('testId2', 'testParentId', 100, 10, 'testName', 'testType', 'testSubType', '{\"id\":\"testId2\",\"score\":10,\"name\":\"testName\",\"parent\":\"testParentId\",\"email\":null,\"link\":\"http:\\/\\/twitter.com\\/datninja12\",\"type\":\"testType\",\"subType\":\"testSubType\"}')");
     $sources = Modules\DataContext\MySql_V2\DataContext::ListAllSources();
     $db->exec("DELETE FROM SC_Sources");
     $db = null;
     $this->assertEquals(true, \is_array($sources));
     $this->AssertEquals(2, \count($sources));
     $this->assertEquals("testId1", $sources[0]->id);
     $this->assertEquals("testParentId", $sources[0]->parent);
     $this->assertEquals(10, $sources[0]->score);
     $this->assertEquals("testName", $sources[0]->name);
     $this->assertEquals("testType", $sources[0]->type);
     $this->assertEquals("testSubType", $sources[0]->subType);
     $this->assertEquals("testId2", $sources[1]->id);
     $this->assertEquals("testParentId", $sources[1]->parent);
     $this->assertEquals(10, $sources[1]->score);
     $this->assertEquals("testName", $sources[1]->name);
     $this->assertEquals("testType", $sources[1]->type);
     $this->assertEquals("testSubType", $sources[1]->subType);
 }
 public function testListAllChannelsWithTwoChannelsAndActiveAndInProcessFlags()
 {
     $pdo = Modules\DataContext\MySql_V2\DataContext::PDOConnection();
     $time = time();
     $channel = new ObjectModel\Channel();
     $channel->id = "testId1";
     $channel->type = "test";
     $channel->subType = "test";
     $channel->active = true;
     $channel->inprocess = true;
     $channel->nextrun = $time;
     Modules\DataContext\MySql_V2\DataContext::SaveChannels(array($channel));
     $channel->id = "testId2";
     $channel->active = false;
     $channel->nextrun = $time - 100;
     Modules\DataContext\MySql_V2\DataContext::SaveChannels(array($channel));
     $channels = Modules\DataContext\MySql_V2\DataContext::ListAllChannels();
     Modules\DataContext\MySql_V2\DataContext::RemoveChannels(array("testId1", "testId2"));
     $this->assertEquals(true, is_array($channels));
     $this->assertEquals(2, count($channels));
     $this->assertEquals("testId1", $channels[0]->id);
     $this->assertEquals("testId2", $channels[1]->id);
 }
 public function testDeleteContentWithTwoContentItems()
 {
     $content1 = new ObjectModel\Content();
     $content1->id = "testId1";
     $content1->state = "new_content";
     $content1->date = time();
     $content1->tags = array(new ObjectModel\Tag("testText1", "testType1"), new ObjectModel\Tag("testText2", "testType2"));
     $content2 = new ObjectModel\Content();
     $content2->id = "testId2";
     $content2->state = "new_content";
     $content2->date = time();
     $content2->tags = array(new ObjectModel\Tag("testText1", "testType1"), new ObjectModel\Tag("testText2", "testType2"));
     $source = new ObjectModel\Source();
     $source->id = "testId1";
     $source->parent = "testParentId";
     $source->score = 1;
     $source->name = "testName";
     $source->type = "testType";
     $source->subType = "testSubType";
     $content1->source = $source;
     $content2->source = $source;
     Modules\DataContext\MySql_V2\DataContext::SaveContent(array($content1, $content2));
     Modules\DataContext\MySql_V2\DataContext::DeleteContent(array($content1, $content2));
     $pdo = Modules\DataContext\MySql_V2\DataContext::PDOConnection();
     $found = false;
     foreach ($pdo->query("SELECT * FROM SC_Content WHERE id in ('testId1', 'testId2')") as $row) {
         $found = true;
     }
     $this->assertEquals(false, $found);
     $found = false;
     foreach ($pdo->query("SELECT * FROM SC_Sources WHERE id = 'testId1'") as $row) {
         $found = true;
         $this->assertEquals("testId1", $row["id"]);
     }
     $this->assertEquals(true, $found);
     $count = 0;
     foreach ($pdo->query("SELECT type, text FROM SC_Tags") as $row) {
         $count++;
         $this->assertEquals(true, $row["type"] == "testType1" || $row["type"] == "testType2");
         $this->assertEquals(true, $row["text"] == "testtext1" || $row["text"] == "testtext2");
     }
     $this->assertEquals(2, $count);
     $pdo->exec("DELETE FROM SC_Content");
     $pdo->exec("DELETE FROM SC_Sources");
     $pdo->exec("DELETE FROM SC_Content_Tags");
     $pdo->exec("DELETE FROM SC_Tags");
     $pdo = null;
 }