public function testDataPoolWithOffset() { $stubLocalDataResponse = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataResponse'); $stubLocalDataResponse->expects($this->once())->method('json')->will($this->returnValue($this->getData('device-make-100'))); $stubLocalDataRequest = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataRequest'); $stubLocalDataRequest->expects($this->once())->method('send')->will($this->returnValue($stubLocalDataResponse)); $stubLocalDataClient = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataClient'); $stubLocalDataClient->expects($this->once())->method('get')->with($this->equalTo('/device-make?start_element=100&num_elements=100'), $this->anything())->will($this->returnValue($stubLocalDataRequest)); $request = new Request('username', 'password', 'token', null, $stubLocalDataClient); $request->get(Request::SERVICE_DEVICE_MAKE)->offsetBy(100); $dataPool = new DataPool(); $data = $dataPool->get($request, 100, true); $this->assertEquals(100, $data->getNumElements()); }
public function testResponseMethods() { $categoryData = $this->getData('category'); $stubLocalDataResponse = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataResponse'); $stubLocalDataResponse->expects($this->once())->method('json')->will($this->returnValue($categoryData)); $stubLocalDataRequest = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataRequest'); $stubLocalDataRequest->expects($this->once())->method('send')->will($this->returnValue($stubLocalDataResponse)); $stubLocalDataClient = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataClient'); $stubLocalDataClient->expects($this->once())->method('get')->will($this->returnValue($stubLocalDataRequest)); $request = new Request('username', 'password', 'token', null, $stubLocalDataClient); $response = $request->get(Request::SERVICE_CATEGORY)->send(); $this->assertEquals($categoryData['response']['status'], $response->getStatus()); $this->assertEquals($categoryData['response']['start_element'], $response->getStartElement()); $this->assertEquals($categoryData['response']['count'], $response->getCount()); $this->assertEquals(count($categoryData['response']['categories']), $response->getNumElements()); }
public function testSinceKey() { $stubLocalDataResponse = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataResponse'); $stubLocalDataResponse->expects($this->once())->method('json')->will($this->returnValue($this->getData('category'))); $stubLocalDataRequest = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataRequest'); $stubLocalDataRequest->expects($this->once())->method('send')->will($this->returnValue($stubLocalDataResponse)); $dateTime = \DateTime::createFromFormat("Y-m-d H:i:s", "2014-00-00 00:00:00"); $stubLocalDataClient = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataClient'); $stubLocalDataClient->expects($this->once())->method('get')->with($this->equalTo(sprintf('/category?min_last_modified=%s', urlencode($dateTime->format("Y-m-d H:i:s")))), $this->anything())->will($this->returnValue($stubLocalDataRequest)); $request = new Request('username', 'password', 'token', null, $stubLocalDataClient); $request->get(Request::SERVICE_CATEGORY)->since($dateTime)->send(); }