Esempio n. 1
0
 public function testCollect()
 {
     // getPosts returns an array of size 10 => 20 loops => 20 getUrl
     $this->curlUtils->expects($this->exactly(20))->method('getResource')->will($this->returnValue('whatever'));
     $this->postParserUtils->expects($this->exactly(20))->method('getPosts')->will($this->returnValue(array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9)));
     $this->postParserUtils->expects($this->exactly(200))->method('parse')->will($this->returnValue(array("content" => "this is a content", "author" => "FOO", "created" => "2014-01-01 00:00:00")));
     // insert in Db should be called 200 times
     $this->conn->expects($this->exactly(200))->method('insert');
     $response = $this->postController->collect();
     $this->assertInstanceOf("Symfony\\Component\\HttpFoundation\\JsonResponse", $response);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertContains("200 posts have been added", $response->getContent());
 }