OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
reader
/
aws-ses
/
vendor
/
aws
/
aws-sdk-php
/
tests
/
S3
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:15 AM
rwxr-xr-x
📄
AmbiguousSuccessParserTest.php
3.68 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
ApplyChecksumMiddlewareTest.php
7.42 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
BatchDeleteTest.php
6.73 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
BucketEndpointArnMiddlewareTest.php
21.78 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
BucketEndpointMiddlewareTest.php
6.02 KB
05/19/2025 10:07:15 AM
rw-r--r--
📁
Crypto
-
05/19/2025 10:07:15 AM
rwxr-xr-x
📁
Exception
-
05/19/2025 10:07:15 AM
rwxr-xr-x
📄
GetBucketLocationParserTest.php
1.34 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
MultipartCopyTest.php
4.94 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
MultipartUploaderTest.php
12.52 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
ObjectCopierTest.php
15.15 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
ObjectUploaderTest.php
11.32 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
PermanentRedirectMiddlewareTest.php
982 bytes
05/19/2025 10:07:15 AM
rw-r--r--
📄
PostObjectTest.php
3.52 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
PostObjectV4Test.php
11.12 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
PutObjectUrlMiddlewareTest.php
2 KB
05/19/2025 10:07:15 AM
rw-r--r--
📁
RegionalEndpoint
-
05/19/2025 10:07:15 AM
rwxr-xr-x
📄
RetryableMalformedResponseParserTest.php
934 bytes
05/19/2025 10:07:15 AM
rw-r--r--
📄
S3ClientTest.php
92.05 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
S3EndpointMiddlewareTest.php
30.05 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
S3MultiRegionClientTest.php
24.99 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
S3UriParserTest.php
7.45 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
SSECMiddlewareTest.php
2.91 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
StreamWrapperPathStyleTest.php
30.16 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
StreamWrapperTest.php
36.33 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
StreamWrapperV2ExistenceTest.php
32.63 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
TransferTest.php
14.24 KB
05/19/2025 10:07:15 AM
rw-r--r--
📁
UseArnRegion
-
05/19/2025 10:07:15 AM
rwxr-xr-x
📄
ValidateResponseChecksumParserTest.php
5.45 KB
05/19/2025 10:07:15 AM
rw-r--r--
📄
sig_hack.php
226 bytes
05/19/2025 10:07:15 AM
rw-r--r--
📁
test_cases
-
03/03/2025 08:45:28 AM
rwxr-xr-x
Editing: BatchDeleteTest.php
Close
<?php namespace Aws\Test\S3; use Aws\CommandInterface; use Aws\MockHandler; use Aws\Result; use Aws\S3\BatchDelete; use Aws\S3\Exception\DeleteMultipleObjectsException; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; /** * @covers \Aws\S3\BatchDelete */ class BatchDeleteTest extends TestCase { use UsesServiceTrait; public function testValidatesBatchSizeIsGreatherThanZero() { $this->expectException(\InvalidArgumentException::class); $client = $this->getTestClient('s3'); BatchDelete::fromIterator($client, 'foo', new \ArrayIterator(), ['batch_size' => 0]); } public function testValidatesBeforeIsCallable() { $this->expectException(\InvalidArgumentException::class); $client = $this->getTestClient('s3'); BatchDelete::fromIterator($client, 'foo', new \ArrayIterator(), ['before' => 0]); } public function testReturnsSamePromiseInstance() { $client = $this->getTestClient('s3'); $this->addMockResults($client, [[]]); $batch = BatchDelete::fromIterator($client, 'foo', new \ArrayIterator()); $this->assertSame($batch->promise(), $batch->promise()); } public function testBatchesInBatchSize() { $cmds = []; $client = $this->getTestClient('s3'); // Executes three commands. $this->addMockResults($client, [[], [], []]); $keys = []; for ($i = 0; $i < 100; $i++) { $keys[] = ['Key' => 'foo/$i']; } $batch = BatchDelete::fromIterator( $client, 'foo', new \ArrayIterator($keys), [ 'batch_size' => 40, 'before' => function ($cmd) use (&$cmds) { $cmds[] = $cmd; } ] ); $batch->delete(); $this->assertCount(3, $cmds); $this->assertCount(40, $cmds[0]['Delete']['Objects']); $this->assertCount(40, $cmds[1]['Delete']['Objects']); $this->assertCount(20, $cmds[2]['Delete']['Objects']); } public function testThrowsWhenErrorsInIterator() { $client = $this->getTestClient('s3'); $this->addMockResults($client, [ [ 'Deleted' => [['Key' => 'baz']], 'Errors' => [ ['Key' => 'foo', 'Code' => 'bar', 'Message' => 'baz'] ] ] ]); $keys = [['Key' => 'baz'], ['Key' => 'foo']]; $batch = BatchDelete::fromIterator($client, 'foo', new \ArrayIterator($keys)); try { $batch->delete(); $this->fail(); } catch (DeleteMultipleObjectsException $e) { $this->assertCount(1, $e->getErrors()); $this->assertSame('foo', $e->getErrors()[0]['Key']); $this->assertCount(1, $e->getDeleted()); $this->assertSame('baz', $e->getDeleted()[0]['Key']); } } public function testThrowsWhenErrorsInEach() { $client = $this->getTestClient('s3'); $this->addMockResults($client, [ [ 'Contents' => [ ['Key' => 'baz'], ['Key' => 'foo'] ] ], [ 'Deleted' => [['Key' => 'baz']], 'Errors' => [ ['Key' => 'foo', 'Code' => 'bar', 'Message' => 'baz'] ] ] ]); $batch = BatchDelete::fromListObjects($client, ['Bucket' => 'foo']); try { $batch->delete(); $this->fail(); } catch (DeleteMultipleObjectsException $e) { $this->assertCount(1, $e->getErrors()); $this->assertSame('foo', $e->getErrors()[0]['Key']); $this->assertCount(1, $e->getDeleted()); $this->assertSame('baz', $e->getDeleted()[0]['Key']); } } public function testCanCreateFromListObjects() { $client = $this->getTestClient('s3'); $mock = new MockHandler([ new Result([ 'IsTruncated' => false, 'Contents' => [ ['Key' => 'foo'], ['Key' => 'bar'], ] ]), new Result([]) ]); $client->getHandlerList()->setHandler($mock); $params = ['Bucket' => 'foo']; $batch = BatchDelete::fromListObjects($client, $params); $batch->delete(); $last = $mock->getLastCommand(); $this->assertSame('DeleteObjects', $last->getName()); $this->assertCount(2, $last['Delete']['Objects']); $this->assertSame('foo', $last['Bucket']); } public function testDeletesYieldedCommandsWhenEachCallbackReturns() { $client = $this->getTestClient('s3'); $this->addMockResults($client, [ [ 'Contents' => [ ['Key' => 0], ['Key' => 1], ['Key' => 2], ['Key' => 3], ['Key' => 4], ['Key' => 5], ['Key' => 6], ['Key' => 7], ['Key' => 8], ['Key' => 9], ] ], ['Deleted' => []], ['Deleted' => []], ['Deleted' => []], ['Deleted' => []], ]); $cmds = []; $batch = BatchDelete::fromListObjects( $client, ['Bucket' => 'foo'], [ 'batch_size' => 4, 'before' => function (CommandInterface $cmd) use (&$cmds) { $cmds[] = $cmd; } ] ); $batch->delete(); $this->assertCount(3, $cmds); $keys = \JmesPath\search('[].Delete.Objects[].Key', $cmds); $this->assertEquals(range(0, 9), $keys); } public function testWithNoMatchingObjects() { $client = $this->getTestClient('s3'); $mock = new MockHandler([ new Result([ 'IsTruncated' => false, 'Contents' => null ]), new Result([]) ]); $client->getHandlerList()->setHandler($mock); $params = ['Bucket' => 'foo']; $batch = BatchDelete::fromListObjects($client, $params); $batch->delete(); $last = $mock->getLastCommand(); $this->assertSame('ListObjects', $last->getName()); $this->assertFalse(isset($last['Delete']['Objects'])); $this->assertSame('foo', $last['Bucket']); } }