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 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; }