2022-02-20 20:22:07 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Akeeba Engine
|
|
|
|
|
*
|
|
|
|
|
* @package akeebaengine
|
2024-03-20 03:03:34 +00:00
|
|
|
|
* @copyright Copyright (c)2006-2024 Nicholas K. Dionysopoulos / Akeeba Ltd
|
2022-02-20 20:22:07 +00:00
|
|
|
|
* @license GNU General Public License version 3, or later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Akeeba\MiniTest\Test;
|
|
|
|
|
|
|
|
|
|
|
2023-12-19 02:28:16 +00:00
|
|
|
|
use Akeeba\S3\Connector;
|
2022-02-20 20:22:07 +00:00
|
|
|
|
use RuntimeException;
|
|
|
|
|
|
|
|
|
|
class BucketsList extends AbstractTest
|
|
|
|
|
{
|
|
|
|
|
public static function listBucketsDetailed(Connector $s3, array $options): bool
|
|
|
|
|
{
|
|
|
|
|
$buckets = $s3->listBuckets(true);
|
|
|
|
|
|
2023-12-19 02:28:16 +00:00
|
|
|
|
static::assert(is_array($buckets), "Detailed buckets list is not an array");
|
|
|
|
|
static::assert(isset($buckets['owner']), "Detailed buckets list does not list an owner");
|
|
|
|
|
static::assert(isset($buckets['owner']['id']), "Detailed buckets list does not list an owner's id");
|
|
|
|
|
static::assert(isset($buckets['owner']['name']), "Detailed buckets list does not list an owner's name");
|
|
|
|
|
static::assert(isset($buckets['buckets']), "Detailed buckets list does not list any buckets");
|
2022-02-20 20:22:07 +00:00
|
|
|
|
|
|
|
|
|
foreach ($buckets['buckets'] as $bucketInfo)
|
|
|
|
|
{
|
2023-12-19 02:28:16 +00:00
|
|
|
|
static::assert(isset($bucketInfo['name']), "Bucket information does not list a name");
|
|
|
|
|
static::assert(isset($bucketInfo['time']), "Bucket information does not list a created times");
|
2022-02-20 20:22:07 +00:00
|
|
|
|
|
|
|
|
|
if ($bucketInfo['name'] === $options['bucket'])
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("Detailed buckets list does not include configured bucket ‘{$options['bucket']}′");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function listBucketsSimple(Connector $s3, array $options): bool
|
|
|
|
|
{
|
|
|
|
|
$buckets = $s3->listBuckets(false);
|
|
|
|
|
|
2023-12-19 02:28:16 +00:00
|
|
|
|
static::assert(is_array($buckets), "Simple buckets list is not an array");
|
|
|
|
|
static::assert(in_array($options['bucket'], $buckets), "Simple buckets list does not include configured bucket ‘{$options['bucket']}′");
|
2022-02-20 20:22:07 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|