Пример #1
0
 /**
  * @expectedException \RequestLab\XitiAnalytics\XitiException
  */
 public function testQueryWithJsonError()
 {
     $this->clientMock->expects($this->once())->method('getHeaders')->will($this->returnValue(array('Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($this->login . ':' . $this->password))));
     $this->queryMock->expects($this->once())->method('build')->will($this->returnValue('uri'));
     $this->httpAdapterMock->expects($this->once())->method('getContent')->with($this->equalTo('uri'))->will($this->returnValue(json_encode(array('ErrorCode' => '2017', 'ErrorMessage' => 'Le message'))));
     $this->service->query($this->queryMock);
 }
Пример #2
0
 public function testBuild()
 {
     $this->query->setColumns(array('m_visits', 'm_page_loads'));
     $this->query->setSpace('475905');
     $this->query->setStartDate($startDate = new \DateTime('2015-08-02'));
     $this->query->setEndDate($endDate = new \DateTime('2015-08-02'));
     $this->query->setMaxResults(10000);
     $this->query->setPageNum(1);
     $this->query->setLng('fr');
     $expected = "https://apirest.atinternet-solutions.com/data/v2/json/getData?columns=%7Bm_visits%2Cm_page_loads%7D&space=%7Bs%3A475905%7D&period=%7BD%3A%7Bstart%3A%272015-08-02%27%2Cend%3A%272015-08-02%27%7D%7D&max-results=10000&page-num=1&include=%7Btotal%3Adisplayed%7D&lng=fr";
     $this->assertSame($expected, $this->query->build());
 }