/** * @covers Guzzle\Aws\S3\Command\Bucket\PutBucketContentsAcl * @covers Guzzle\Aws\S3\Command\Bucket\PutBucketContentsAcl::process * @covers Guzzle\Aws\S3\Command\Bucket\PutBucketContentsAcl::setAcl * @covers Guzzle\Aws\S3\Command\Bucket\PutBucketContentsAcl::getResult * @covers Guzzle\Service\ResourceIteratorApplyBatched */ public function testIterativeAclSet() { $command = new PutBucketContentsAcl(); $command->setBucket('test'); $acl = new Acl(); $acl->getGrantList()->addGrant(S3Client::GRANT_TYPE_GROUP, S3Client::GRANT_ALL, S3Client::GRANT_READ); $this->assertSame($command, $command->setAcl($acl)); $client = $this->getServiceBuilder()->get('test.s3'); $this->setMockResponse($client, array('ListBucketNextMarkerPrefixMarkerResponse', 'ListBucketResponse', 'PutObjectAclResponse', 'PutObjectAclResponse', 'PutObjectAclResponse', 'PutObjectAclResponse')); $client->execute($command); $requests = $this->getMockedRequests(); // Two list buckets followed by deletes for each key found in the results $this->assertEquals('GET', $requests[0]->getMethod()); $this->assertEquals('GET', $requests[1]->getMethod()); $this->assertEquals('PUT', $requests[2]->getMethod()); $this->assertEquals('/?acl', $requests[2]->getResourceUri()); $this->assertEquals('PUT', $requests[3]->getMethod()); $this->assertEquals('/?acl', $requests[3]->getResourceUri()); $this->assertEquals('PUT', $requests[4]->getMethod()); $this->assertEquals('/?acl', $requests[4]->getResourceUri()); $this->assertEquals('PUT', $requests[5]->getMethod()); $this->assertEquals('/?acl', $requests[5]->getResourceUri()); $this->assertEquals(4, $command->getResult()->getIteratedCount()); $this->assertEquals(1, $command->getResult()->getBatchCount()); }
/** * @covers Guzzle\Aws\S3\Model\Acl::__construct */ public function testCanBuildFromExisting() { $xml = new \SimpleXMLElement('<AccessControlPolicy><Owner><ID>test_id</ID><DisplayName>Bob</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group"><URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>'); $acl = new Acl($xml); $this->assertEquals('Bob', $acl->getOwnerDisplayName()); $this->assertEquals('test_id', $acl->getOwnerId()); $this->assertTrue($acl->getGrantList()->hasGrant('Group', \Guzzle\Aws\S3\S3Client::GRANT_AUTH, \Guzzle\Aws\S3\S3Client::GRANT_FULL_CONTROL)); }