Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 public function testAuth()
 {
     $stubLocalDataResponse = $this->getMock('\\SWCO\\AppNexusAPI\\Tests\\LocalDataResponse');
     $stubLocalDataResponse->expects($this->once())->method('json')->will($this->returnValue(array('response' => array('token' => 'the-token'))));
     $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('post')->will($this->returnValue($stubLocalDataRequest));
     $request = new Request('username', 'password', null, null, $stubLocalDataClient);
     $this->assertEquals('the-token', $request->auth());
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function __construct($username, $password, $token = null, IServiceFactory $serviceFactory = null, ClientInterface $client = null, Auth $auth = null)
 {
     parent::__construct($username, $password, $token, $serviceFactory, $client, $auth);
     $this->get(Request::SERVICE_BRAND, false);
 }
Exemplo n.º 5
0
 /**
  * Enables creating a new request object (or child class) from an existing request object.
  *
  * @param Request $request
  * @return static
  */
 public static function newFromRequest(Request $request)
 {
     $reflector = new \ReflectionClass(get_called_class());
     return $reflector->newInstanceArgs($request->getConstructParamsArray());
 }