public function testWithFullGoodJSON() { $content = new \Swiftriver\Core\ObjectModel\Content(); $content->id = "testId"; $json = '["tagone","tagtwo"]'; $parser = new ContentFromJSONParser($content, $json); $item = $parser->GetTaggedContent(); $this->assertEquals(2, count($item->tags)); $tags = $item->tags; $firsttag = $tags[0]; $this->assertEquals("General", $firsttag->type); $this->assertEquals("tagone", $firsttag->text); $lasttag = $tags[1]; $this->assertEquals("General", $lasttag->type); $this->assertEquals("tagtwo", $lasttag->text); }
public function testWithGoodButSmallJSON() { $content = new \Swiftriver\Core\ObjectModel\Content(); $content->SetId("testId"); $json = '{"memes":[{"source":"http://www.knallgrau.at/en","updated":"Mon May 15 13:38:14 CEST 2006","dimensions":{"topic":["knallgrau","twoday","platform","Contact","content","software","management","blog","business","company"]}}]}'; $parser = new ContentFromJSONParser($content, $json); $item = $parser->GetTaggedContent(); $this->assertEquals(10, count($item->GetTags())); $tags = $item->GetTags(); $firsttag = $tags[0]; $this->assertEquals("what", $firsttag->GetType()); $this->assertEquals("knallgrau", $firsttag->GetText()); $lasttag = $tags[9]; $this->assertEquals("what", $lasttag->GetType()); $this->assertEquals("company", $lasttag->GetText()); }