Пример #1
0
 /**
  * testFunctionality
  * 
  * Test basic class functionality
  */
 public function testFunctionality()
 {
     $client = new Client('http://www.somedomain.com/mm5', 'TOKENZrSHWEET');
     $this->assertEquals($client->getUri(), 'http://www.somedomain.com/mm5');
     $this->assertEquals($client->getToken(), 'TOKENZrSHWEET');
     $this->assertEquals($client->getUrl(), 'http://www.somedomain.com/mm5/json.mvc?Function=Module&Module_Code=remoteprovisioning&Module_Function=XML');
     $client->setUri('http://www.someotherdomain.com/mm5')->setToken('TOKENZrSHWEETERWHENCHANGED');
     $this->assertEquals($client->getUri(), 'http://www.someotherdomain.com/mm5');
     $this->assertEquals($client->getToken(), 'TOKENZrSHWEETERWHENCHANGED');
     $this->assertEquals($client->getUrl(), 'http://www.someotherdomain.com/mm5/json.mvc?Function=Module&Module_Code=remoteprovisioning&Module_Function=XML');
     $request = new Request('I AM A REQUEST CONTENT');
     $mockClient = new ClientMock('http://www.somedomain.com/mm5', 'TOKENZrSHWEET');
     $response = $mockClient->doRequest($request);
     $this->assertInstanceOf('Miva\\Provisioning\\Response', $response);
 }
Пример #2
0
 function testDoRequestCurlError()
 {
     $client = new ClientMock();
     $request = new Request('GET', 'http://example.org/');
     $client->on('curlExec', function (&$return) {
         $return = "";
     });
     $client->on('curlStuff', function (&$return) {
         $return = [[], 1, 'Curl error'];
     });
     try {
         $response = $client->doRequest($request);
         $this->fail('This should have thrown an exception');
     } catch (ClientException $e) {
         $this->assertEquals(1, $e->getCode());
         $this->assertEquals('Curl error', $e->getMessage());
     }
 }