Skip to content

Commit 1d6f5e6

Browse files
committed
add fop
1 parent a83532e commit 1d6f5e6

File tree

6 files changed

+102
-4
lines changed

6 files changed

+102
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ php:
66
before_script:
77
- export QINIU_ACCESS_KEY="Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ"
88
- export QINIU_SECRET_KEY="b5b5vNg5nnkwkPfW5ayicPE_pj6hqgKMQEaWQ6JD"
9-
- export QINIU_BUCKET_NAME="php_sdk_test_bucket"
9+
- export QINIU_BUCKET_NAME="phpsdk"
1010
- export QINIU_KEY_NAME="file_name"
1111
script:
1212
- cd tests; phpunit .

qiniu/fop.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
require_once("auth_digest.php");
4+
5+
// --------------------------------------------------------------------------------
6+
// class Qiniu_ImageView
7+
8+
class Qiniu_ImageView {
9+
public $Mode;
10+
public $Width;
11+
public $Height;
12+
public $Quality;
13+
public $Format;
14+
15+
public function MakeRequest($url)
16+
{
17+
$ops = array($this->Mode);
18+
19+
if (!empty($this->Width)) {
20+
$ops[] = 'w/' . $this->Width;
21+
}
22+
if (!empty($this->Height)) {
23+
$ops[] = 'h/' . $this->Height;
24+
}
25+
if (!empty($this->Quality)) {
26+
$ops[] = 'q/' . $this->Quality;
27+
}
28+
if (!empty($this->Format)) {
29+
$ops[] = 'format/' . $this->Format;
30+
}
31+
32+
return $url . "?imageView/" . implode('/', $ops);
33+
}
34+
}
35+
36+
// --------------------------------------------------------------------------------
37+
// class Qiniu_Exif
38+
39+
class Qiniu_Exif {
40+
41+
public function MakeRequest($url)
42+
{
43+
return $url . "?exif";
44+
}
45+
46+
}
47+
48+
// --------------------------------------------------------------------------------
49+
// class Qiniu_ImageInfo
50+
51+
class Qiniu_ImageInfo {
52+
53+
public function MakeRequest($url)
54+
{
55+
return $url . "?imageInfo";
56+
}
57+
58+
}

tests/FopTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
require_once('bootstrap.php');
4+
5+
class FopTest extends PHPUnit_Framework_TestCase
6+
{
7+
8+
public $url = 'http://phpsdk.qiniudn.com/f22.jpeg';
9+
10+
public function testImageView()
11+
{
12+
$imageView = new Qiniu_ImageView();
13+
$imageView->Mode = 1;
14+
$imageView->Width = 80;
15+
$imageView->Format = 'jpg';
16+
17+
$url = $this->url;
18+
19+
$expectedUrl = $url . '?imageView/1/w/80/format/jpg';
20+
$this->assertEquals($imageView->MakeRequest($url), $expectedUrl);
21+
}
22+
23+
public function testExif()
24+
{
25+
$exif = new Qiniu_Exif();
26+
$url = $this->url;
27+
$expectedUrl = $url . '?exif';
28+
$this->assertEquals($exif->MakeRequest($url), $expectedUrl);
29+
}
30+
31+
public function testImageInfo()
32+
{
33+
$imageView = new Qiniu_ImageInfo();
34+
$url = $this->url;
35+
$expectedUrl = $url . '?imageInfo';
36+
37+
$this->assertEquals($imageView->MakeRequest($url), $expectedUrl);
38+
}
39+
}

tests/RsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require("bootstrap.php");
44

5-
class RsApiTest extends PHPUnit_Framework_TestCase
5+
class RsTest extends PHPUnit_Framework_TestCase
66
{
77
public $client;
88
public $bucket;

tests/RsfTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function testRsf()
2323
$this->assertNull($err);
2424
$this->assertArrayHasKey('marker', $ret);
2525

26-
list($ret, $err) = $this->rsf->ListPrefix($this->bucket, "file", $ret['marker'], 2);
27-
$this->assertNull($err);
26+
list($ret, $err) = $this->rsf->ListPrefix($this->bucket, "file", $ret['marker'], 1);
27+
$this->assertEquals($err, 'EOF');
2828
}
2929

3030
}

tests/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_once("../qiniu/rs.php");
44
require_once("../qiniu/rsf.php");
55
require_once("../qiniu/io.php");
6+
require_once("../qiniu/fop.php");
67

78
$accessKey = getenv("QINIU_ACCESS_KEY");
89
$secretKey = getenv("QINIU_SECRET_KEY");

0 commit comments

Comments
 (0)