Skip to content

Commit

Permalink
Merge pull request #541 from basho/bugfix/kaz-update-php-test
Browse files Browse the repository at this point in the history
php-tests: fixed to work with aws-sdk-php-2.3.x.
  • Loading branch information
ksauzz committed Apr 25, 2013
2 parents dab402d + 9feb895 commit 6192547
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
1 change: 0 additions & 1 deletion client_tests/php/.gitignore
@@ -1,4 +1,3 @@
test_services.json
phpunit
composer.lock
vendor
2 changes: 1 addition & 1 deletion client_tests/php/composer.json
Expand Up @@ -3,7 +3,7 @@
"bin-dir": "."
},
"require": {
"aws/aws-sdk-php": "2.*"
"aws/aws-sdk-php": "2.3.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
Expand Down
Expand Up @@ -3,11 +3,11 @@
"services" : {
"default_settings" : {
"params" : {
"key" : "your-aws-access-key-id",
"secret" : "your-aws-secret-access-key",
"key" : "key_id",
"secret" : "key_secret",
"region" : "us-east-1",
"base_url" : "http://s3.amazonaws.com",
// "curl.options": {"CURLOPT_PROXY" : "33.33.33.10:8080"},
"curl.options": {"CURLOPT_PROXY" : "localhost:8080"},
"scheme" : "http"
}
}
Expand Down
6 changes: 3 additions & 3 deletions client_tests/php/tests/S3ClientTest.php
Expand Up @@ -38,9 +38,9 @@ public function tearDown()
{
if ( ! $this->client->doesBucketExist($this->bucket)) { return; }

$objectKeys = $this->client->listObjects(array('Bucket' => $this->bucket))['Contents'];
foreach ($objectKeys as $key) {
$this->client->deleteObject(array('Bucket' => $this->bucket, 'Key' => $key['Key']));
$objects = $this->client->getIterator('ListObjects', array('Bucket' => $this->bucket));
foreach ($objects as $object) {
$this->client->deleteObject(array('Bucket' => $this->bucket, 'Key' => $object['Key']));
}
$this->client->deleteBucket(array('Bucket' => $this->bucket));
}
Expand Down
28 changes: 27 additions & 1 deletion client_tests/php/tests/bootstrap.php
Expand Up @@ -21,5 +21,31 @@
---------------------------------------------------------------------
*/
require_once 'vendor/autoload.php';
Guzzle\Tests\GuzzleTestCase::setServiceBuilder(Aws\Common\Aws::factory($_SERVER['CONFIG']));
use Guzzle\Http\Client;

function newServiceBuilder() {
$user = creat_user();
return Aws\Common\Aws::factory($_SERVER['CONFIG'], array(
'key' => $user['key_id'],
'secret' => $user['key_secret'],
'curl.options' => array('CURLOPT_PROXY' => 'localhost:' . cs_port())
));
}

function creat_user() {
$name = uniqid('riakcs-');
$client = new Client('http://localhost:' . cs_port());
$request = $client->put('/riak-cs/user',
array('Content-Type' => 'application/json'),
"{\"name\":\"{$name}\", \"email\":\"{$name}@example.com\"}");
return $request->send()->json();
}

function cs_port() {
return getenv('CS_HTTP_PORT') ? getenv('CS_HTTP_PORT') : 8080;
}


Guzzle\Tests\GuzzleTestCase::setServiceBuilder(newServiceBuilder());

?>

0 comments on commit 6192547

Please sign in to comment.