public static function setUpBeforeClass() { self::$client = new Client(); $getBouncesStream = Stream::factory(JsonLoader::getBounces()); $getClicksStream = Stream::factory(JsonLoader::getClicks()); $getForwardsStream = Stream::factory(JsonLoader::getForwards()); $getUnsubscribesStream = Stream::factory(JsonLoader::getOptOuts()); $getSendsStream = Stream::factory(JsonLoader::getSends()); $getOpensStream = Stream::factory(JsonLoader::getOpens()); $getSummaryStream = Stream::factory(JsonLoader::getSummary()); $mock = new Mock([new Response(200, array(), $getBouncesStream), new Response(200, array(), $getClicksStream), new Response(200, array(), $getForwardsStream), new Response(200, array(), $getUnsubscribesStream), new Response(200, array(), $getSendsStream), new Response(200, array(), $getOpensStream), new Response(200, array(), $getSummaryStream)]); self::$client->getEmitter()->attach($mock); }
public function testGetBounces() { $curlResponse = CurlResponse::create(JsonLoader::getBounces(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('get')->with()->will($this->returnValue($curlResponse)); $resultSet = $this->campaignTrackingService->getBounces('access_token', "1100394165290", array('limit' => 2)); $this->assertInstanceOf('Ctct\\Components\\ResultSet', $resultSet); $this->assertInstanceOf('Ctct\\Components\\Tracking\\BounceActivity', $resultSet->results[0]); $this->assertEquals("bGltaXQ9MyZuZXh0PTEzNTQ4MTcyMTA0MzA", $resultSet->next); $this->assertEquals("EMAIL_BOUNCE", $resultSet->results[0]->activity_type); $this->assertEquals(1100394165290, $resultSet->results[0]->campaign_id); $this->assertEquals("2", $resultSet->results[0]->contact_id); $this->assertEquals("*****@*****.**", $resultSet->results[0]->email_address); $this->assertEquals("B", $resultSet->results[0]->bounce_code); $this->assertEquals("Non-existent address", $resultSet->results[0]->bounce_description); $this->assertEquals("", $resultSet->results[0]->bounce_message); $this->assertEquals("2012-12-06T13:05:24.844Z", $resultSet->results[0]->bounce_date); }