コード例 #1
0
 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", "/");
 }
コード例 #2
0
ファイル: TinifyTest.php プロジェクト: maomaotp/up2S3
 public function testFromBufferShouldReturnSource()
 {
     CurlMock::register("https://api.tinify.com/shrink", array("status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location")));
     Tinify\setKey("valid");
     $this->assertInstanceOf("Tinify\\Source", Tinify\fromBuffer("png file"));
 }
コード例 #3
0
ファイル: TinifySourceTest.php プロジェクト: maomaotp/up2S3
 public function testToFileShouldStoreImageData()
 {
     CurlMock::register("https://api.tinify.com/shrink", array("status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location")));
     CurlMock::register("https://api.tinify.com/some/location", array("status" => 200, "body" => "compressed file"));
     $path = tempnam(sys_get_temp_dir(), "tinify-php");
     Tinify\setKey("valid");
     Tinify\Source::fromBuffer("png file")->toFile($path);
     $this->assertSame("compressed file", file_get_contents($path));
 }