Beispiel #1
0
 public function testAppIdentifierShouldResetClientWithNewAppIdentifier()
 {
     CurlMock::register("https://api.tinify.com/", array("status" => 200));
     Tinify\setKey("abcde");
     Tinify\setAppIdentifier("MyApp/1.0");
     Tinify\Tinify::getClient();
     Tinify\setAppIdentifier("MyApp/2.0");
     $client = Tinify\Tinify::getClient();
     $client->request("get", "/");
     $this->assertSame(Tinify\Client::userAgent() . " MyApp/2.0", CurlMock::last(CURLOPT_USERAGENT));
 }
 public function testRequestWithBadCredentialsShouldThrowExceptionWithMessage()
 {
     CurlMock::register("https://api.tinify.com/", array("status" => 401, "body" => '{"error":"Unauthorized","message":"Oops!"}'));
     $this->setExpectedExceptionRegExp("Tinify\\AccountException", "/Oops! \\(HTTP 401\\/Unauthorized\\)/");
     $client = new Tinify\Client("key");
     $client->request("get", "/");
 }
 function __construct($key = null, $appIdentifier = null)
 {
     parent::__construct($key, $appIdentifier);
     $this->handlers = array();
 }