From daa7ceb978f7b8671040144cc89c401af058285a Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 11:37:18 -0300 Subject: [PATCH 01/17] allow authentication be passed as array --- src/Authentication/MicrosoftEntraId.php | 30 +++++++++++++++++------ src/Authentication/SharedKeyAuth.php | 17 +++++++++++-- src/Exceptions/RequiredFieldException.php | 4 +-- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/Authentication/MicrosoftEntraId.php b/src/Authentication/MicrosoftEntraId.php index c2bdd6a..483309d 100644 --- a/src/Authentication/MicrosoftEntraId.php +++ b/src/Authentication/MicrosoftEntraId.php @@ -11,25 +11,39 @@ use Xray\AzureStoragePhpSdk\Concerns\UseCurrentHttpDate; use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; use Xray\AzureStoragePhpSdk\Contracts\Http\Request; -use Xray\AzureStoragePhpSdk\Exceptions\RequestException; +use Xray\AzureStoragePhpSdk\Exceptions\{RequestException, RequiredFieldException}; final class MicrosoftEntraId implements Auth { use UseCurrentHttpDate; + protected string $account; + + protected string $directoryId; + + protected string $applicationId; + + protected string $applicationSecret; + protected ?ClientInterface $client = null; protected string $token = ''; protected ?DateTime $tokenExpiresAt = null; - public function __construct( - protected string $account, - protected string $directoryId, - protected string $applicationId, - protected string $applicationSecret, - ) { - // + /** @param array{account: string, directory: string, application: string, secret: string} $config */ + public function __construct(array $config) + { + if (!isset($config['account'], $config['directory'], $config['application'], $config['secret'])) { + $missingParameters = array_diff(['account', 'directory', 'application', 'secret'], array_keys($config)); + + throw RequiredFieldException::create('Missing required parameters: ' . implode(', ', $missingParameters)); + } + + $this->account = $config['account']; + $this->directoryId = $config['directory']; + $this->applicationId = $config['application']; + $this->applicationSecret = $config['secret']; } public function withRequestClient(ClientInterface $client): self diff --git a/src/Authentication/SharedKeyAuth.php b/src/Authentication/SharedKeyAuth.php index 8f6a488..bc61591 100644 --- a/src/Authentication/SharedKeyAuth.php +++ b/src/Authentication/SharedKeyAuth.php @@ -7,14 +7,27 @@ use Xray\AzureStoragePhpSdk\Concerns\UseCurrentHttpDate; use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; use Xray\AzureStoragePhpSdk\Contracts\Http\Request; +use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; final class SharedKeyAuth implements Auth { use UseCurrentHttpDate; - public function __construct(protected string $account, protected string $key) + protected string $account; + + protected string $key; + + /** @param array{account: string, key: string} $config */ + public function __construct(array $config) { - // + if (!isset($config['account'], $config['key'])) { + $missingParameters = array_diff(['account', 'key'], array_keys($config)); + + throw RequiredFieldException::create('Missing required parameters: ' . implode(', ', $missingParameters)); + } + + $this->account = $config['account']; + $this->key = $config['key']; } public function getAccount(): string diff --git a/src/Exceptions/RequiredFieldException.php b/src/Exceptions/RequiredFieldException.php index 2c3f737..5333f3f 100644 --- a/src/Exceptions/RequiredFieldException.php +++ b/src/Exceptions/RequiredFieldException.php @@ -8,9 +8,9 @@ final class RequiredFieldException extends Exception { - protected function __construct(string $message) + public static function create(string $message): static { - parent::__construct($message); + return new static($message); } public static function missingField(string $field): static From b3663deb9a51a521dfd64a2b3556b5395f359b49 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 12:58:54 -0300 Subject: [PATCH 02/17] enhance collections class --- src/Support/Collection.php | 311 ++++++++++++++++++++++++++++++++++--- 1 file changed, 293 insertions(+), 18 deletions(-) diff --git a/src/Support/Collection.php b/src/Support/Collection.php index 37b356a..9f83f55 100644 --- a/src/Support/Collection.php +++ b/src/Support/Collection.php @@ -4,19 +4,23 @@ namespace Xray\AzureStoragePhpSdk\Support; +use ArgumentCountError; use ArrayAccess; use ArrayIterator; use IteratorAggregate; use JsonSerializable; use Traversable; +use Xray\AzureStoragePhpSdk\Contracts\Arrayable; /** - * @template TKey of array-key - * @template TValue of object + * @template TKey + * @template TValue + * + * @implements Arrayable>> * @implements IteratorAggregate * @implements ArrayAccess */ -class Collection implements IteratorAggregate, ArrayAccess, JsonSerializable +class Collection implements Arrayable, IteratorAggregate, ArrayAccess, JsonSerializable { /** @param array $items */ public function __construct(protected array $items = []) @@ -30,43 +34,312 @@ public function all(): array return $this->items; } - /** @return TValue|null */ - public function first(): ?object + /** + * Get the first item from the collection passing the given truth test. + * + * @template TFirstDefault + * + * @param (callable(TValue, TKey): bool)|null $callback + * @param TFirstDefault|(\Closure(): TFirstDefault) $default + * @return TValue|TFirstDefault|null + */ + public function first(?callable $callback = null, mixed $default = null): mixed + { + /** @var TFirstDefault $default */ + $default = is_callable($default) + ? call_user_func($default) + : $default; + + if (is_null($callback)) { + if ($this->isEmpty()) { + return $default; + } + + foreach ($this as $item) { + return $item; + } + + return $default; + } + + foreach ($this as $key => $value) { + if ($callback($value, $key)) { + return $value; + } + } + + return $default; + } + + /** + * Get the last item from the collection. + * + * @template TLastDefault + * + * @param (callable(TValue, TKey): bool)|null $callback + * @param TLastDefault|(\Closure(): TLastDefault) $default + * @return TValue|TLastDefault|null + */ + public function last(?callable $callback = null, mixed $default = null): mixed { - return $this->get(0); + /** @var TLastDefault $default */ + $default = is_callable($default) + ? call_user_func($default) + : $default; + + if (is_null($callback)) { + if ($this->isEmpty()) { + return $default; + } + + foreach (array_reverse($this->items, true) as $item) { + return $item; + } + + return $default; + } + + foreach (array_reverse($this->items, true) as $key => $value) { + if ($callback($value, $key)) { + return $value; + } + } + + return $default; } - /** @return TValue|null */ - public function last(): ?object + /** + * Get an item from the collection by key. + * + * @template TGetDefault + * + * @param (int&TKey)|(string&TKey) $key + * @param TGetDefault|(\Closure(): TGetDefault) $default + * @return TValue|TGetDefault + */ + public function get(string|int $key, mixed $default = null) { - return $this->get(count($this->items) - 1); + if (array_key_exists($key, $this->items)) { + return $this->items[$key]; + } + + return is_callable($default) + ? call_user_func($default) + : $default; } /** - * @param TKey $key - * @return TValue|null + * Get the keys of the collection items. + * + * @return self */ - public function get(int|string $key): ?object + public function keys(): static // @phpstan-ignore-line { - return $this->items[$key] ?? null; + // @phpstan-ignore-next-line + return new static(array_keys($this->items)); } + /** + * Count the number of items in the collection. + */ public function count(): int { return count($this->items); } + /** + * Determine if the collection is empty or not. + * + * @phpstan-assert-if-true null $this->first() + * + * @phpstan-assert-if-false TValue $this->first() + */ public function isEmpty(): bool { return empty($this->items); } + /** + * Determine if the collection is not empty. + * + * @phpstan-assert-if-true TValue $this->first() + * + * @phpstan-assert-if-false null $this->first() + */ public function isNotEmpty(): bool { - return !empty($this->items); + return !$this->isEmpty(); + } + + /** + * Push one or more items onto the end of the collection. + * + * @param TValue ...$values + */ + public function push(mixed ...$values): static + { + foreach ($values as $value) { + $this->items[] = $value; + } + + return $this; + } + + /** + * Merge the collection with the given items. + * + * @param iterable $items + */ + public function merge(iterable $items): static + { + // @phpstan-ignore-next-line + return new static(array_merge($this->items, $items)); + } + + /** + * Push all of the given items onto the collection. + * + * @param iterable<(int&TKey)|(string&TKey), TValue> $source + * @return static + */ + public function concat(iterable $source): static // @phpstan-ignore-line + { + // @phpstan-ignore-next-line + $result = new static($this->items); + + foreach ($source as $item) { + $result->push($item); + } + + return $result; + } + + /** + * Put an item in the collection by key. + * + * @param (int&TKey)|(string&TKey) $key + * @param TValue $value + */ + public function put(string|int $key, mixed $value): static + { + $this->offsetSet($key, $value); + + return $this; + } + + /** + * Remove an item from the collection by key. + * + * @param (iterable)|(int&TKey)|(string&TKey) $keys + */ + public function forget(iterable|string|int $keys): static + { + $keys = !is_iterable($keys) ? func_get_args() : $keys; + // @phpstan-ignore-next-line + $keysToRemove = $this->filter(function (string|int $key) use ($keys): bool { + return in_array($key, $keys); // @phpstan-ignore-line + }, ARRAY_FILTER_USE_KEY); + + /** @var TKey $key */ + foreach ($keysToRemove as $key) { + $this->offsetUnset($key); + } + + return $this; + } + + /** + * Get a value from the array, and remove it. + * + * @param (int&TKey)|(string&TKey) $key + */ + public function pull(string|int $key, mixed $default = null): mixed + { + $value = $this->get($key, $default); + + $this->forget($key); + + return $value; + } + + /** + * Run a map over each of the items. + * + * @template TMapValue + * + * @param callable(TValue, TKey): TMapValue $callback + * @return static + */ + public function map(callable $callback) + { + $keys = array_keys($this->items); + + try { + $items = array_map($callback, $this->items, $keys); + } catch (ArgumentCountError) { + $items = array_map($callback, $this->items); // @phpstan-ignore-line + } + + // @phpstan-ignore-next-line + return new static(array_combine($keys, $items)); + } + + /** + * Execute a callback over each item. + * + * @param callable(TValue, TKey): mixed $callback + * @return $this + */ + public function each(callable $callback): static + { + foreach ($this as $key => $item) { + if ($callback($item, $key) === false) { + break; + } + } + + return $this; + } + + /** + * Run a filter over each of the items. + * + * @param (callable(TValue, TKey): bool)|null $callback + * @param int $mode - Available options are: 0: ARRAY_FILTER_USE_VALUE, 1: ARRAY_FILTER_USE_BOTH or 2: ARRAY_FILTER_USE_KEY + * @return static + */ + public function filter(?callable $callback = null, int $mode = ARRAY_FILTER_USE_BOTH) + { + if ($callback) { + // @phpstan-ignore-next-line + return new static(array_filter($this->items, $callback, $mode)); + } + + // @phpstan-ignore-next-line + return new static(array_filter($this->items)); + } + + /** + * Convert the collection to its array representation. + * + * @return array> + */ + public function toArray(): array + { + $items = $this->items; + + foreach ($items as $key => $item) { + $items[$key] = match (true) { + $item instanceof Arrayable => $item->toArray(), + $item instanceof JsonSerializable => $item->jsonSerialize(), + default => $item, + }; + } + + return $items; } - /** @return Traversable */ + /** @return ArrayIterator<(int&TKey)|(string&TKey), TValue> */ public function getIterator(): Traversable { return new ArrayIterator($this->items); @@ -84,16 +357,18 @@ public function offsetExists(mixed $offset): bool } /** - * @param TKey $offset + * @param (int&TKey)|(string&TKey) $offset * @return TValue|null */ - public function offsetGet(mixed $offset): ?object + public function offsetGet(mixed $offset): mixed { return $this->get($offset); } /** - * @param TKey $offset + * Set an item in the collection by key. + * + * @param (int&TKey)|(string&TKey) $offset * @param TValue $value */ public function offsetSet(mixed $offset, mixed $value): void From 61827d337f31652bde821b2c512cc22dbb4e8b84 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 12:59:21 -0300 Subject: [PATCH 03/17] add new property to container properties --- .../Entities/Container/ContainerProperties.php | 12 ++++++++---- src/BlobStorage/Resource.php | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/BlobStorage/Entities/Container/ContainerProperties.php b/src/BlobStorage/Entities/Container/ContainerProperties.php index 3813163..adce3d2 100644 --- a/src/BlobStorage/Entities/Container/ContainerProperties.php +++ b/src/BlobStorage/Entities/Container/ContainerProperties.php @@ -5,6 +5,7 @@ namespace Xray\AzureStoragePhpSdk\BlobStorage\Entities\Container; use DateTimeImmutable; +use Xray\AzureStoragePhpSdk\BlobStorage\Resource; final readonly class ContainerProperties { @@ -32,6 +33,8 @@ public bool $xMsDenyEncryptionScopeOverride; + public ?string $blobPublicAccess; + public DateTimeImmutable $date; /** @param array $containerProperty */ @@ -40,15 +43,16 @@ public function __construct(array $containerProperty) $this->lastModified = new DateTimeImmutable($containerProperty['Last-Modified'] ?? 'now'); $this->eTag = $containerProperty['ETag'] ?? ''; $this->server = $containerProperty['Server'] ?? ''; - $this->xMsRequestId = $containerProperty['x-ms-request-id'] ?? ''; - $this->xMsVersion = $containerProperty['x-ms-version'] ?? ''; - $this->xMsLeaseStatus = $containerProperty['x-ms-lease-status'] ?? ''; - $this->xMsLeaseState = $containerProperty['x-ms-lease-state'] ?? ''; + $this->xMsRequestId = $containerProperty[Resource::REQUEST_ID] ?? ''; + $this->xMsVersion = $containerProperty[Resource::AUTH_VERSION] ?? ''; + $this->xMsLeaseStatus = $containerProperty[Resource::LEASE_STATUS] ?? ''; + $this->xMsLeaseState = $containerProperty[Resource::LEASE_STATE] ?? ''; $this->xMsHasImmutabilityPolicy = to_boolean($containerProperty['x-ms-has-immutability-policy'] ?? ''); $this->xMsHasLegalHold = to_boolean($containerProperty['x-ms-has-legal-hold'] ?? ''); $this->xMsImmutableStorageWithVersioningEnabled = to_boolean($containerProperty['x-ms-immutable-storage-with-versioning-enabled'] ?? ''); $this->xMsDefaultEncryptionScopeOverride = $containerProperty['x-ms-default-encryption-scope'] ?? ''; $this->xMsDenyEncryptionScopeOverride = to_boolean($containerProperty['x-ms-deny-encryption-scope-override'] ?? ''); $this->date = new DateTimeImmutable($containerProperty['Date'] ?? 'now'); + $this->blobPublicAccess = $containerProperty[Resource::BLOB_PUBLIC_ACCESS] ?? null; } } diff --git a/src/BlobStorage/Resource.php b/src/BlobStorage/Resource.php index c9015ea..186a806 100644 --- a/src/BlobStorage/Resource.php +++ b/src/BlobStorage/Resource.php @@ -21,11 +21,14 @@ final class Resource public const string CONTENT_LENGTH = 'Content-Length'; public const string REQUEST_ID = 'x-ms-request-id'; - public const string LEASE_ID = 'x-ms-lease-id'; + public const string LEASE_ID = 'x-ms-lease-id'; + public const string LEASE_ACTION = 'x-ms-lease-action'; public const string LEASE_BREAK_PERIOD = 'x-ms-lease-break-period'; public const string LEASE_DURATION = 'x-ms-lease-duration'; public const string LEASE_PROPOSED_ID = 'x-ms-proposed-lease-id'; + public const string LEASE_STATUS = 'x-ms-lease-status'; + public const string LEASE_STATE = 'x-ms-lease-state'; public const string DELETE_CONTAINER_NAME = 'x-ms-deleted-container-name'; public const string DELETE_CONTAINER_VERSION = 'x-ms-deleted-container-version'; @@ -38,6 +41,7 @@ final class Resource public const string PAGE_WRITE = 'x-ms-page-write'; public const string RANGE = 'x-ms-range'; + public const string BLOB_PUBLIC_ACCESS = 'x-ms-blob-public-access'; public const string BLOB_CACHE_CONTROL = 'x-ms-blob-cache-control'; public const string BLOB_CONTENT_TYPE = 'x-ms-blob-content-type'; public const string BLOB_CONTENT_MD5 = 'x-ms-blob-content-md5'; From ebe1eaddc5d2c8618d2059294b4e0fdd522bf208 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 12:59:32 -0300 Subject: [PATCH 04/17] fix phpstan issues --- src/Authentication/MicrosoftEntraId.php | 1 + src/Authentication/SharedKeyAuth.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Authentication/MicrosoftEntraId.php b/src/Authentication/MicrosoftEntraId.php index 483309d..3eae9eb 100644 --- a/src/Authentication/MicrosoftEntraId.php +++ b/src/Authentication/MicrosoftEntraId.php @@ -34,6 +34,7 @@ final class MicrosoftEntraId implements Auth /** @param array{account: string, directory: string, application: string, secret: string} $config */ public function __construct(array $config) { + // @phpstan-ignore-next-line if (!isset($config['account'], $config['directory'], $config['application'], $config['secret'])) { $missingParameters = array_diff(['account', 'directory', 'application', 'secret'], array_keys($config)); diff --git a/src/Authentication/SharedKeyAuth.php b/src/Authentication/SharedKeyAuth.php index bc61591..85f18d1 100644 --- a/src/Authentication/SharedKeyAuth.php +++ b/src/Authentication/SharedKeyAuth.php @@ -20,6 +20,7 @@ final class SharedKeyAuth implements Auth /** @param array{account: string, key: string} $config */ public function __construct(array $config) { + // @phpstan-ignore-next-line if (!isset($config['account'], $config['key'])) { $missingParameters = array_diff(['account', 'key'], array_keys($config)); From 26eed362829c42382dee025d9a4acee9000abffe Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 12:59:44 -0300 Subject: [PATCH 05/17] add new methods to client --- src/BlobStorage/BlobStorageClient.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/BlobStorage/BlobStorageClient.php b/src/BlobStorage/BlobStorageClient.php index 432479e..589cb54 100644 --- a/src/BlobStorage/BlobStorageClient.php +++ b/src/BlobStorage/BlobStorageClient.php @@ -25,6 +25,16 @@ public static function create(Auth $auth, array $config = []): static return new static(new Request($auth, new Config($config))); } + public function getRequest(): RequestContract + { + return $this->request; + } + + public function config(): Config + { + return $this->request->getConfig(); + } + public function account(): AccountManager { return azure_app(AccountManager::class); From a0971a4d2fddd95b70268a639c16736c760a4454 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 14:08:28 -0300 Subject: [PATCH 06/17] adjust all tests --- composer.json | 8 +- src/BlobStorage/BlobStorageClient.php | 2 +- src/Support/Collection.php | 15 +- src/Tests/Http/RequestFake.php | 2 +- .../Authentication/MicrosoftEntraIdTest.php | 42 +++- .../UserDelegationSasTest.php | 17 +- .../Authentication/SharedKeyAuthTest.php | 26 ++- ...rageTest.php => BlobStorageClientTest.php} | 18 +- .../Blob/BlobStorageBlobManagerTest.php | 8 +- tests/Feature/Http/RequestTest.php | 16 +- tests/Feature/Support/CollectionTest.php | 212 ++++++++++++++++++ .../Exceptions/RequiredFieldExceptionTest.php | 6 + 12 files changed, 335 insertions(+), 37 deletions(-) rename tests/Feature/BlobStorage/{BlobStorageTest.php => BlobStorageClientTest.php} (64%) diff --git a/composer.json b/composer.json index 465c3fe..47307f0 100644 --- a/composer.json +++ b/composer.json @@ -39,13 +39,17 @@ ], "autoload": { "psr-4": { - "Xray\\AzureStoragePhpSdk\\": "src/", - "Xray\\Tests\\": "tests/" + "Xray\\AzureStoragePhpSdk\\": "src/" }, "files": [ "src/helpers.php" ] }, + "autoload-dev": { + "psr-4": { + "Xray\\Tests\\": "tests/" + } + }, "minimum-stability": "stable", "config": { "allow-plugins": { diff --git a/src/BlobStorage/BlobStorageClient.php b/src/BlobStorage/BlobStorageClient.php index 589cb54..a731688 100644 --- a/src/BlobStorage/BlobStorageClient.php +++ b/src/BlobStorage/BlobStorageClient.php @@ -30,7 +30,7 @@ public function getRequest(): RequestContract return $this->request; } - public function config(): Config + public function getConfig(): Config { return $this->request->getConfig(); } diff --git a/src/Support/Collection.php b/src/Support/Collection.php index 9f83f55..57b9b8c 100644 --- a/src/Support/Collection.php +++ b/src/Support/Collection.php @@ -59,7 +59,7 @@ public function first(?callable $callback = null, mixed $default = null): mixed return $item; } - return $default; + return $default; // @codeCoverageIgnore } foreach ($this as $key => $value) { @@ -96,7 +96,7 @@ public function last(?callable $callback = null, mixed $default = null): mixed return $item; } - return $default; + return $default; // @codeCoverageIgnore } foreach (array_reverse($this->items, true) as $key => $value) { @@ -235,13 +235,9 @@ public function put(string|int $key, mixed $value): static public function forget(iterable|string|int $keys): static { $keys = !is_iterable($keys) ? func_get_args() : $keys; - // @phpstan-ignore-next-line - $keysToRemove = $this->filter(function (string|int $key) use ($keys): bool { - return in_array($key, $keys); // @phpstan-ignore-line - }, ARRAY_FILTER_USE_KEY); /** @var TKey $key */ - foreach ($keysToRemove as $key) { + foreach ($keys as $key) { $this->offsetUnset($key); } @@ -276,9 +272,12 @@ public function map(callable $callback) try { $items = array_map($callback, $this->items, $keys); + + // @codeCoverageIgnoreStart } catch (ArgumentCountError) { $items = array_map($callback, $this->items); // @phpstan-ignore-line } + // @codeCoverageIgnoreEnd // @phpstan-ignore-next-line return new static(array_combine($keys, $items)); @@ -294,7 +293,7 @@ public function each(callable $callback): static { foreach ($this as $key => $item) { if ($callback($item, $key) === false) { - break; + break; // @codeCoverageIgnore } } diff --git a/src/Tests/Http/RequestFake.php b/src/Tests/Http/RequestFake.php index 7efb030..e66a1f4 100644 --- a/src/Tests/Http/RequestFake.php +++ b/src/Tests/Http/RequestFake.php @@ -49,7 +49,7 @@ class RequestFake implements Request public function __construct(?Auth $auth = null, ?Config $config = null) { - $this->auth = $auth ?? azure_app(SharedKeyAuth::class, ['account' => 'account', 'key' => 'key']); + $this->auth = $auth ?? azure_app(SharedKeyAuth::class, ['config' => ['account' => 'account', 'key' => 'key']]); $this->config = $config ?? azure_app(Config::class); } diff --git a/tests/Feature/Authentication/MicrosoftEntraIdTest.php b/tests/Feature/Authentication/MicrosoftEntraIdTest.php index 8f0e908..dfe744f 100644 --- a/tests/Feature/Authentication/MicrosoftEntraIdTest.php +++ b/tests/Feature/Authentication/MicrosoftEntraIdTest.php @@ -5,6 +5,7 @@ use Xray\AzureStoragePhpSdk\Authentication\MicrosoftEntraId; use Xray\AzureStoragePhpSdk\BlobStorage\Enums\HttpVerb; use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; +use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; use Xray\Tests\Fakes\ClientFake; @@ -15,15 +16,44 @@ ->toImplement(Auth::class); }); +it('should fail if any required field is missing', function (string $field) { + $config = [ + 'account' => 'account', + 'directory' => 'directory', + 'application' => 'application', + 'secret' => 'secret', + ]; + + unset($config[$field]); + + expect(fn () => new MicrosoftEntraId($config)) + ->toThrow(RequiredFieldException::class, "Missing required parameters: {$field}"); +})->with([ + 'Missing Account' => ['account'], + 'Missing Directory' => ['directory'], + 'Missing Application' => ['application'], + 'Missing Secret' => ['secret'], +]); + it('should get date formatted correctly', function () { - $auth = new MicrosoftEntraId('account', 'directory', 'application', 'secret'); + $auth = new MicrosoftEntraId([ + 'account' => 'account', + 'directory' => 'directory', + 'application' => 'application', + 'secret' => 'secret', + ]); expect($auth->getDate()) ->toBe(gmdate('D, d M Y H:i:s T')); }); it('should get the authentication account', function () { - $auth = new MicrosoftEntraId('account', 'directory', 'application', 'secret'); + $auth = new MicrosoftEntraId([ + 'account' => 'account', + 'directory' => 'directory', + 'application' => 'application', + 'secret' => 'secret', + ]); expect($auth->getAccount()) ->toBe('account'); @@ -40,8 +70,12 @@ $client = (new ClientFake()) ->withResponseFake($body); - $auth = (new MicrosoftEntraId('account', 'directory', $application = 'application', $secret = 'secret')) - ->withRequestClient($client); + $auth = (new MicrosoftEntraId([ + 'account' => 'account', + 'directory' => 'directory', + 'application' => $application = 'application', + 'secret' => $secret = 'secret', + ]))->withRequestClient($client); expect($auth->getAuthentication(new RequestFake())) ->toBe("{$tokeType} {$token}"); diff --git a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php index 21748e3..3c8827d 100644 --- a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php +++ b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php @@ -19,7 +19,7 @@ }); it('should throw an exception if the authentication method is not supported', function () { - $request = new RequestFake(new SharedKeyAuth('account', 'key')); + $request = new RequestFake(new SharedKeyAuth(['account' => 'account', 'key' => 'key'])); (new UserDelegationSas($request)) ->buildTokenUrl(AccessTokenPermission::READ, new DateTimeImmutable()); @@ -39,8 +39,12 @@ XML; - $request = (new RequestFake(new MicrosoftEntraId('account', 'directory', 'application', 'secret'))) - ->withFakeResponse(new ResponseFake($body)); + $request = (new RequestFake(new MicrosoftEntraId([ + 'account' => 'account', + 'directory' => 'directory', + 'application' => 'application', + 'secret' => 'secret', + ])))->withFakeResponse(new ResponseFake($body)); (new UserDelegationSas($request)) ->buildTokenUrl(AccessTokenPermission::READ, new DateTimeImmutable()); @@ -75,7 +79,12 @@ $container = 'container'; $blob = 'blob.txt'; - $request = (new RequestFake(new MicrosoftEntraId($account = 'account', 'directory', 'application', 'secret'))) + $request = (new RequestFake(new MicrosoftEntraId([ + 'account' => $account = 'account', + 'directory' => 'directory', + 'application' => 'application', + 'secret' => 'secret', + ]))) ->withFakeResponse(new ResponseFake($body)) ->withResource("/{$container}/{$blob}"); diff --git a/tests/Feature/Authentication/SharedKeyAuthTest.php b/tests/Feature/Authentication/SharedKeyAuthTest.php index 217e4c2..59494a5 100644 --- a/tests/Feature/Authentication/SharedKeyAuthTest.php +++ b/tests/Feature/Authentication/SharedKeyAuthTest.php @@ -6,6 +6,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Enums\HttpVerb; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; +use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; use Xray\AzureStoragePhpSdk\Http\Headers; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; @@ -16,15 +17,30 @@ ->toImplement(Auth::class); }); +it('should fail if any required field is missing', function (string $field) { + $config = [ + 'account' => 'account', + 'key' => 'key', + ]; + + unset($config[$field]); + + expect(fn () => new SharedKeyAuth($config)) + ->toThrow(RequiredFieldException::class, "Missing required parameters: {$field}"); +})->with([ + 'Missing Account' => ['account'], + 'Missing Key' => ['key'], +]); + it('should get date formatted correctly', function () { - $auth = new SharedKeyAuth('account', 'key'); + $auth = new SharedKeyAuth(['account' => 'account', 'key' => 'key']); expect($auth->getDate()) ->toBe(gmdate('D, d M Y H:i:s T')); }); it('should get the authentication account', function () { - $auth = new SharedKeyAuth('account', 'key'); + $auth = new SharedKeyAuth(['account' => 'account', 'key' => 'key']); expect($auth->getAccount()) ->toBe('account'); @@ -33,7 +49,7 @@ it('should get correctly the authentication signature for all http methods', function (HttpVerb $verb) { $decodedKey = 'my-decoded-account-key'; - $auth = new SharedKeyAuth($account = 'account', base64_encode($decodedKey)); + $auth = new SharedKeyAuth(['account' => $account = 'account', 'key' => base64_encode($decodedKey)]); $request = (new RequestFake()) ->withVerb($verb); @@ -57,7 +73,7 @@ it('should get correctly the authentication signature for all headers', function (string $headerMethod, int|string $headerValue) { $decodedKey = 'my-decoded-account-key'; - $auth = new SharedKeyAuth($account = 'account', base64_encode($decodedKey)); + $auth = new SharedKeyAuth(['account' => $account = 'account', 'key' => base64_encode($decodedKey)]); $request = (new RequestFake()) ->withVerb(HttpVerb::GET) @@ -86,7 +102,7 @@ it('should get correctly the authentication signature for all canonical headers', function (string $headerMethod, string $headerValue) { $decodedKey = 'my-decoded-account-key'; - $auth = new SharedKeyAuth($account = 'account', base64_encode($decodedKey)); + $auth = new SharedKeyAuth(['account' => $account = 'account', 'key' => base64_encode($decodedKey)]); $request = (new RequestFake()) ->withVerb(HttpVerb::GET) diff --git a/tests/Feature/BlobStorage/BlobStorageTest.php b/tests/Feature/BlobStorage/BlobStorageClientTest.php similarity index 64% rename from tests/Feature/BlobStorage/BlobStorageTest.php rename to tests/Feature/BlobStorage/BlobStorageClientTest.php index 7a1c8be..9c28c89 100644 --- a/tests/Feature/BlobStorage/BlobStorageTest.php +++ b/tests/Feature/BlobStorage/BlobStorageClientTest.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Xray\AzureStoragePhpSdk\Authentication\SharedKeyAuth; -use Xray\AzureStoragePhpSdk\BlobStorage\BlobStorageClient; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobManager; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\{AccountManager, ContainerManager}; +use Xray\AzureStoragePhpSdk\BlobStorage\{BlobStorageClient, Config}; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; uses()->group('blob-storage'); @@ -21,8 +21,22 @@ 'Blob Manager' => ['blobs', BlobManager::class, ['test']], ]); +it('should get the underneath request', function () { + $request = new RequestFake(); + + expect((new BlobStorageClient($request))->getRequest()) + ->toBeInstanceOf(RequestFake::class); +}); + +it('should get the underneath config', function () { + $request = new RequestFake(); + + expect((new BlobStorageClient($request))->getConfig()) + ->toBeInstanceOf(Config::class); +}); + it('should create a new blob storage client', function () { - $auth = new SharedKeyAuth('account', 'key'); + $auth = new SharedKeyAuth(['account' => 'account', 'key' => 'key']); expect(BlobStorageClient::create($auth)) ->toBeInstanceOf(BlobStorageClient::class); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php index 26c34b1..6c1710a 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php @@ -369,8 +369,12 @@ XML; - $request = (new RequestFake(new MicrosoftEntraId('account', 'directory', 'application', 'secret'))) - ->withFakeResponse(new ResponseFake($body)); + $request = (new RequestFake(new MicrosoftEntraId([ + 'account' => 'account', + 'directory' => 'directory', + 'application' => 'application', + 'secret' => 'secret', + ])))->withFakeResponse(new ResponseFake($body)); $container = 'container'; $blob = 'blob.txt'; diff --git a/tests/Feature/Http/RequestTest.php b/tests/Feature/Http/RequestTest.php index 4252962..3c13d1a 100644 --- a/tests/Feature/Http/RequestTest.php +++ b/tests/Feature/Http/RequestTest.php @@ -12,7 +12,7 @@ uses()->group('http'); it('should send get, delete, and options requests', function (string $method, HttpVerb $verb): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $request = (new Request($auth, client: $client = new ClientFake())) ->withAuthentication() @@ -46,7 +46,7 @@ ]); it('should send post and put requests', function (string $method, HttpVerb $verb): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $request = (new Request($auth, client: $client = new ClientFake())) ->withoutAuthentication() @@ -86,7 +86,7 @@ ]); it('should get request config', function (): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $config = new Config(); expect((new Request($auth, $config, new ClientFake()))->getConfig()) @@ -94,14 +94,14 @@ }); it('should get request auth', function (): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); expect((new Request($auth, client: new ClientFake()))->getAuth()) ->toBe($auth); }); it('should get the http verb from request', function (HttpVerb $verb) { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $request = (new Request($auth, client: new ClientFake())) ->withVerb($verb); @@ -112,7 +112,7 @@ })->with(fn () => HttpVerb::cases()); it('should get the resource from request', function (): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $request = (new Request($auth, client: new ClientFake())) ->withResource('endpoint'); @@ -122,7 +122,7 @@ }); it('should get the headers from request', function (): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $request = (new Request($auth, client: new ClientFake())) ->withHttpHeaders(new Headers()); @@ -132,7 +132,7 @@ }); it('should get the body from request', function (): void { - $auth = new SharedKeyAuth('my_account', 'bar'); + $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); $request = (new Request($auth, client: new ClientFake())) ->withBody('body'); diff --git a/tests/Feature/Support/CollectionTest.php b/tests/Feature/Support/CollectionTest.php index 43021b0..1a8ea48 100644 --- a/tests/Feature/Support/CollectionTest.php +++ b/tests/Feature/Support/CollectionTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Xray\AzureStoragePhpSdk\Contracts\Arrayable; use Xray\AzureStoragePhpSdk\Support\Collection; uses()->group('supports'); @@ -94,3 +95,214 @@ expect($iterations)->toBe(3); }); + +it('should get the first item', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]; + + expect(new Collection($items)) + ->first()->text->toBe('test') + ->first(fn (object $item) => $item->id === 2)->text->toBe('something') + ->first(fn (object $item) => $item->id === 4)->toBeNull() + ->first(fn (object $item) => $item->id === 4, fn () => (object) ['text' => 'new'])->text->toBe('new') + ->and(new Collection()) + ->first()->toBeNull(); +}); + +it('should get the last item', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]; + + expect(new Collection($items)) + ->last()->text->toBe('other') + ->last(fn (object $item) => $item->id === 2)->text->toBe('something') + ->last(fn (object $item) => $item->id === 4)->toBeNull() + ->last(fn (object $item) => $item->id === 4, fn () => (object) ['text' => 'new'])->text->toBe('new') + ->and(new Collection()) + ->last()->toBeNull(); +}); + +it('should be able to get an item out of the collection', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]; + + expect(new Collection($items)) + ->get(1)->text->toBe('something') + ->get(3)->toBeNull() + ->get(4, fn () => 'test')->toBe('test'); +}); + +it('should get the collection\'s keys', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]; + + expect(new Collection($items)) + ->keys()->all()->toBe([0, 1, 2]); +}); + +it('should push items into the collection', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + ]; + + $collection = (new Collection($items)) + ->push((object)['id' => 2, 'text' => 'something']); + + expect($collection) + ->first()->id->toBe(1) + ->last()->id->toBe(2); +}); + +it('should merge items into the collection', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + ]; + + $collection = (new Collection($items)) + ->merge([(object)['id' => 3, 'text' => 'something']]); + + expect($collection) + ->first()->id->toBe(1) + ->last()->id->toBe(3); +}); + +it('should concat items to the collection', function () { + $items = [ + (object)['id' => 1, 'text' => 'test'], + ]; + + $collection = (new Collection($items)) + ->concat([(object)['id' => 4, 'text' => 'something']]); + + expect($collection) + ->first()->id->toBe(1) + ->last()->id->toBe(4); +}); + +it('should put a new value into a collection key', function () { + $collection = new Collection([ + (object)['id' => 1, 'text' => 'test'], + ]); + + $collection->put(0, (object)['id' => 2, 'text' => 'something']); + + expect($collection) + ->first()->id->toBe(2); +}); + +it('should forget a value from the collection', function () { + $collection = new Collection([ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]); + + $collection->forget(1); + + expect($collection) + ->count()->toBe(2); + + $collection->forget([0, 2]); + + expect($collection) + ->isEmpty()->toBeTrue(); +}); + +it('should pull an item out of the collection', function () { + $collection = new Collection([ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]); + + expect($collection->pull(1)) + ->id->toBe(2); + + expect($collection) + ->count()->toBe(2); +}); + +it('should map the collection', function () { + $collection = new Collection([ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]); + + $result = $collection->map(fn (object $item) => $item->text); + + expect($result) + ->all() + ->toBe(['test', 'something', 'other']); +}); + +it('should loop over the collection', function () { + $collection = new Collection([ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]); + + $iterations = 0; + + $collection->each(function (object $item, int $index) use (&$iterations) { + $iterations++; + + expect($item) + ->id->toBe($index + 1); + }); + + expect($iterations)->toBe(3); +}); + +it('should filter the collection', function () { + $collection = new Collection([ + (object)['id' => 1, 'text' => 'test'], + (object)['id' => 2, 'text' => 'something'], + (object)['id' => 3, 'text' => 'other'], + ]); + + expect($collection->filter(fn (object $item) => $item->id > 1)) + ->count()->toBe(2) + ->first()->id->toBe(2) + ->last()->id->toBe(3); + + $collection = new Collection(['test', '', null, 0]); + + expect($collection->filter()) + ->count()->toBe(1) + ->first()->toBe('test'); +}); + +it('should get collection as array', function () { + $collection = new Collection([ + 'test', + new class () implements Arrayable { + public function toArray(): array + { + return ['array']; + } + }, + new class () implements JsonSerializable { + public function jsonSerialize(): array + { + return ['json']; + } + }, + ]); + + expect($collection->toArray()) + ->toBe(['test', ['array'], ['json']]); +}); diff --git a/tests/Unit/Exceptions/RequiredFieldExceptionTest.php b/tests/Unit/Exceptions/RequiredFieldExceptionTest.php index bf32c0d..4d62dd5 100644 --- a/tests/Unit/Exceptions/RequiredFieldExceptionTest.php +++ b/tests/Unit/Exceptions/RequiredFieldExceptionTest.php @@ -11,6 +11,12 @@ ->toExtend(Exception::class); }); +it('should create a new required field exception', function () { + expect(RequiredFieldException::create('This is a new required field exception')) + ->getMessage()->toBe('This is a new required field exception') + ->getCode()->toBe(0); +}); + it('should be a required field exception', function () { expect(RequiredFieldException::missingField('name')) ->getMessage()->toBe('Field [name] is required') From f1edb35efff658c617d1ddcbf03182285cec46c6 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 14:08:33 -0300 Subject: [PATCH 07/17] update packages --- composer.lock | 110 +++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/composer.lock b/composer.lock index 2656f77..d06fdea 100644 --- a/composer.lock +++ b/composer.lock @@ -700,16 +700,16 @@ }, { "name": "captainhook/captainhook", - "version": "5.23.3", + "version": "5.23.4", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook.git", - "reference": "c9deaefc098dde7f7093b44482b099195442e70d" + "reference": "53cdd84c14dd50d229cf5ebef66b20a128ade613" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/c9deaefc098dde7f7093b44482b099195442e70d", - "reference": "c9deaefc098dde7f7093b44482b099195442e70d", + "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/53cdd84c14dd50d229cf5ebef66b20a128ade613", + "reference": "53cdd84c14dd50d229cf5ebef66b20a128ade613", "shasum": "" }, "require": { @@ -772,7 +772,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook/tree/5.23.3" + "source": "https://github.com/captainhookphp/captainhook/tree/5.23.4" }, "funding": [ { @@ -780,7 +780,7 @@ "type": "github" } ], - "time": "2024-07-07T19:12:59+00:00" + "time": "2024-08-22T07:50:22+00:00" }, { "name": "captainhook/hook-installer", @@ -887,26 +887,26 @@ }, { "name": "composer/pcre", - "version": "3.2.0", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90" + "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/ea4ab6f9580a4fd221e0418f2c357cdd39102a90", - "reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90", + "url": "https://api.github.com/repos/composer/pcre/zipball/1637e067347a0c40bbb1e3cd786b20dcab556a81", + "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81", "shasum": "" }, "require": { "php": "^7.4 || ^8.0" }, "conflict": { - "phpstan/phpstan": "<1.11.8" + "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.8", + "phpstan/phpstan": "^1.11.10", "phpstan/phpstan-strict-rules": "^1.1", "phpunit/phpunit": "^8 || ^9" }, @@ -946,7 +946,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.2.0" + "source": "https://github.com/composer/pcre/tree/3.3.0" }, "funding": [ { @@ -962,7 +962,7 @@ "type": "tidelift" } ], - "time": "2024-07-25T09:36:02+00:00" + "time": "2024-08-19T19:43:53+00:00" }, { "name": "composer/xdebug-handler", @@ -1836,21 +1836,21 @@ }, { "name": "pestphp/pest", - "version": "v2.35.0", + "version": "v2.35.1", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "d0ff2c8ec294b7aa7fcb0f3ddc4fdec864234646" + "reference": "b13acb630df52c06123588d321823c31fc685545" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/d0ff2c8ec294b7aa7fcb0f3ddc4fdec864234646", - "reference": "d0ff2c8ec294b7aa7fcb0f3ddc4fdec864234646", + "url": "https://api.github.com/repos/pestphp/pest/zipball/b13acb630df52c06123588d321823c31fc685545", + "reference": "b13acb630df52c06123588d321823c31fc685545", "shasum": "" }, "require": { "brianium/paratest": "^7.3.1", - "nunomaduro/collision": "^7.10.0|^8.3.0", + "nunomaduro/collision": "^7.10.0|^8.4.0", "nunomaduro/termwind": "^1.15.1|^2.0.1", "pestphp/pest-plugin": "^2.1.1", "pestphp/pest-plugin-arch": "^2.7.0", @@ -1928,7 +1928,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.35.0" + "source": "https://github.com/pestphp/pest/tree/v2.35.1" }, "funding": [ { @@ -1940,7 +1940,7 @@ "type": "github" } ], - "time": "2024-08-02T10:57:29+00:00" + "time": "2024-08-20T21:41:50+00:00" }, { "name": "pestphp/pest-plugin", @@ -2508,16 +2508,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.10", + "version": "1.11.11", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "640410b32995914bde3eed26fa89552f9c2c082f" + "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/640410b32995914bde3eed26fa89552f9c2c082f", - "reference": "640410b32995914bde3eed26fa89552f9c2c082f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/707c2aed5d8d0075666e673a5e71440c1d01a5a3", + "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3", "shasum": "" }, "require": { @@ -2562,36 +2562,36 @@ "type": "github" } ], - "time": "2024-08-08T09:02:50+00:00" + "time": "2024-08-19T14:37:29+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.15", + "version": "10.1.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae" + "reference": "7e308268858ed6baedc8704a304727d20bc07c77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", - "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77", + "reference": "7e308268858ed6baedc8704a304727d20bc07c77", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=8.1", - "phpunit/php-file-iterator": "^4.0", - "phpunit/php-text-template": "^3.0", - "sebastian/code-unit-reverse-lookup": "^3.0", - "sebastian/complexity": "^3.0", - "sebastian/environment": "^6.0", - "sebastian/lines-of-code": "^2.0", - "sebastian/version": "^4.0", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-text-template": "^3.0.1", + "sebastian/code-unit-reverse-lookup": "^3.0.0", + "sebastian/complexity": "^3.2.0", + "sebastian/environment": "^6.1.0", + "sebastian/lines-of-code": "^2.0.2", + "sebastian/version": "^4.0.1", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { "phpunit/phpunit": "^10.1" @@ -2603,7 +2603,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1-dev" + "dev-main": "10.1.x-dev" } }, "autoload": { @@ -2632,7 +2632,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.15" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.16" }, "funding": [ { @@ -2640,7 +2640,7 @@ "type": "github" } ], - "time": "2024-06-29T08:25:15+00:00" + "time": "2024-08-22T04:31:57+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3041,16 +3041,16 @@ }, { "name": "psr/log", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + "reference": "79dff0b268932c640297f5208d6298f71855c03e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "url": "https://api.github.com/repos/php-fig/log/zipball/79dff0b268932c640297f5208d6298f71855c03e", + "reference": "79dff0b268932c640297f5208d6298f71855c03e", "shasum": "" }, "require": { @@ -3085,9 +3085,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/3.0.0" + "source": "https://github.com/php-fig/log/tree/3.0.1" }, - "time": "2021-07-14T16:46:02+00:00" + "time": "2024-08-21T13:31:24+00:00" }, { "name": "sebastian/cli-parser", @@ -3259,16 +3259,16 @@ }, { "name": "sebastian/comparator", - "version": "5.0.1", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2db5010a484d53ebf536087a70b4a5423c102372" + "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", - "reference": "2db5010a484d53ebf536087a70b4a5423c102372", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", + "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", "shasum": "" }, "require": { @@ -3279,7 +3279,7 @@ "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.3" + "phpunit/phpunit": "^10.4" }, "type": "library", "extra": { @@ -3324,7 +3324,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.2" }, "funding": [ { @@ -3332,7 +3332,7 @@ "type": "github" } ], - "time": "2023-08-14T13:18:12+00:00" + "time": "2024-08-12T06:03:08+00:00" }, { "name": "sebastian/complexity", From 0c35fb3402ac1d483d2f03ed9fa08b69a5ab1304 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 24 Aug 2024 14:14:24 -0300 Subject: [PATCH 08/17] fix phpstan issues --- .../Authentication/MicrosoftEntraIdTest.php | 2 +- .../Authentication/SharedKeyAuthTest.php | 2 +- tests/Feature/Support/CollectionTest.php | 28 +++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/Feature/Authentication/MicrosoftEntraIdTest.php b/tests/Feature/Authentication/MicrosoftEntraIdTest.php index dfe744f..8172c0d 100644 --- a/tests/Feature/Authentication/MicrosoftEntraIdTest.php +++ b/tests/Feature/Authentication/MicrosoftEntraIdTest.php @@ -26,7 +26,7 @@ unset($config[$field]); - expect(fn () => new MicrosoftEntraId($config)) + expect(fn () => new MicrosoftEntraId($config)) // @phpstan-ignore-line ->toThrow(RequiredFieldException::class, "Missing required parameters: {$field}"); })->with([ 'Missing Account' => ['account'], diff --git a/tests/Feature/Authentication/SharedKeyAuthTest.php b/tests/Feature/Authentication/SharedKeyAuthTest.php index 59494a5..d1151eb 100644 --- a/tests/Feature/Authentication/SharedKeyAuthTest.php +++ b/tests/Feature/Authentication/SharedKeyAuthTest.php @@ -25,7 +25,7 @@ unset($config[$field]); - expect(fn () => new SharedKeyAuth($config)) + expect(fn () => new SharedKeyAuth($config)) // @phpstan-ignore-line ->toThrow(RequiredFieldException::class, "Missing required parameters: {$field}"); })->with([ 'Missing Account' => ['account'], diff --git a/tests/Feature/Support/CollectionTest.php b/tests/Feature/Support/CollectionTest.php index 1a8ea48..9e407b6 100644 --- a/tests/Feature/Support/CollectionTest.php +++ b/tests/Feature/Support/CollectionTest.php @@ -103,11 +103,18 @@ (object)['id' => 3, 'text' => 'other'], ]; + $findItem = function (int $id): callable { + return function (object $item) use ($id): bool { + /** @var object{id: int, text: string} $item */ + return $item->id === $id; + }; + }; + expect(new Collection($items)) ->first()->text->toBe('test') - ->first(fn (object $item) => $item->id === 2)->text->toBe('something') - ->first(fn (object $item) => $item->id === 4)->toBeNull() - ->first(fn (object $item) => $item->id === 4, fn () => (object) ['text' => 'new'])->text->toBe('new') + ->first($findItem(2))->text->toBe('something') + ->first($findItem(4))->toBeNull() + ->first($findItem(4), fn () => (object) ['text' => 'new'])->text->toBe('new') ->and(new Collection()) ->first()->toBeNull(); }); @@ -119,11 +126,18 @@ (object)['id' => 3, 'text' => 'other'], ]; + $findItem = function (int $id): callable { + return function (object $item) use ($id): bool { + /** @var object{id: int, text: string} $item */ + return $item->id === $id; + }; + }; + expect(new Collection($items)) ->last()->text->toBe('other') - ->last(fn (object $item) => $item->id === 2)->text->toBe('something') - ->last(fn (object $item) => $item->id === 4)->toBeNull() - ->last(fn (object $item) => $item->id === 4, fn () => (object) ['text' => 'new'])->text->toBe('new') + ->last($findItem(2))->text->toBe('something') + ->last($findItem(4))->toBeNull() + ->last($findItem(4), fn () => (object) ['text' => 'new'])->text->toBe('new') ->and(new Collection()) ->last()->toBeNull(); }); @@ -290,12 +304,14 @@ $collection = new Collection([ 'test', new class () implements Arrayable { + /** @return array */ public function toArray(): array { return ['array']; } }, new class () implements JsonSerializable { + /** @return array */ public function jsonSerialize(): array { return ['json']; From d9217332bf7946dd94a5e6cf344dc71770aa47ef Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 09:44:52 -0300 Subject: [PATCH 09/17] update packages --- composer.lock | 224 +++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/composer.lock b/composer.lock index d06fdea..d7f54ec 100644 --- a/composer.lock +++ b/composer.lock @@ -700,16 +700,16 @@ }, { "name": "captainhook/captainhook", - "version": "5.23.4", + "version": "5.23.5", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook.git", - "reference": "53cdd84c14dd50d229cf5ebef66b20a128ade613" + "reference": "8b39418081b0db0c8a2996f8740ea44345af6888" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/53cdd84c14dd50d229cf5ebef66b20a128ade613", - "reference": "53cdd84c14dd50d229cf5ebef66b20a128ade613", + "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/8b39418081b0db0c8a2996f8740ea44345af6888", + "reference": "8b39418081b0db0c8a2996f8740ea44345af6888", "shasum": "" }, "require": { @@ -772,7 +772,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook/tree/5.23.4" + "source": "https://github.com/captainhookphp/captainhook/tree/5.23.5" }, "funding": [ { @@ -780,7 +780,7 @@ "type": "github" } ], - "time": "2024-08-22T07:50:22+00:00" + "time": "2024-09-05T15:44:55+00:00" }, { "name": "captainhook/hook-installer", @@ -887,16 +887,16 @@ }, { "name": "composer/pcre", - "version": "3.3.0", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81" + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/1637e067347a0c40bbb1e3cd786b20dcab556a81", - "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81", + "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", "shasum": "" }, "require": { @@ -946,7 +946,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.0" + "source": "https://github.com/composer/pcre/tree/3.3.1" }, "funding": [ { @@ -962,7 +962,7 @@ "type": "tidelift" } ], - "time": "2024-08-19T19:43:53+00:00" + "time": "2024-08-27T18:44:43+00:00" }, { "name": "composer/xdebug-handler", @@ -1079,16 +1079,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42" + "reference": "8520451a140d3f46ac33042715115e290cf5785f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42", - "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f", + "reference": "8520451a140d3f46ac33042715115e290cf5785f", "shasum": "" }, "require": { @@ -1128,7 +1128,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0" }, "funding": [ { @@ -1136,7 +1136,7 @@ "type": "github" } ], - "time": "2024-02-07T09:43:46+00:00" + "time": "2024-08-06T10:04:20+00:00" }, { "name": "filp/whoops", @@ -1321,16 +1321,16 @@ }, { "name": "laravel/pint", - "version": "v1.17.2", + "version": "v1.17.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "e8a88130a25e3f9d4d5785e6a1afca98268ab110" + "reference": "9d77be916e145864f10788bb94531d03e1f7b482" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/e8a88130a25e3f9d4d5785e6a1afca98268ab110", - "reference": "e8a88130a25e3f9d4d5785e6a1afca98268ab110", + "url": "https://api.github.com/repos/laravel/pint/zipball/9d77be916e145864f10788bb94531d03e1f7b482", + "reference": "9d77be916e145864f10788bb94531d03e1f7b482", "shasum": "" }, "require": { @@ -1341,13 +1341,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.61.1", - "illuminate/view": "^10.48.18", + "friendsofphp/php-cs-fixer": "^3.64.0", + "illuminate/view": "^10.48.20", "larastan/larastan": "^2.9.8", "laravel-zero/framework": "^10.4.0", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.35.0" + "pestphp/pest": "^2.35.1" }, "bin": [ "builds/pint" @@ -1383,7 +1383,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-08-06T15:11:54+00:00" + "time": "2024-09-03T15:00:28+00:00" }, { "name": "mockery/mockery", @@ -1685,16 +1685,16 @@ }, { "name": "nunomaduro/termwind", - "version": "v2.0.1", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "58c4c58cf23df7f498daeb97092e34f5259feb6a" + "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/58c4c58cf23df7f498daeb97092e34f5259feb6a", - "reference": "58c4c58cf23df7f498daeb97092e34f5259feb6a", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/e5f21eade88689536c0cdad4c3cd75f3ed26e01a", + "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a", "shasum": "" }, "require": { @@ -1704,11 +1704,11 @@ }, "require-dev": { "ergebnis/phpstan-rules": "^2.2.0", - "illuminate/console": "^11.0.0", - "laravel/pint": "^1.14.0", - "mockery/mockery": "^1.6.7", - "pestphp/pest": "^2.34.1", - "phpstan/phpstan": "^1.10.59", + "illuminate/console": "^11.1.1", + "laravel/pint": "^1.15.0", + "mockery/mockery": "^1.6.11", + "pestphp/pest": "^2.34.6", + "phpstan/phpstan": "^1.10.66", "phpstan/phpstan-strict-rules": "^1.5.2", "symfony/var-dumper": "^7.0.4", "thecodingmachine/phpstan-strict-rules": "^1.0.0" @@ -1753,7 +1753,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.0.1" + "source": "https://github.com/nunomaduro/termwind/tree/v2.1.0" }, "funding": [ { @@ -1769,7 +1769,7 @@ "type": "github" } ], - "time": "2024-03-06T16:17:14+00:00" + "time": "2024-09-05T15:25:50+00:00" }, { "name": "pdepend/pdepend", @@ -2461,16 +2461,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.1", + "version": "1.30.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" + "reference": "51b95ec8670af41009e2b2b56873bad96682413e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e", + "reference": "51b95ec8670af41009e2b2b56873bad96682413e", "shasum": "" }, "require": { @@ -2502,22 +2502,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1" }, - "time": "2024-05-31T08:52:43+00:00" + "time": "2024-09-07T20:13:05+00:00" }, { "name": "phpstan/phpstan", - "version": "1.11.11", + "version": "1.12.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3" + "reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/707c2aed5d8d0075666e673a5e71440c1d01a5a3", - "reference": "707c2aed5d8d0075666e673a5e71440c1d01a5a3", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0fcbf194ab63d8159bb70d9aa3e1350051632009", + "reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009", "shasum": "" }, "require": { @@ -2562,7 +2562,7 @@ "type": "github" } ], - "time": "2024-08-19T14:37:29+00:00" + "time": "2024-09-09T08:10:35+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3041,16 +3041,16 @@ }, { "name": "psr/log", - "version": "3.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "79dff0b268932c640297f5208d6298f71855c03e" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/79dff0b268932c640297f5208d6298f71855c03e", - "reference": "79dff0b268932c640297f5208d6298f71855c03e", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "shasum": "" }, "require": { @@ -3085,9 +3085,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/3.0.1" + "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2024-08-21T13:31:24+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "sebastian/cli-parser", @@ -4338,16 +4338,16 @@ }, { "name": "symfony/console", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9" + "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9", - "reference": "cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9", + "url": "https://api.github.com/repos/symfony/console/zipball/1eed7af6961d763e7832e874d7f9b21c3ea9c111", + "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111", "shasum": "" }, "require": { @@ -4411,7 +4411,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.3" + "source": "https://github.com/symfony/console/tree/v7.1.4" }, "funding": [ { @@ -4427,20 +4427,20 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:41:01+00:00" + "time": "2024-08-15T22:48:53+00:00" }, { "name": "symfony/dependency-injection", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "8126f0be4ff984e4db0140e60917900a53facb49" + "reference": "5320e0bc2c9e2d7450bb4091e497a305a68b28ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/8126f0be4ff984e4db0140e60917900a53facb49", - "reference": "8126f0be4ff984e4db0140e60917900a53facb49", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/5320e0bc2c9e2d7450bb4091e497a305a68b28ed", + "reference": "5320e0bc2c9e2d7450bb4091e497a305a68b28ed", "shasum": "" }, "require": { @@ -4491,7 +4491,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v7.1.3" + "source": "https://github.com/symfony/dependency-injection/tree/v7.1.4" }, "funding": [ { @@ -4507,7 +4507,7 @@ "type": "tidelift" } ], - "time": "2024-07-26T07:35:39+00:00" + "time": "2024-08-29T08:16:25+00:00" }, { "name": "symfony/filesystem", @@ -4577,16 +4577,16 @@ }, { "name": "symfony/finder", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "717c6329886f32dc65e27461f80f2a465412fdca" + "reference": "d95bbf319f7d052082fb7af147e0f835a695e823" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/717c6329886f32dc65e27461f80f2a465412fdca", - "reference": "717c6329886f32dc65e27461f80f2a465412fdca", + "url": "https://api.github.com/repos/symfony/finder/zipball/d95bbf319f7d052082fb7af147e0f835a695e823", + "reference": "d95bbf319f7d052082fb7af147e0f835a695e823", "shasum": "" }, "require": { @@ -4621,7 +4621,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.1.3" + "source": "https://github.com/symfony/finder/tree/v7.1.4" }, "funding": [ { @@ -4637,24 +4637,24 @@ "type": "tidelift" } ], - "time": "2024-07-24T07:08:44+00:00" + "time": "2024-08-13T14:28:19+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540" + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-ctype": "*" @@ -4700,7 +4700,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -4716,24 +4716,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -4778,7 +4778,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" }, "funding": [ { @@ -4794,24 +4794,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" + "reference": "3833d7255cc303546435cb650316bff708a1c75c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -4859,7 +4859,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" }, "funding": [ { @@ -4875,24 +4875,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -4939,7 +4939,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -4955,7 +4955,7 @@ "type": "tidelift" } ], - "time": "2024-06-19T12:30:46+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/process", @@ -5103,16 +5103,16 @@ }, { "name": "symfony/string", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "ea272a882be7f20cad58d5d78c215001617b7f07" + "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ea272a882be7f20cad58d5d78c215001617b7f07", - "reference": "ea272a882be7f20cad58d5d78c215001617b7f07", + "url": "https://api.github.com/repos/symfony/string/zipball/6cd670a6d968eaeb1c77c2e76091c45c56bc367b", + "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b", "shasum": "" }, "require": { @@ -5170,7 +5170,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.3" + "source": "https://github.com/symfony/string/tree/v7.1.4" }, "funding": [ { @@ -5186,20 +5186,20 @@ "type": "tidelift" } ], - "time": "2024-07-22T10:25:37+00:00" + "time": "2024-08-12T09:59:40+00:00" }, { "name": "symfony/var-dumper", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "86af4617cca75a6e28598f49ae0690f3b9d4591f" + "reference": "a5fa7481b199090964d6fd5dab6294d5a870c7aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/86af4617cca75a6e28598f49ae0690f3b9d4591f", - "reference": "86af4617cca75a6e28598f49ae0690f3b9d4591f", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/a5fa7481b199090964d6fd5dab6294d5a870c7aa", + "reference": "a5fa7481b199090964d6fd5dab6294d5a870c7aa", "shasum": "" }, "require": { @@ -5253,7 +5253,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.1.3" + "source": "https://github.com/symfony/var-dumper/tree/v7.1.4" }, "funding": [ { @@ -5269,7 +5269,7 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:41:01+00:00" + "time": "2024-08-30T16:12:47+00:00" }, { "name": "symfony/var-exporter", From b9e5ee50e552f6cf7ed9c30af43eb1522b394024 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 10:27:07 -0300 Subject: [PATCH 10/17] update pest to v3 --- composer.json | 2 +- composer.lock | 707 +++++++++++++++++++++++++++++-------------------- tests/Pest.php | 2 +- 3 files changed, 422 insertions(+), 289 deletions(-) diff --git a/composer.json b/composer.json index 47307f0..eee951b 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "laravel/pint": "^1.16", "phpstan/phpstan": "^1.11", - "pestphp/pest": "^2.34", + "pestphp/pest": "^3.0", "symfony/var-dumper": "^7.0", "phpmd/phpmd": "^2.15", "squizlabs/php_codesniffer": "^3.10", diff --git a/composer.lock b/composer.lock index d7f54ec..644fc28 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "882a9d7493b8a16afb001d6b42e6a3a2", + "content-hash": "17b2342cebc379e47a15d0c563b92183", "packages": [ { "name": "guzzlehttp/guzzle", @@ -606,16 +606,16 @@ "packages-dev": [ { "name": "brianium/paratest", - "version": "v7.4.3", + "version": "v7.5.4", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "64fcfd0e28a6b8078a19dbf9127be2ee645b92ec" + "reference": "c490591cc9c2f4830633b905547d30d5eb609c88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/64fcfd0e28a6b8078a19dbf9127be2ee645b92ec", - "reference": "64fcfd0e28a6b8078a19dbf9127be2ee645b92ec", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/c490591cc9c2f4830633b905547d30d5eb609c88", + "reference": "c490591cc9c2f4830633b905547d30d5eb609c88", "shasum": "" }, "require": { @@ -623,31 +623,31 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-simplexml": "*", - "fidry/cpu-core-counter": "^1.1.0", - "jean85/pretty-package-versions": "^2.0.5", + "fidry/cpu-core-counter": "^1.2.0", + "jean85/pretty-package-versions": "^2.0.6", "php": "~8.2.0 || ~8.3.0", - "phpunit/php-code-coverage": "^10.1.11 || ^11.0.0", - "phpunit/php-file-iterator": "^4.1.0 || ^5.0.0", - "phpunit/php-timer": "^6.0.0 || ^7.0.0", - "phpunit/phpunit": "^10.5.9 || ^11.0.3", - "sebastian/environment": "^6.0.1 || ^7.0.0", - "symfony/console": "^6.4.3 || ^7.0.3", - "symfony/process": "^6.4.3 || ^7.0.3" + "phpunit/php-code-coverage": "^11.0.6", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-timer": "^7.0.1", + "phpunit/phpunit": "^11.3.3", + "sebastian/environment": "^7.2.0", + "symfony/console": "^6.4.11 || ^7.1.4", + "symfony/process": "^6.4.8 || ^7.1.3" }, "require-dev": { "doctrine/coding-standard": "^12.0.0", "ext-pcov": "*", "ext-posix": "*", - "phpstan/phpstan": "^1.10.58", - "phpstan/phpstan-deprecation-rules": "^1.1.4", - "phpstan/phpstan-phpunit": "^1.3.15", - "phpstan/phpstan-strict-rules": "^1.5.2", - "squizlabs/php_codesniffer": "^3.9.0", - "symfony/filesystem": "^6.4.3 || ^7.0.3" + "infection/infection": "^0.29.6", + "phpstan/phpstan": "^1.12.1", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "squizlabs/php_codesniffer": "^3.10.2", + "symfony/filesystem": "^6.4.9 || ^7.1.2" }, "bin": [ "bin/paratest", - "bin/paratest.bat", "bin/paratest_for_phpstorm" ], "type": "library", @@ -684,7 +684,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.4.3" + "source": "https://github.com/paratestphp/paratest/tree/v7.5.4" }, "funding": [ { @@ -696,7 +696,7 @@ "type": "paypal" } ], - "time": "2024-02-20T07:24:02+00:00" + "time": "2024-09-04T21:15:27+00:00" }, { "name": "captainhook/captainhook", @@ -1836,36 +1836,37 @@ }, { "name": "pestphp/pest", - "version": "v2.35.1", + "version": "v3.0.6", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "b13acb630df52c06123588d321823c31fc685545" + "reference": "0d50d35b5eab4164b1e777e63f689be5cd8c40e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/b13acb630df52c06123588d321823c31fc685545", - "reference": "b13acb630df52c06123588d321823c31fc685545", + "url": "https://api.github.com/repos/pestphp/pest/zipball/0d50d35b5eab4164b1e777e63f689be5cd8c40e5", + "reference": "0d50d35b5eab4164b1e777e63f689be5cd8c40e5", "shasum": "" }, "require": { - "brianium/paratest": "^7.3.1", - "nunomaduro/collision": "^7.10.0|^8.4.0", - "nunomaduro/termwind": "^1.15.1|^2.0.1", - "pestphp/pest-plugin": "^2.1.1", - "pestphp/pest-plugin-arch": "^2.7.0", - "php": "^8.1.0", - "phpunit/phpunit": "^10.5.17" + "brianium/paratest": "^7.5.4", + "nunomaduro/collision": "^8.4.0", + "nunomaduro/termwind": "^2.1.0", + "pestphp/pest-plugin": "^3.0.0", + "pestphp/pest-plugin-arch": "^3.0.0", + "pestphp/pest-plugin-mutate": "^3.0.3", + "php": "^8.2.0", + "phpunit/phpunit": "^11.3.4" }, "conflict": { - "phpunit/phpunit": ">10.5.17", - "sebastian/exporter": "<5.1.0", + "phpunit/phpunit": ">11.3.4", + "sebastian/exporter": "<6.0.0", "webmozart/assert": "<1.11.0" }, "require-dev": { - "pestphp/pest-dev-tools": "^2.16.0", - "pestphp/pest-plugin-type-coverage": "^2.8.5", - "symfony/process": "^6.4.0|^7.1.3" + "pestphp/pest-dev-tools": "^3.0.0", + "pestphp/pest-plugin-type-coverage": "^3.0.0", + "symfony/process": "^7.1.3" }, "bin": [ "bin/pest" @@ -1874,6 +1875,8 @@ "extra": { "pest": { "plugins": [ + "Pest\\Mutate\\Plugins\\Mutate", + "Pest\\Plugins\\Configuration", "Pest\\Plugins\\Bail", "Pest\\Plugins\\Cache", "Pest\\Plugins\\Coverage", @@ -1928,7 +1931,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.35.1" + "source": "https://github.com/pestphp/pest/tree/v3.0.6" }, "funding": [ { @@ -1940,34 +1943,34 @@ "type": "github" } ], - "time": "2024-08-20T21:41:50+00:00" + "time": "2024-09-11T17:59:43+00:00" }, { "name": "pestphp/pest-plugin", - "version": "v2.1.1", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin.git", - "reference": "e05d2859e08c2567ee38ce8b005d044e72648c0b" + "reference": "e79b26c65bc11c41093b10150c1341cc5cdbea83" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/e05d2859e08c2567ee38ce8b005d044e72648c0b", - "reference": "e05d2859e08c2567ee38ce8b005d044e72648c0b", + "url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/e79b26c65bc11c41093b10150c1341cc5cdbea83", + "reference": "e79b26c65bc11c41093b10150c1341cc5cdbea83", "shasum": "" }, "require": { "composer-plugin-api": "^2.0.0", "composer-runtime-api": "^2.2.2", - "php": "^8.1" + "php": "^8.2" }, "conflict": { - "pestphp/pest": "<2.2.3" + "pestphp/pest": "<3.0.0" }, "require-dev": { - "composer/composer": "^2.5.8", - "pestphp/pest": "^2.16.0", - "pestphp/pest-dev-tools": "^2.16.0" + "composer/composer": "^2.7.9", + "pestphp/pest": "^3.0.0", + "pestphp/pest-dev-tools": "^3.0.0" }, "type": "composer-plugin", "extra": { @@ -1994,7 +1997,7 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin/tree/v2.1.1" + "source": "https://github.com/pestphp/pest-plugin/tree/v3.0.0" }, "funding": [ { @@ -2010,31 +2013,30 @@ "type": "patreon" } ], - "time": "2023-08-22T08:40:06+00:00" + "time": "2024-09-08T23:21:41+00:00" }, { "name": "pestphp/pest-plugin-arch", - "version": "v2.7.0", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-arch.git", - "reference": "d23b2d7498475354522c3818c42ef355dca3fcda" + "reference": "0a27e55a270cfe73d8cb70551b91002ee2cb64b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/d23b2d7498475354522c3818c42ef355dca3fcda", - "reference": "d23b2d7498475354522c3818c42ef355dca3fcda", + "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/0a27e55a270cfe73d8cb70551b91002ee2cb64b0", + "reference": "0a27e55a270cfe73d8cb70551b91002ee2cb64b0", "shasum": "" }, "require": { - "nunomaduro/collision": "^7.10.0|^8.1.0", - "pestphp/pest-plugin": "^2.1.1", - "php": "^8.1", + "pestphp/pest-plugin": "^3.0.0", + "php": "^8.2", "ta-tikoma/phpunit-architecture-test": "^0.8.4" }, "require-dev": { - "pestphp/pest": "^2.33.0", - "pestphp/pest-dev-tools": "^2.16.0" + "pestphp/pest": "^3.0.0", + "pestphp/pest-dev-tools": "^3.0.0" }, "type": "library", "extra": { @@ -2069,19 +2071,91 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.7.0" + "source": "https://github.com/pestphp/pest-plugin-arch/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2024-09-08T23:23:55+00:00" + }, + { + "name": "pestphp/pest-plugin-mutate", + "version": "v3.0.3", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-mutate.git", + "reference": "d83a5e106c92ea0ebf928eefbe4a57f028adf468" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/d83a5e106c92ea0ebf928eefbe4a57f028adf468", + "reference": "d83a5e106c92ea0ebf928eefbe4a57f028adf468", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.1.0", + "pestphp/pest-plugin": "^3.0.0", + "php": "^8.2", + "psr/simple-cache": "^3.0.0" + }, + "require-dev": { + "pestphp/pest": "^3.0.1", + "pestphp/pest-dev-tools": "^3.0.0", + "pestphp/pest-plugin-type-coverage": "^3.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Pest\\Mutate\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sandro Gehri", + "email": "sandrogehri@gmail.com" + } + ], + "description": "Mutates your code to find untested cases", + "keywords": [ + "framework", + "mutate", + "mutation", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-mutate/tree/v3.0.3" }, "funding": [ { "url": "https://www.paypal.com/paypalme/enunomaduro", "type": "custom" }, + { + "url": "https://github.com/gehrisandro", + "type": "github" + }, { "url": "https://github.com/nunomaduro", "type": "github" } ], - "time": "2024-01-26T09:46:42+00:00" + "time": "2024-09-10T15:59:08+00:00" }, { "name": "phar-io/manifest", @@ -2566,35 +2640,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.16", + "version": "11.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "7e308268858ed6baedc8704a304727d20bc07c77" + "reference": "ebdffc9e09585dafa71b9bffcdb0a229d4704c45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77", - "reference": "7e308268858ed6baedc8704a304727d20bc07c77", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ebdffc9e09585dafa71b9bffcdb0a229d4704c45", + "reference": "ebdffc9e09585dafa71b9bffcdb0a229d4704c45", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.19.1 || ^5.1.0", - "php": ">=8.1", - "phpunit/php-file-iterator": "^4.1.0", - "phpunit/php-text-template": "^3.0.1", - "sebastian/code-unit-reverse-lookup": "^3.0.0", - "sebastian/complexity": "^3.2.0", - "sebastian/environment": "^6.1.0", - "sebastian/lines-of-code": "^2.0.2", - "sebastian/version": "^4.0.1", + "nikic/php-parser": "^5.1.0", + "php": ">=8.2", + "phpunit/php-file-iterator": "^5.0.1", + "phpunit/php-text-template": "^4.0.1", + "sebastian/code-unit-reverse-lookup": "^4.0.1", + "sebastian/complexity": "^4.0.1", + "sebastian/environment": "^7.2.0", + "sebastian/lines-of-code": "^3.0.1", + "sebastian/version": "^5.0.1", "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^10.1" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -2603,7 +2677,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1.x-dev" + "dev-main": "11.0.x-dev" } }, "autoload": { @@ -2632,7 +2706,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.16" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.6" }, "funding": [ { @@ -2640,32 +2714,32 @@ "type": "github" } ], - "time": "2024-08-22T04:31:57+00:00" + "time": "2024-08-22T04:37:56+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "4.1.0", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6", + "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2693,7 +2767,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.0" }, "funding": [ { @@ -2701,28 +2775,28 @@ "type": "github" } ], - "time": "2023-08-31T06:24:48+00:00" + "time": "2024-08-27T05:02:59+00:00" }, { "name": "phpunit/php-invoker", - "version": "4.0.0", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + "reference": "c1ca3814734c07492b3d4c5f794f4b0995333da2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2", + "reference": "c1ca3814734c07492b3d4c5f794f4b0995333da2", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-pcntl": "*" @@ -2730,7 +2804,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2756,7 +2830,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + "security": "https://github.com/sebastianbergmann/php-invoker/security/policy", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/5.0.1" }, "funding": [ { @@ -2764,32 +2839,32 @@ "type": "github" } ], - "time": "2023-02-03T06:56:09+00:00" + "time": "2024-07-03T05:07:44+00:00" }, { "name": "phpunit/php-text-template", - "version": "3.0.1", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + "reference": "3e0404dc6b300e6bf56415467ebcb3fe4f33e964" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964", + "reference": "3e0404dc6b300e6bf56415467ebcb3fe4f33e964", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -2816,7 +2891,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/php-text-template/tree/4.0.1" }, "funding": [ { @@ -2824,32 +2899,32 @@ "type": "github" } ], - "time": "2023-08-31T14:07:24+00:00" + "time": "2024-07-03T05:08:43+00:00" }, { "name": "phpunit/php-timer", - "version": "6.0.0", + "version": "7.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + "reference": "3b415def83fbcb41f991d9ebf16ae4ad8b7837b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3", + "reference": "3b415def83fbcb41f991d9ebf16ae4ad8b7837b3", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -2875,7 +2950,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + "security": "https://github.com/sebastianbergmann/php-timer/security/policy", + "source": "https://github.com/sebastianbergmann/php-timer/tree/7.0.1" }, "funding": [ { @@ -2883,20 +2959,20 @@ "type": "github" } ], - "time": "2023-02-03T06:57:52+00:00" + "time": "2024-07-03T05:09:35+00:00" }, { "name": "phpunit/phpunit", - "version": "10.5.17", + "version": "11.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c1f736a473d21957ead7e94fcc029f571895abf5" + "reference": "d2ef57db1410b102b250e0cdce6675a60c2a993d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1f736a473d21957ead7e94fcc029f571895abf5", - "reference": "c1f736a473d21957ead7e94fcc029f571895abf5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d2ef57db1410b102b250e0cdce6675a60c2a993d", + "reference": "d2ef57db1410b102b250e0cdce6675a60c2a993d", "shasum": "" }, "require": { @@ -2906,26 +2982,25 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", - "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.5", - "phpunit/php-file-iterator": "^4.0", - "phpunit/php-invoker": "^4.0", - "phpunit/php-text-template": "^3.0", - "phpunit/php-timer": "^6.0", - "sebastian/cli-parser": "^2.0", - "sebastian/code-unit": "^2.0", - "sebastian/comparator": "^5.0", - "sebastian/diff": "^5.0", - "sebastian/environment": "^6.0", - "sebastian/exporter": "^5.1", - "sebastian/global-state": "^6.0.1", - "sebastian/object-enumerator": "^5.0", - "sebastian/recursion-context": "^5.0", - "sebastian/type": "^4.0", - "sebastian/version": "^4.0" + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=8.2", + "phpunit/php-code-coverage": "^11.0.6", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-invoker": "^5.0.1", + "phpunit/php-text-template": "^4.0.1", + "phpunit/php-timer": "^7.0.1", + "sebastian/cli-parser": "^3.0.2", + "sebastian/code-unit": "^3.0.1", + "sebastian/comparator": "^6.0.2", + "sebastian/diff": "^6.0.2", + "sebastian/environment": "^7.2.0", + "sebastian/exporter": "^6.1.3", + "sebastian/global-state": "^7.0.2", + "sebastian/object-enumerator": "^6.0.1", + "sebastian/type": "^5.0.1", + "sebastian/version": "^5.0.1" }, "suggest": { "ext-soap": "To be able to generate mocks based on WSDL files" @@ -2936,7 +3011,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.5-dev" + "dev-main": "11.3-dev" } }, "autoload": { @@ -2968,7 +3043,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.17" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.4" }, "funding": [ { @@ -2984,7 +3059,7 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:39:01+00:00" + "time": "2024-09-09T06:08:34+00:00" }, { "name": "psr/container", @@ -3089,30 +3164,81 @@ }, "time": "2024-09-11T13:17:53+00:00" }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, { "name": "sebastian/cli-parser", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" + "reference": "15c5dd40dc4f38794d383bb95465193f5e0ae180" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", - "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180", + "reference": "15c5dd40dc4f38794d383bb95465193f5e0ae180", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -3136,7 +3262,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/3.0.2" }, "funding": [ { @@ -3144,32 +3270,32 @@ "type": "github" } ], - "time": "2024-03-02T07:12:49+00:00" + "time": "2024-07-03T04:41:36+00:00" }, { "name": "sebastian/code-unit", - "version": "2.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + "reference": "6bb7d09d6623567178cf54126afa9c2310114268" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/6bb7d09d6623567178cf54126afa9c2310114268", + "reference": "6bb7d09d6623567178cf54126afa9c2310114268", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -3192,7 +3318,8 @@ "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + "security": "https://github.com/sebastianbergmann/code-unit/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.1" }, "funding": [ { @@ -3200,32 +3327,32 @@ "type": "github" } ], - "time": "2023-02-03T06:58:43+00:00" + "time": "2024-07-03T04:44:28+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "3.0.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + "reference": "183a9b2632194febd219bb9246eee421dad8d45e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e", + "reference": "183a9b2632194febd219bb9246eee421dad8d45e", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -3247,7 +3374,8 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/4.0.1" }, "funding": [ { @@ -3255,36 +3383,36 @@ "type": "github" } ], - "time": "2023-02-03T06:59:15+00:00" + "time": "2024-07-03T04:45:54+00:00" }, { "name": "sebastian/comparator", - "version": "5.0.2", + "version": "6.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53" + "reference": "fa37b9e2ca618cb051d71b60120952ee8ca8b03d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", - "reference": "2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa37b9e2ca618cb051d71b60120952ee8ca8b03d", + "reference": "fa37b9e2ca618cb051d71b60120952ee8ca8b03d", "shasum": "" }, "require": { "ext-dom": "*", "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/diff": "^5.0", - "sebastian/exporter": "^5.0" + "php": ">=8.2", + "sebastian/diff": "^6.0", + "sebastian/exporter": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^10.4" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "6.1-dev" } }, "autoload": { @@ -3324,7 +3452,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.2" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.1.0" }, "funding": [ { @@ -3332,33 +3460,33 @@ "type": "github" } ], - "time": "2024-08-12T06:03:08+00:00" + "time": "2024-09-11T15:42:56+00:00" }, { "name": "sebastian/complexity", - "version": "3.2.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68ff824baeae169ec9f2137158ee529584553799" + "reference": "ee41d384ab1906c68852636b6de493846e13e5a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", - "reference": "68ff824baeae169ec9f2137158ee529584553799", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0", + "reference": "ee41d384ab1906c68852636b6de493846e13e5a0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "nikic/php-parser": "^5.0", + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.2-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -3382,7 +3510,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/4.0.1" }, "funding": [ { @@ -3390,33 +3518,33 @@ "type": "github" } ], - "time": "2023-12-21T08:37:17+00:00" + "time": "2024-07-03T04:49:50+00:00" }, { "name": "sebastian/diff", - "version": "5.1.1", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" + "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", - "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544", + "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0", - "symfony/process": "^6.4" + "phpunit/phpunit": "^11.0", + "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -3449,7 +3577,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" + "source": "https://github.com/sebastianbergmann/diff/tree/6.0.2" }, "funding": [ { @@ -3457,27 +3585,27 @@ "type": "github" } ], - "time": "2024-03-02T07:15:17+00:00" + "time": "2024-07-03T04:53:05+00:00" }, { "name": "sebastian/environment", - "version": "6.1.0", + "version": "7.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "8074dbcd93529b357029f5cc5058fd3e43666984" + "reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984", - "reference": "8074dbcd93529b357029f5cc5058fd3e43666984", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5", + "reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "suggest": { "ext-posix": "*" @@ -3485,7 +3613,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.1-dev" + "dev-main": "7.2-dev" } }, "autoload": { @@ -3513,7 +3641,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", "security": "https://github.com/sebastianbergmann/environment/security/policy", - "source": "https://github.com/sebastianbergmann/environment/tree/6.1.0" + "source": "https://github.com/sebastianbergmann/environment/tree/7.2.0" }, "funding": [ { @@ -3521,34 +3649,34 @@ "type": "github" } ], - "time": "2024-03-23T08:47:14+00:00" + "time": "2024-07-03T04:54:44+00:00" }, { "name": "sebastian/exporter", - "version": "5.1.2", + "version": "6.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "955288482d97c19a372d3f31006ab3f37da47adf" + "reference": "c414673eee9a8f9d51bbf8d61fc9e3ef1e85b20e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf", - "reference": "955288482d97c19a372d3f31006ab3f37da47adf", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c414673eee9a8f9d51bbf8d61fc9e3ef1e85b20e", + "reference": "c414673eee9a8f9d51bbf8d61fc9e3ef1e85b20e", "shasum": "" }, "require": { "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/recursion-context": "^5.0" + "php": ">=8.2", + "sebastian/recursion-context": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.2" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-main": "6.1-dev" } }, "autoload": { @@ -3591,7 +3719,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2" + "source": "https://github.com/sebastianbergmann/exporter/tree/6.1.3" }, "funding": [ { @@ -3599,35 +3727,35 @@ "type": "github" } ], - "time": "2024-03-02T07:17:12+00:00" + "time": "2024-07-03T04:56:19+00:00" }, { "name": "sebastian/global-state", - "version": "6.0.2", + "version": "7.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" + "reference": "3be331570a721f9a4b5917f4209773de17f747d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", - "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7", + "reference": "3be331570a721f9a4b5917f4209773de17f747d7", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -3653,7 +3781,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", "security": "https://github.com/sebastianbergmann/global-state/security/policy", - "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" + "source": "https://github.com/sebastianbergmann/global-state/tree/7.0.2" }, "funding": [ { @@ -3661,33 +3789,33 @@ "type": "github" } ], - "time": "2024-03-02T07:19:19+00:00" + "time": "2024-07-03T04:57:36+00:00" }, { "name": "sebastian/lines-of-code", - "version": "2.0.2", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" + "reference": "d36ad0d782e5756913e42ad87cb2890f4ffe467a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a", + "reference": "d36ad0d782e5756913e42ad87cb2890f4ffe467a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "nikic/php-parser": "^5.0", + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -3711,7 +3839,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/3.0.1" }, "funding": [ { @@ -3719,34 +3847,34 @@ "type": "github" } ], - "time": "2023-12-21T08:38:20+00:00" + "time": "2024-07-03T04:58:38+00:00" }, { "name": "sebastian/object-enumerator", - "version": "5.0.0", + "version": "6.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + "reference": "f5b498e631a74204185071eb41f33f38d64608aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa", + "reference": "f5b498e631a74204185071eb41f33f38d64608aa", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -3768,7 +3896,8 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/object-enumerator/security/policy", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/6.0.1" }, "funding": [ { @@ -3776,32 +3905,32 @@ "type": "github" } ], - "time": "2023-02-03T07:08:32+00:00" + "time": "2024-07-03T05:00:13+00:00" }, { "name": "sebastian/object-reflector", - "version": "3.0.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + "reference": "6e1a43b411b2ad34146dee7524cb13a068bb35f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9", + "reference": "6e1a43b411b2ad34146dee7524cb13a068bb35f9", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -3823,7 +3952,8 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/object-reflector/security/policy", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/4.0.1" }, "funding": [ { @@ -3831,32 +3961,32 @@ "type": "github" } ], - "time": "2023-02-03T07:06:18+00:00" + "time": "2024-07-03T05:01:32+00:00" }, { "name": "sebastian/recursion-context", - "version": "5.0.0", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "05909fb5bc7df4c52992396d0116aed689f93712" + "reference": "694d156164372abbd149a4b85ccda2e4670c0e16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", - "reference": "05909fb5bc7df4c52992396d0116aed689f93712", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/694d156164372abbd149a4b85ccda2e4670c0e16", + "reference": "694d156164372abbd149a4b85ccda2e4670c0e16", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -3886,7 +4016,8 @@ "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.2" }, "funding": [ { @@ -3894,32 +4025,32 @@ "type": "github" } ], - "time": "2023-02-03T07:05:40+00:00" + "time": "2024-07-03T05:10:34+00:00" }, { "name": "sebastian/type", - "version": "4.0.0", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb6a6566f9589e86661291d13eba708cce5eb4aa", + "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -3942,7 +4073,8 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + "security": "https://github.com/sebastianbergmann/type/security/policy", + "source": "https://github.com/sebastianbergmann/type/tree/5.0.1" }, "funding": [ { @@ -3950,29 +4082,29 @@ "type": "github" } ], - "time": "2023-02-03T07:10:45+00:00" + "time": "2024-07-03T05:11:49+00:00" }, { "name": "sebastian/version", - "version": "4.0.1", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + "reference": "45c9debb7d039ce9b97de2f749c2cf5832a06ac4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/45c9debb7d039ce9b97de2f749c2cf5832a06ac4", + "reference": "45c9debb7d039ce9b97de2f749c2cf5832a06ac4", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -3995,7 +4127,8 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + "security": "https://github.com/sebastianbergmann/version/security/policy", + "source": "https://github.com/sebastianbergmann/version/tree/5.0.1" }, "funding": [ { @@ -4003,7 +4136,7 @@ "type": "github" } ], - "time": "2023-02-07T11:34:05+00:00" + "time": "2024-07-03T05:13:08+00:00" }, { "name": "sebastianfeldmann/camino", diff --git a/tests/Pest.php b/tests/Pest.php index 6a1cf85..12050fd 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -16,7 +16,7 @@ | */ -uses(TestCase::class)->in('Feature', 'Unit'); +pest()->extends(TestCase::class)->in('Feature', 'Unit'); /* |-------------------------------------------------------------------------- From 7befb3ff73d4ebb1631dc6220b5bc5ca5ac0face Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 10:48:41 -0300 Subject: [PATCH 11/17] fix pest presets --- src/BlobStorage/Resource.php | 32 +++++++++++++++---- .../CouldNotCreateTempFileException.php | 2 +- .../InvalidResourceTypeException.php | 2 +- src/Exceptions/ManagerNotSetException.php | 2 +- .../FailedAuthenticationException.php | 2 +- src/Exceptions/UnableToConvertException.php | 2 +- src/Exceptions/UnableToParseException.php | 2 +- src/Http/Request.php | 2 +- tests/Unit/ArchTest.php | 3 ++ 9 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/BlobStorage/Resource.php b/src/BlobStorage/Resource.php index 186a806..8d62cc5 100644 --- a/src/BlobStorage/Resource.php +++ b/src/BlobStorage/Resource.php @@ -64,12 +64,9 @@ final class Resource public static function canonicalize(string $uri): string { - /** @var array */ - $parsed = parse_url($uri); + $parsed = static::parseUrl($uri); - parse_str($parsed['query'] ?? '', $queryParams); - - ksort($queryParams); + ksort($parsed['query']); $result = ''; @@ -77,10 +74,33 @@ public static function canonicalize(string $uri): string * @var string $value * @var string $key */ - foreach ($queryParams as $key => $value) { + foreach ($parsed['query'] as $key => $value) { $result .= mb_convert_case($key, MB_CASE_LOWER, 'UTF-8') . ':' . $value . "\n"; } return $parsed['path'] . "\n" . rtrim($result, "\n"); } + + /** @return array */ + protected static function parseUrl(string $uri): array + { + /** @var array */ + $parsed = parse_url($uri); + + if (trim($parsed['query'] ?? '') === '') { + $parsed['query'] = []; + + return $parsed; + } + + $parsed['query'] = array_reduce(explode('&', $parsed['query']), function (array $carry, string $query): array { + $parts = explode('=', $query); + + $carry[$parts[0]] = $parts[1]; + + return $carry; + }, []); + + return $parsed; + } } diff --git a/src/Exceptions/CouldNotCreateTempFileException.php b/src/Exceptions/CouldNotCreateTempFileException.php index 176a9a8..b58f925 100644 --- a/src/Exceptions/CouldNotCreateTempFileException.php +++ b/src/Exceptions/CouldNotCreateTempFileException.php @@ -6,7 +6,7 @@ use Exception; -class CouldNotCreateTempFileException extends Exception +final class CouldNotCreateTempFileException extends Exception { protected function __construct(string $message) { diff --git a/src/Exceptions/InvalidResourceTypeException.php b/src/Exceptions/InvalidResourceTypeException.php index ff40727..fb66dc9 100644 --- a/src/Exceptions/InvalidResourceTypeException.php +++ b/src/Exceptions/InvalidResourceTypeException.php @@ -6,7 +6,7 @@ use Exception; -class InvalidResourceTypeException extends Exception +final class InvalidResourceTypeException extends Exception { public static function create(string $message): self { diff --git a/src/Exceptions/ManagerNotSetException.php b/src/Exceptions/ManagerNotSetException.php index 5951c52..008a029 100644 --- a/src/Exceptions/ManagerNotSetException.php +++ b/src/Exceptions/ManagerNotSetException.php @@ -6,7 +6,7 @@ use Exception; -class ManagerNotSetException extends Exception +final class ManagerNotSetException extends Exception { protected function __construct(string $message) { diff --git a/src/Exceptions/RequestException/FailedAuthenticationException.php b/src/Exceptions/RequestException/FailedAuthenticationException.php index 9cba5a7..b8e2a68 100644 --- a/src/Exceptions/RequestException/FailedAuthenticationException.php +++ b/src/Exceptions/RequestException/FailedAuthenticationException.php @@ -6,7 +6,7 @@ use Xray\AzureStoragePhpSdk\Exceptions\RequestException; -class FailedAuthenticationException extends RequestException +final class FailedAuthenticationException extends RequestException { // } diff --git a/src/Exceptions/UnableToConvertException.php b/src/Exceptions/UnableToConvertException.php index 45cfca3..002ee7c 100644 --- a/src/Exceptions/UnableToConvertException.php +++ b/src/Exceptions/UnableToConvertException.php @@ -6,7 +6,7 @@ use Exception; -class UnableToConvertException extends Exception +final class UnableToConvertException extends Exception { protected function __construct(string $message) { diff --git a/src/Exceptions/UnableToParseException.php b/src/Exceptions/UnableToParseException.php index 4ef3d57..e372375 100644 --- a/src/Exceptions/UnableToParseException.php +++ b/src/Exceptions/UnableToParseException.php @@ -6,7 +6,7 @@ use Exception; -class UnableToParseException extends Exception +final class UnableToParseException extends Exception { protected function __construct(string $message) { diff --git a/src/Http/Request.php b/src/Http/Request.php index ac23956..476214a 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -13,7 +13,7 @@ use Xray\AzureStoragePhpSdk\Contracts\Http\{Request as RequestContract, Response as ResponseContract}; /** @suppressWarnings(PHPMD.ExcessiveParameterList) */ -class Request implements RequestContract +final class Request implements RequestContract { use HasAuthenticatedRequest; use HasSharingMethods; diff --git a/tests/Unit/ArchTest.php b/tests/Unit/ArchTest.php index fddc3c5..4c07921 100644 --- a/tests/Unit/ArchTest.php +++ b/tests/Unit/ArchTest.php @@ -2,6 +2,9 @@ use Xray\AzureStoragePhpSdk\Contracts\Manager; +arch()->preset()->php(); +arch()->preset()->security()->ignoring('md5'); + arch('it should not use dumping functions') ->expect(['dd', 'dump', 'die', 'exit', 'var_dump', 'var_export']) ->not->toBeUsed(); From 3bdefcbb61394392e5004e8dd4d540700a052c28 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 11:03:22 -0300 Subject: [PATCH 12/17] add covers to all tests --- tests/Feature/Application/ApplicationTest.php | 3 ++- .../Authentication/MicrosoftEntraIdTest.php | 3 ++- .../UserDelegationSasTest.php | 3 ++- .../Authentication/SharedKeyAuthTest.php | 3 ++- .../BlobStorage/BlobStorageClientTest.php | 3 ++- .../BlobStorage/BlobStorageConfigTest.php | 3 ++- .../BlobStorage/BlobStorateResouceTest.php | 3 ++- .../Concerns/ValidateContainerNameTest.php | 3 ++- .../Concerns/ValidateMetadataKeyTest.php | 3 ++- .../Container/BlobStorageContainerTest.php | 3 ++- ...StoragePreflightBlobRequestManagerTest.php | 3 ++- .../BlobStorageStoragePropertyManagerTest.php | 3 ++- .../Managers/Blob/BlobLeaseManagerTest.php | 3 ++- .../Blob/BlobStorageBlobManagerTest.php | 3 ++- .../BlobStorageBlobMetadataManagerTest.php | 3 ++- .../Blob/BlobStorageBlobPageManagerTest.php | 3 ++- .../BlobStorageBlobPropertyManagerTest.php | 3 ++- .../Blob/BlobStorageBlobTagManagerTest.php | 3 ++- .../BlobStorageAccountManagerTest.php | 3 ++- .../BlobStorageContainerManagerTest.php | 3 ++- ...StorageContainerAccessLevelManagerTest.php | 3 ++- .../BlobStorageContainerLeaseManagerTest.php | 3 ++- ...lobStorageContainerMetadataManagerTest.php | 3 ++- .../BlobStorage/Queries/BlobTagQueryTest.php | 3 ++- tests/Feature/Converters/XmlConverterTest.php | 3 ++- tests/Feature/HelpersTest.php | 23 +++++++++++-------- tests/Feature/Http/HeadersTest.php | 3 ++- tests/Feature/Http/RequestTest.php | 3 ++- tests/Feature/Http/ResponseTest.php | 3 ++- tests/Feature/Parsers/XmlParserTest.php | 3 ++- tests/Feature/Support/CollectionTest.php | 3 ++- tests/Unit/Concerns/HasManagerTest.php | 3 ++- tests/Unit/Concerns/HasRequestSharedTest.php | 3 ++- tests/Unit/Entities/Blob/BlobMetadataTest.php | 3 ++- tests/Unit/Entities/Blob/BlobTagTest.php | 3 ++- tests/Unit/Entities/Blob/BlobTest.php | 3 ++- .../Entities/Container/ContainerLeaseTest.php | 3 ++- .../CouldNotCreateTempFileExceptionTest.php | 3 ++- .../InvalidArgumentExceptionTest.php | 3 ++- .../InvalidFileMimeTypeExceptionTest.php | 3 ++- .../Exceptions/ManagerNotSetExceptionTest.php | 3 ++- .../Unit/Exceptions/RequestExceptionTest.php | 3 ++- .../Exceptions/RequiredFieldExceptionTest.php | 3 ++- .../UnableToConvertExceptionTest.php | 3 ++- .../Exceptions/UnableToParseExceptionTest.php | 3 ++- tests/Unit/Resources/FileTest.php | 3 ++- 46 files changed, 103 insertions(+), 55 deletions(-) diff --git a/tests/Feature/Application/ApplicationTest.php b/tests/Feature/Application/ApplicationTest.php index 723cbc2..b2b9bb5 100644 --- a/tests/Feature/Application/ApplicationTest.php +++ b/tests/Feature/Application/ApplicationTest.php @@ -5,7 +5,8 @@ use Xray\AzureStoragePhpSdk\Application\Application; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('applications'); +pest()->group('applications'); +covers(Application::class); afterEach(fn () => Application::getInstance()->flush()); diff --git a/tests/Feature/Authentication/MicrosoftEntraIdTest.php b/tests/Feature/Authentication/MicrosoftEntraIdTest.php index 8172c0d..a484d07 100644 --- a/tests/Feature/Authentication/MicrosoftEntraIdTest.php +++ b/tests/Feature/Authentication/MicrosoftEntraIdTest.php @@ -9,7 +9,8 @@ use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; use Xray\Tests\Fakes\ClientFake; -uses()->group('authentications'); +pest()->group('authentications'); +covers(MicrosoftEntraId::class); it('should implements Auth interface', function () { expect(MicrosoftEntraId::class) diff --git a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php index 3c8827d..a4d313b 100644 --- a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php +++ b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php @@ -11,7 +11,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidResourceTypeException; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('authentications', 'shared-access-signatures'); +pest()->group('authentications', 'shared-access-signatures'); +covers(UserDelegationSas::class); it('should implements SharedAccessSignature interface', function () { expect(UserDelegationSas::class) diff --git a/tests/Feature/Authentication/SharedKeyAuthTest.php b/tests/Feature/Authentication/SharedKeyAuthTest.php index d1151eb..b3d2bda 100644 --- a/tests/Feature/Authentication/SharedKeyAuthTest.php +++ b/tests/Feature/Authentication/SharedKeyAuthTest.php @@ -10,7 +10,8 @@ use Xray\AzureStoragePhpSdk\Http\Headers; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; -uses()->group('authentications'); +pest()->group('authentications'); +covers(SharedKeyAuth::class); it('should implements Auth interface', function () { expect(SharedKeyAuth::class) diff --git a/tests/Feature/BlobStorage/BlobStorageClientTest.php b/tests/Feature/BlobStorage/BlobStorageClientTest.php index 9c28c89..6e64da4 100644 --- a/tests/Feature/BlobStorage/BlobStorageClientTest.php +++ b/tests/Feature/BlobStorage/BlobStorageClientTest.php @@ -8,7 +8,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\{BlobStorageClient, Config}; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; -uses()->group('blob-storage'); +pest()->group('blob-storage'); +covers(BlobStorageClient::class); it('should be able to get blob storage managers', function (string $method, string $class, array $parameters = []) { $request = new RequestFake(); diff --git a/tests/Feature/BlobStorage/BlobStorageConfigTest.php b/tests/Feature/BlobStorage/BlobStorageConfigTest.php index a357231..fb14f26 100644 --- a/tests/Feature/BlobStorage/BlobStorageConfigTest.php +++ b/tests/Feature/BlobStorage/BlobStorageConfigTest.php @@ -6,7 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Converter; use Xray\AzureStoragePhpSdk\Parsers\XmlParser; -uses()->group('blob-storage'); +pest()->group('blob-storage'); +covers(Config::class); it('should set default config value if none of the optional ones are provided', function () { expect(new Config()) diff --git a/tests/Feature/BlobStorage/BlobStorateResouceTest.php b/tests/Feature/BlobStorage/BlobStorateResouceTest.php index 2581101..c2c1b54 100644 --- a/tests/Feature/BlobStorage/BlobStorateResouceTest.php +++ b/tests/Feature/BlobStorage/BlobStorateResouceTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resource; -uses()->group('blob-storage'); +pest()->group('blob-storage'); +covers(Resource::class); it('should canonicalize resource correctly', function () { $uri = 'https://account.blob.core.windows.net/container/?RestType=service&Comp=properties'; diff --git a/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php b/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php index 54af27c..f85a7e7 100644 --- a/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php +++ b/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php @@ -3,7 +3,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Concerns\ValidateContainerName; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('blob-storage', 'concerns'); +pest()->group('blob-storage', 'concerns'); +covers(ValidateContainerName::class); it('should not throw an exception if the container name is valid', function () { $class = new class () { diff --git a/tests/Feature/BlobStorage/Concerns/ValidateMetadataKeyTest.php b/tests/Feature/BlobStorage/Concerns/ValidateMetadataKeyTest.php index 1b9cf76..0778754 100644 --- a/tests/Feature/BlobStorage/Concerns/ValidateMetadataKeyTest.php +++ b/tests/Feature/BlobStorage/Concerns/ValidateMetadataKeyTest.php @@ -3,7 +3,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Concerns\ValidateMetadataKey; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('blob-storage', 'concerns'); +pest()->group('blob-storage', 'concerns'); +covers(ValidateMetadataKey::class); it('should not throw an exception if the key is valid', function () { $class = new class () { diff --git a/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php b/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php index 2697a4e..78e7e5f 100644 --- a/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php +++ b/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php @@ -11,7 +11,8 @@ use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'entities', 'containers'); +pest()->group('blob-storage', 'entities', 'containers'); +covers(Container::class); it('should throw an exception if the container\'s name isn\'t provided', function () { $container = new Container([ diff --git a/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php b/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php index b2e012d..267419b 100644 --- a/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php @@ -7,7 +7,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; -uses()->group('blob-storage', 'managers', 'account'); +pest()->group('blob-storage', 'managers', 'account'); +covers(PreflightBlobRequestManager::class); it('should send a request to the preflight blob', function (string $method, HttpVerb $verb) { $request = new RequestFake(); diff --git a/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php b/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php index a692600..1b10b65 100644 --- a/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php @@ -9,7 +9,8 @@ use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'account'); +pest()->group('blob-storage', 'managers', 'account'); +covers(StoragePropertyManager::class); it('should get the blob property', function () { $body = <<group('blob-storage', 'managers', 'blob'); +pest()->group('blob-storage', 'managers', 'blob'); +covers(BlobLeaseManager::class); const BLOB_LEASE_MANAGER_REQUEST_URL = 'container/blob?comp=lease&resttype=blob'; const BLOB_LEASE_MANAGER_VERSION = '2020-06-12'; diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php index 6c1710a..73aed78 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php @@ -20,7 +20,8 @@ use function Xray\Tests\mock; -uses()->group('blob-storage', 'managers', 'blobs'); +pest()->group('blob-storage', 'managers', 'blobs'); +covers(BlobManager::class); it('should get the blob\'s managers', function (string $method, string $class) { $request = new RequestFake(); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php index 2d25d41..c9e7fe7 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php @@ -7,7 +7,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'blobs'); +pest()->group('blob-storage', 'managers', 'blobs'); +covers(BlobMetadataManager::class); it('should get the blob\'s metadata', function () { $request = (new RequestFake()) diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php index c009f17..7865be6 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php @@ -10,7 +10,8 @@ use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'blobs'); +pest()->group('blob-storage', 'managers', 'blobs'); +covers(BlobPageManager::class); it('should throw an exception if the page is out of boundary', function () { $request = new RequestFake(); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php index 29dfc16..107eeff 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php @@ -7,7 +7,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Http\Request; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'blobs'); +pest()->group('blob-storage', 'managers', 'blobs'); +covers(BlobPropertyManager::class); it('should get the blob\'s properties', function () { $request = (new RequestFake()) diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php index bc851be..7a24a88 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php @@ -8,7 +8,8 @@ use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'blobs'); +pest()->group('blob-storage', 'managers', 'blobs'); +covers(BlobTagManager::class); it('should get the blob\'s tags', function () { $body = <<group('blob-storage', 'managers', 'accounts'); +pest()->group('blob-storage', 'managers', 'accounts'); +covers(AccountManager::class); it('should get account\'s managers', function (string $method, string $class) { $request = new RequestFake(); diff --git a/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php b/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php index 24859cc..18585ff 100644 --- a/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php @@ -12,7 +12,8 @@ use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'containers'); +pest()->group('blob-storage', 'managers', 'containers'); +covers(ContainerManager::class); it('should get container\'s managers', function (string $method, string $class) { $request = new RequestFake(); diff --git a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php index 4533b88..9307682 100644 --- a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php @@ -7,7 +7,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'containers'); +pest()->group('blob-storage', 'managers', 'containers'); +covers(ContainerAccessLevelManager::class); it('should list all container access levels', function () { $body = <<group('blob-storage', 'managers', 'containers'); +pest()->group('blob-storage', 'managers', 'containers'); +covers(ContainerLeaseManager::class); it('should acquire a new lease', function () { $request = (new RequestFake()) diff --git a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php index 4d58636..9b62d25 100644 --- a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php @@ -8,7 +8,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; -uses()->group('blob-storage', 'managers', 'containers'); +pest()->group('blob-storage', 'managers', 'containers'); +covers(ContainerMetadataManager::class); it('should get the container\'s metadata', function () { $request = (new RequestFake()) diff --git a/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php b/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php index 359696f..12202a4 100644 --- a/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php +++ b/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php @@ -5,7 +5,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\{InvalidArgumentException, RequiredFieldException}; use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake}; -uses()->group('blob-storage', 'queries'); +pest()->group('blob-storage', 'queries'); +covers(QueriesBlobTagQuery::class); it('should create a query', function () { $request = (new RequestFake()); diff --git a/tests/Feature/Converters/XmlConverterTest.php b/tests/Feature/Converters/XmlConverterTest.php index 9869c36..b721bc7 100644 --- a/tests/Feature/Converters/XmlConverterTest.php +++ b/tests/Feature/Converters/XmlConverterTest.php @@ -6,7 +6,8 @@ use Xray\AzureStoragePhpSdk\Converter\XmlConverter; use Xray\AzureStoragePhpSdk\Exceptions\UnableToConvertException; -uses()->group('converters'); +pest()->group('converters'); +covers(XmlConverter::class); it('should implement Converter interface', function () { expect(XmlConverter::class) diff --git a/tests/Feature/HelpersTest.php b/tests/Feature/HelpersTest.php index 294af96..be7efd8 100644 --- a/tests/Feature/HelpersTest.php +++ b/tests/Feature/HelpersTest.php @@ -2,7 +2,7 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('helpers'); +pest()->group('helpers'); it('should check with function', function () { $called = false; @@ -15,22 +15,25 @@ }))->toBe($content); expect($called)->toBeTrue(); -}); +})->covers('with'); it('should check if it\'s running in console', function () { expect(is_running_in_console())->toBeTrue(); -}); +})->covers('is_running_in_console'); it('should fail when an invalid protocol is validated', function () { validate_protocol('invalid'); -})->throws(InvalidArgumentException::class, 'Invalid protocol: invalid. Valid protocols: http, https'); +})->throws( + InvalidArgumentException::class, + 'Invalid protocol: invalid. Valid protocols: http, https', +)->covers('validate_protocol'); it('should pass when a valid protocol is validated', function (string $protocol) { expect(validate_protocol($protocol))->toBeTrue(); })->with([ 'HTTP' => ['http'], 'HTTPS' => ['https'], -]); +])->covers('validate_protocol'); it('should convert camel case string to be used in the headers', function (string $value, string $expected) { expect(str_camel_to_header($value))->toBe($expected); @@ -38,7 +41,7 @@ 'Pascal Case' => ['Test', 'Test'], 'Multi Words' => ['MultiWords', 'Multi-Words'], 'Camel Case' => ['camelCase', 'Camel-Case'], -]); +])->covers('str_camel_to_header'); it('should convert value to boolean type', function (mixed $value, bool $expected) { expect(to_boolean($value))->toBe($expected); @@ -54,14 +57,14 @@ 'String' => ['string', false], 'Object' => [(object)['test' => 'test'], false], 'Array' => [[1, 2, 3], false], -]); +])->covers('to_boolean'); it('should convert date time to RFC1123 format', function () { $datetime = (new DateTime('2022-05-26 04:12:36', new DateTimeZone('Asia/Jakarta'))); $expected = (clone $datetime)->setTimezone(new DateTimeZone('GMT')); expect(convert_to_RFC1123($datetime))->toBe("{$expected->format('D, d M Y H:i:s')} GMT"); -}); +})->covers('convert_to_RFC1123'); it('should convert datetime to RFC3339 micro format', function () { $datetime = (new DateTime('2024-08-10 12:04:59', new DateTimeZone('America/New_York'))); @@ -71,7 +74,7 @@ $microseconds = str_pad($microseconds, 7, '0', STR_PAD_LEFT); expect(convert_to_RFC3339_micro($datetime))->toBe("{$expected->format('Y-m-d\TH:i:s')}.{$microseconds}Z"); -}); +})->covers('convert_to_RFC3339_micro'); it('should convert to ISO format', function (string|DateTimeImmutable $datetime, $expected) { expect(convert_to_ISO($datetime)) @@ -79,4 +82,4 @@ })->with([ 'String' => ['2024-10-10 12:04:59', '2024-10-10T12:04:59Z'], 'DateTimeImmutable' => [(new DateTimeImmutable('2024-10-10 12:04:59', new DateTimeZone('UTC'))), '2024-10-10T12:04:59Z'], -]); +])->covers('convert_to_ISO'); diff --git a/tests/Feature/Http/HeadersTest.php b/tests/Feature/Http/HeadersTest.php index bf2c076..660708b 100644 --- a/tests/Feature/Http/HeadersTest.php +++ b/tests/Feature/Http/HeadersTest.php @@ -6,7 +6,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; use Xray\AzureStoragePhpSdk\Http\Headers; -uses()->group('http'); +pest()->group('http'); +covers(Headers::class); it('should throw an exception if header is missing', function (): void { expect(new Headers()) diff --git a/tests/Feature/Http/RequestTest.php b/tests/Feature/Http/RequestTest.php index 3c13d1a..b52d61e 100644 --- a/tests/Feature/Http/RequestTest.php +++ b/tests/Feature/Http/RequestTest.php @@ -9,7 +9,8 @@ use Xray\AzureStoragePhpSdk\Http\{Headers, Request}; use Xray\Tests\Fakes\ClientFake; -uses()->group('http'); +pest()->group('http'); +covers(Request::class); it('should send get, delete, and options requests', function (string $method, HttpVerb $verb): void { $auth = new SharedKeyAuth(['account' => 'my_account', 'key' => 'bar']); diff --git a/tests/Feature/Http/ResponseTest.php b/tests/Feature/Http/ResponseTest.php index 49419c5..1e5bd74 100644 --- a/tests/Feature/Http/ResponseTest.php +++ b/tests/Feature/Http/ResponseTest.php @@ -7,7 +7,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; use Xray\AzureStoragePhpSdk\Http\Response; -uses()->group('http'); +pest()->group('http'); +covers(Response::class); it('should create from guzzle response', function (): void { expect(Response::createFromGuzzleResponse(new GuzzleResponse())) diff --git a/tests/Feature/Parsers/XmlParserTest.php b/tests/Feature/Parsers/XmlParserTest.php index e7bcf63..f2df3ea 100644 --- a/tests/Feature/Parsers/XmlParserTest.php +++ b/tests/Feature/Parsers/XmlParserTest.php @@ -6,7 +6,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\UnableToParseException; use Xray\AzureStoragePhpSdk\Parsers\XmlParser; -uses()->group('parsers'); +pest()->group('parsers'); +covers(XmlParser::class); it('should implement Parser interface', function () { expect(XmlParser::class) diff --git a/tests/Feature/Support/CollectionTest.php b/tests/Feature/Support/CollectionTest.php index 9e407b6..b68b364 100644 --- a/tests/Feature/Support/CollectionTest.php +++ b/tests/Feature/Support/CollectionTest.php @@ -5,7 +5,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Arrayable; use Xray\AzureStoragePhpSdk\Support\Collection; -uses()->group('supports'); +pest()->group('supports'); +covers(Collection::class); it('should have the correct architecture', function () { expect(Collection::class) diff --git a/tests/Unit/Concerns/HasManagerTest.php b/tests/Unit/Concerns/HasManagerTest.php index a974aae..99792af 100644 --- a/tests/Unit/Concerns/HasManagerTest.php +++ b/tests/Unit/Concerns/HasManagerTest.php @@ -6,7 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Manager; use Xray\AzureStoragePhpSdk\Exceptions\ManagerNotSetException; -uses()->group('concerns', 'traits'); +pest()->group('concerns', 'traits'); +covers(HasManager::class); it('should throw an exception if the manager is not set', function () { $class = new class () { diff --git a/tests/Unit/Concerns/HasRequestSharedTest.php b/tests/Unit/Concerns/HasRequestSharedTest.php index 0fddc64..425b292 100644 --- a/tests/Unit/Concerns/HasRequestSharedTest.php +++ b/tests/Unit/Concerns/HasRequestSharedTest.php @@ -6,7 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Http\Request; use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; -uses()->group('concerns', 'traits'); +pest()->group('concerns', 'traits'); +covers(HasRequestShared::class); it('should have a request shared property', function () { $request = new RequestFake(); diff --git a/tests/Unit/Entities/Blob/BlobMetadataTest.php b/tests/Unit/Entities/Blob/BlobMetadataTest.php index bfc93de..e36511b 100644 --- a/tests/Unit/Entities/Blob/BlobMetadataTest.php +++ b/tests/Unit/Entities/Blob/BlobMetadataTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Blob\BlobMetadata; -uses()->group('entities', 'blobs'); +pest()->group('entities', 'blobs'); +covers(BlobMetadata::class); it('should get the metadata property', function (string $property, string $value) { $metadata = new BlobMetadata([ diff --git a/tests/Unit/Entities/Blob/BlobTagTest.php b/tests/Unit/Entities/Blob/BlobTagTest.php index fdc11ed..4705cfd 100644 --- a/tests/Unit/Entities/Blob/BlobTagTest.php +++ b/tests/Unit/Entities/Blob/BlobTagTest.php @@ -5,7 +5,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Blob\{BlobTag}; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('entities', 'blobs'); +pest()->group('entities', 'blobs'); +covers(BlobTag::class); it('should mount the blob tags', function () { $blobTag = new BlobTag([ diff --git a/tests/Unit/Entities/Blob/BlobTest.php b/tests/Unit/Entities/Blob/BlobTest.php index 46180cc..a40476e 100644 --- a/tests/Unit/Entities/Blob/BlobTest.php +++ b/tests/Unit/Entities/Blob/BlobTest.php @@ -11,7 +11,8 @@ use function Xray\Tests\mock; -uses()->group('entities', 'blobs'); +pest()->group('entities', 'blobs'); +covers(Blob::class); it('should throw an exception if the blob name isn\'t provided', function () { $blob = new Blob([]); diff --git a/tests/Unit/Entities/Container/ContainerLeaseTest.php b/tests/Unit/Entities/Container/ContainerLeaseTest.php index e32fe7a..fa73ee9 100644 --- a/tests/Unit/Entities/Container/ContainerLeaseTest.php +++ b/tests/Unit/Entities/Container/ContainerLeaseTest.php @@ -9,7 +9,8 @@ use function Xray\Tests\mock; -uses()->group('entities', 'containers'); +pest()->group('entities', 'containers'); +covers(ContainerLease::class); it('should renew the container lease', function () { /** @var ContainerLeaseManager $mock */ diff --git a/tests/Unit/Exceptions/CouldNotCreateTempFileExceptionTest.php b/tests/Unit/Exceptions/CouldNotCreateTempFileExceptionTest.php index ba4ab32..b4e0cdf 100644 --- a/tests/Unit/Exceptions/CouldNotCreateTempFileExceptionTest.php +++ b/tests/Unit/Exceptions/CouldNotCreateTempFileExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\CouldNotCreateTempFileException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(CouldNotCreateTempFileException::class); it('should be an exception', function () { expect(CouldNotCreateTempFileException::class) diff --git a/tests/Unit/Exceptions/InvalidArgumentExceptionTest.php b/tests/Unit/Exceptions/InvalidArgumentExceptionTest.php index 94dbb7d..04b783c 100644 --- a/tests/Unit/Exceptions/InvalidArgumentExceptionTest.php +++ b/tests/Unit/Exceptions/InvalidArgumentExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(InvalidArgumentException::class); it('should be an exception', function () { expect(InvalidArgumentException::class) diff --git a/tests/Unit/Exceptions/InvalidFileMimeTypeExceptionTest.php b/tests/Unit/Exceptions/InvalidFileMimeTypeExceptionTest.php index 2389ef5..b3afb7d 100644 --- a/tests/Unit/Exceptions/InvalidFileMimeTypeExceptionTest.php +++ b/tests/Unit/Exceptions/InvalidFileMimeTypeExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidFileMimeTypeException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(InvalidFileMimeTypeException::class); it('can create an InvalidFileMimeTypeException instance', function () { $exception = InvalidFileMimeTypeException::create(); diff --git a/tests/Unit/Exceptions/ManagerNotSetExceptionTest.php b/tests/Unit/Exceptions/ManagerNotSetExceptionTest.php index 54f5577..e39cc09 100644 --- a/tests/Unit/Exceptions/ManagerNotSetExceptionTest.php +++ b/tests/Unit/Exceptions/ManagerNotSetExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\ManagerNotSetException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(ManagerNotSetException::class); it('should be an exception', function () { expect(ManagerNotSetException::class) diff --git a/tests/Unit/Exceptions/RequestExceptionTest.php b/tests/Unit/Exceptions/RequestExceptionTest.php index 5b6a03b..1959a2c 100644 --- a/tests/Unit/Exceptions/RequestExceptionTest.php +++ b/tests/Unit/Exceptions/RequestExceptionTest.php @@ -7,7 +7,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\RequestException; use Xray\AzureStoragePhpSdk\Exceptions\RequestException\FailedAuthenticationException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(RequestException::class); it('should be an exception', function () { expect(RequestException::class) diff --git a/tests/Unit/Exceptions/RequiredFieldExceptionTest.php b/tests/Unit/Exceptions/RequiredFieldExceptionTest.php index 4d62dd5..3620956 100644 --- a/tests/Unit/Exceptions/RequiredFieldExceptionTest.php +++ b/tests/Unit/Exceptions/RequiredFieldExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(RequiredFieldException::class); it('should be an exception', function () { expect(RequiredFieldException::class) diff --git a/tests/Unit/Exceptions/UnableToConvertExceptionTest.php b/tests/Unit/Exceptions/UnableToConvertExceptionTest.php index ec4f590..5486412 100644 --- a/tests/Unit/Exceptions/UnableToConvertExceptionTest.php +++ b/tests/Unit/Exceptions/UnableToConvertExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\UnableToConvertException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(UnableToConvertException::class); it('should be an exception', function () { expect(UnableToConvertException::class) diff --git a/tests/Unit/Exceptions/UnableToParseExceptionTest.php b/tests/Unit/Exceptions/UnableToParseExceptionTest.php index d2f8d8f..309d54e 100644 --- a/tests/Unit/Exceptions/UnableToParseExceptionTest.php +++ b/tests/Unit/Exceptions/UnableToParseExceptionTest.php @@ -4,7 +4,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\UnableToParseException; -uses()->group('exceptions'); +pest()->group('exceptions'); +covers(UnableToParseException::class); it('should be an exception', function () { expect(UnableToParseException::class) diff --git a/tests/Unit/Resources/FileTest.php b/tests/Unit/Resources/FileTest.php index 8011924..4233fc8 100644 --- a/tests/Unit/Resources/FileTest.php +++ b/tests/Unit/Resources/FileTest.php @@ -5,7 +5,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resources\File; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -uses()->group('resources'); +pest()->group('resources'); +covers(File::class); it('should not be able to create a file without a name', function () { $file = new File('', 'content'); From 3f62a02fe6bc7d98442fdd2c52aae585003c99a8 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 11:25:19 -0300 Subject: [PATCH 13/17] resolve phpstan --- phpstan.neon | 2 +- src/BlobStorage/Resource.php | 25 +++++++++---------- .../BlobStorage/Queries/BlobTagQueryTest.php | 4 +-- tests/Feature/Http/RequestTest.php | 14 +++++------ 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 32a2bf5..7e9daa4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,7 @@ parameters: ignoreErrors: - messages: - - '#Call to an undefined method Pest\\PendingCalls\\TestCall\:\:expect\(\)#' + - '#Call to an undefined method Pest\\PendingCalls\\TestCall\:\:(expect|preset)\(\)#' - '#Undefined variable\: \$this#' - '#Call to an undefined method Pest(\\Mixins)?\\Expectation\<.+?\>\:\:[a-zA-Z]+?\(\)#' - '#Access to an undefined property Pest(\\Mixins)?\\Expectation\<.+?\>\:\:\$[a-zA-Z]+?#' diff --git a/src/BlobStorage/Resource.php b/src/BlobStorage/Resource.php index 8d62cc5..23daf4e 100644 --- a/src/BlobStorage/Resource.php +++ b/src/BlobStorage/Resource.php @@ -78,29 +78,28 @@ public static function canonicalize(string $uri): string $result .= mb_convert_case($key, MB_CASE_LOWER, 'UTF-8') . ':' . $value . "\n"; } - return $parsed['path'] . "\n" . rtrim($result, "\n"); + return "{$parsed['path']}\n" . rtrim($result, "\n"); } - /** @return array */ + /** @return array{path: string, query: array} */ protected static function parseUrl(string $uri): array { /** @var array */ $parsed = parse_url($uri); - if (trim($parsed['query'] ?? '') === '') { - $parsed['query'] = []; + /** @var string $path */ + $path = $parsed['path'] ?? ''; - return $parsed; - } - - $parsed['query'] = array_reduce(explode('&', $parsed['query']), function (array $carry, string $query): array { - $parts = explode('=', $query); + $queryParams = trim($parsed['query'] ?? '') === '' + ? [] + : array_reduce(explode('&', $parsed['query']), function (array $carry, string $query): array { + $parts = explode('=', $query); - $carry[$parts[0]] = $parts[1]; + $carry[$parts[0]] = $parts[1]; - return $carry; - }, []); + return $carry; + }, []); - return $parsed; + return ['path' => $path, 'query' => $queryParams]; } } diff --git a/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php b/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php index 12202a4..0d5f0ef 100644 --- a/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php +++ b/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php @@ -18,7 +18,7 @@ ->where('sequence', '>', '2') ->where('sequence', '<', '10'); - expect((fn () => $this->wheres)->call($query)) + expect((fn () => $this->wheres)->call($query)) // @phpstan-ignore-line ->toHaveCount(3) ->toEqual([ ['tag' => 'tag', 'operator' => '=', 'value' => 'value'], @@ -37,7 +37,7 @@ return (object) ['query' => $query]; }); - expect((fn () => $this->callback)->call($query)) + expect((fn () => $this->callback)->call($query)) // @phpstan-ignore-line ->toBeInstanceOf(Closure::class); }); diff --git a/tests/Feature/Http/RequestTest.php b/tests/Feature/Http/RequestTest.php index b52d61e..b976107 100644 --- a/tests/Feature/Http/RequestTest.php +++ b/tests/Feature/Http/RequestTest.php @@ -33,11 +33,11 @@ ); $getRequestOptions = fn () => (object)[ - 'options' => $this->options, - 'headers' => $this->headers, + 'options' => $this->options, // @phpstan-ignore-line + 'headers' => $this->headers, // @phpstan-ignore-line ]; - expect($getRequestOptions->call($request)) + expect($getRequestOptions->call($request)) // @phpstan-ignore-line ->options->toBeEmpty() ->headers->toBeEmpty(); })->with([ @@ -72,12 +72,12 @@ ); $getRequestOptions = fn () => (object)[ - 'options' => $this->options, - 'headers' => $this->headers, - 'shouldAuthenticate' => $this->shouldAuthenticate, + 'options' => $this->options, // @phpstan-ignore-line + 'headers' => $this->headers, // @phpstan-ignore-line + 'shouldAuthenticate' => $this->shouldAuthenticate, // @phpstan-ignore-line ]; - expect($getRequestOptions->call($request)) + expect($getRequestOptions->call($request)) // @phpstan-ignore-line ->options->toBeEmpty() ->headers->toBeEmpty() ->shouldAuthenticate->toBeTrue(); From 70ef4029ba64f5353aa20eafa8b154c324e032ff Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 11:48:23 -0300 Subject: [PATCH 14/17] increase test coverage --- .github/workflows/CI.yaml | 2 +- captainhook.json | 2 +- .../BlobStorage/BlobStorateResouceTest.php | 11 ++++++---- tests/Feature/Http/HeadersTest.php | 10 ++++++++++ tests/Unit/Enums/BlobIncludeOptionTest.php | 14 +++++++++++++ ...validAuthenticationMethodExceptionTest.php | 20 +++++++++++++++++++ .../InvalidResourceTypeExceptionTest.php | 20 +++++++++++++++++++ tests/Unit/Resources/FileTest.php | 7 +++++++ 8 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 tests/Unit/Enums/BlobIncludeOptionTest.php create mode 100644 tests/Unit/Exceptions/Authentication/InvalidAuthenticationMethodExceptionTest.php create mode 100644 tests/Unit/Exceptions/InvalidResourceTypeExceptionTest.php diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 4509e24..fbccc91 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -35,4 +35,4 @@ jobs: run: ./vendor/bin/phpstan analyse - name: Run Pest - run: ./vendor/bin/pest --coverage --min=100 --parallel + run: ./vendor/bin/pest --coverage --min=76 --parallel diff --git a/captainhook.json b/captainhook.json index 9d2aa8d..f75a3ab 100644 --- a/captainhook.json +++ b/captainhook.json @@ -27,7 +27,7 @@ "action": "./vendor/bin/phpstan analyse" }, { - "action": "./vendor/bin/pest --coverage --min=100 --parallel" + "action": "./vendor/bin/pest --coverage --min=76 --parallel" } ] }, diff --git a/tests/Feature/BlobStorage/BlobStorateResouceTest.php b/tests/Feature/BlobStorage/BlobStorateResouceTest.php index c2c1b54..8c61730 100644 --- a/tests/Feature/BlobStorage/BlobStorateResouceTest.php +++ b/tests/Feature/BlobStorage/BlobStorateResouceTest.php @@ -7,9 +7,12 @@ pest()->group('blob-storage'); covers(Resource::class); -it('should canonicalize resource correctly', function () { - $uri = 'https://account.blob.core.windows.net/container/?RestType=service&Comp=properties'; +it('should canonicalize resource correctly', function (string $query, string $expected) { + $uri = "https://account.blob.core.windows.net/container/?{$query}"; expect(Resource::canonicalize($uri)) - ->toBe("/container/\ncomp:properties\nresttype:service"); -}); + ->toBe("/container/\n{$expected}"); +})->with([ + 'With Query Params' => ['RestType=service&Comp=properties', "comp:properties\nresttype:service"], + 'Without Query Params' => ['', ''], +]); diff --git a/tests/Feature/Http/HeadersTest.php b/tests/Feature/Http/HeadersTest.php index 660708b..842313b 100644 --- a/tests/Feature/Http/HeadersTest.php +++ b/tests/Feature/Http/HeadersTest.php @@ -49,6 +49,16 @@ 'Range' => ['setRange', 'bytes=0-100', 'Range'], ]); +it('should check if headers has the given header', function () { + $headers = Headers::parse([ + 'Content-Encoding' => 'utf-8', + ]); + + expect($headers) + ->has('Content-Encoding')->toBeTrue() + ->has('Content-Language')->toBeFalse(); +}); + it('should add additional headers', function () { $headers = (new Headers()) ->withAdditionalHeaders(['foo' => 'bar']) diff --git a/tests/Unit/Enums/BlobIncludeOptionTest.php b/tests/Unit/Enums/BlobIncludeOptionTest.php new file mode 100644 index 0000000..3fc7cc9 --- /dev/null +++ b/tests/Unit/Enums/BlobIncludeOptionTest.php @@ -0,0 +1,14 @@ +group('enums'); +covers(BlobIncludeOption::class); + +it('should return the enum as an array', function () { + expect(BlobIncludeOption::toArray()) + ->toBeArray() + ->toBe(array_map(fn (BlobIncludeOption $enum) => $enum->value, BlobIncludeOption::cases())); +}); diff --git a/tests/Unit/Exceptions/Authentication/InvalidAuthenticationMethodExceptionTest.php b/tests/Unit/Exceptions/Authentication/InvalidAuthenticationMethodExceptionTest.php new file mode 100644 index 0000000..72efe25 --- /dev/null +++ b/tests/Unit/Exceptions/Authentication/InvalidAuthenticationMethodExceptionTest.php @@ -0,0 +1,20 @@ +group('exceptions', 'authentications'); +covers(InvalidAuthenticationMethodException::class); + +it('should be an exception', function () { + expect(InvalidAuthenticationMethodException::class) + ->toExtend(Exception::class); +}); + +it('should create an InvalidAuthenticationMethodException instance', function () { + $exception = InvalidAuthenticationMethodException::create($message = 'Invalid authentication method'); + + expect($exception)->toBeInstanceOf(InvalidAuthenticationMethodException::class) + ->getMessage()->toBe($message); +}); diff --git a/tests/Unit/Exceptions/InvalidResourceTypeExceptionTest.php b/tests/Unit/Exceptions/InvalidResourceTypeExceptionTest.php new file mode 100644 index 0000000..0452628 --- /dev/null +++ b/tests/Unit/Exceptions/InvalidResourceTypeExceptionTest.php @@ -0,0 +1,20 @@ +group('exceptions'); +covers(InvalidResourceTypeException::class); + +it('should be an exception', function () { + expect(InvalidResourceTypeException::class) + ->toExtend(Exception::class); +}); + +it('should create an InvalidResourceTypeException instance', function () { + $exception = InvalidResourceTypeException::create($message = 'Invalid resource type'); + + expect($exception)->toBeInstanceOf(InvalidResourceTypeException::class) + ->getMessage()->toBe($message); +}); diff --git a/tests/Unit/Resources/FileTest.php b/tests/Unit/Resources/FileTest.php index 4233fc8..55db0f2 100644 --- a/tests/Unit/Resources/FileTest.php +++ b/tests/Unit/Resources/FileTest.php @@ -60,3 +60,10 @@ 'Encrypted' => ['getServerEncrypted', true], 'Date' => ['getDate', fn () => new DateTimeImmutable('2021-10-05T00:00:00.0000000Z')], ]); + +it('should detect the content type based on the content', function () { + $file = new File('name', 'content'); + + expect($file->getContentType()) + ->toBe('text/plain'); +}); From c07d78663b2438b2a85807e0770a2196fe65dc17 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 12:28:46 -0300 Subject: [PATCH 15/17] add fake to blob storage client --- phpunit.xml | 2 +- src/BlobStorage/BlobStorageClient.php | 3 +++ src/BlobStorage/Concerns/HasFakeRequest.php | 20 ++++++++++++++ .../Http/Concerns/HasAuthAssertions.php | 2 +- .../Http/Concerns/HasHttpAssertions.php | 2 +- .../Http/Concerns/HasSharableHttp.php | 2 +- src/{Tests => Fakes}/Http/RequestFake.php | 4 +-- src/{Tests => Fakes}/Http/ResponseFake.php | 2 +- .../Authentication/MicrosoftEntraIdTest.php | 2 +- .../UserDelegationSasTest.php | 2 +- .../Authentication/SharedKeyAuthTest.php | 2 +- .../BlobStorage/BlobStorageClientTest.php | 2 +- .../Concerns/HasFakeRequestTest.php | 26 +++++++++++++++++++ .../Container/BlobStorageContainerTest.php | 2 +- ...StoragePreflightBlobRequestManagerTest.php | 2 +- .../BlobStorageStoragePropertyManagerTest.php | 2 +- .../Managers/Blob/BlobLeaseManagerTest.php | 2 +- .../Blob/BlobStorageBlobManagerTest.php | 2 +- .../BlobStorageBlobMetadataManagerTest.php | 2 +- .../Blob/BlobStorageBlobPageManagerTest.php | 2 +- .../BlobStorageBlobPropertyManagerTest.php | 2 +- .../Blob/BlobStorageBlobTagManagerTest.php | 2 +- .../BlobStorageAccountManagerTest.php | 2 +- .../BlobStorageContainerManagerTest.php | 2 +- ...StorageContainerAccessLevelManagerTest.php | 2 +- .../BlobStorageContainerLeaseManagerTest.php | 2 +- ...lobStorageContainerMetadataManagerTest.php | 2 +- .../BlobStorage/Queries/BlobTagQueryTest.php | 2 +- tests/TestCase.php | 2 +- tests/Unit/Concerns/HasRequestSharedTest.php | 2 +- 30 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 src/BlobStorage/Concerns/HasFakeRequest.php rename src/{Tests => Fakes}/Http/Concerns/HasAuthAssertions.php (88%) rename src/{Tests => Fakes}/Http/Concerns/HasHttpAssertions.php (97%) rename src/{Tests => Fakes}/Http/Concerns/HasSharableHttp.php (95%) rename src/{Tests => Fakes}/Http/RequestFake.php (97%) rename src/{Tests => Fakes}/Http/ResponseFake.php (96%) create mode 100644 tests/Feature/BlobStorage/Concerns/HasFakeRequestTest.php diff --git a/phpunit.xml b/phpunit.xml index 51a796c..3f5a684 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -21,7 +21,7 @@ - ./src/Tests + ./src/Fakes diff --git a/src/BlobStorage/BlobStorageClient.php b/src/BlobStorage/BlobStorageClient.php index a731688..e2381a0 100644 --- a/src/BlobStorage/BlobStorageClient.php +++ b/src/BlobStorage/BlobStorageClient.php @@ -4,6 +4,7 @@ namespace Xray\AzureStoragePhpSdk\BlobStorage; +use Xray\AzureStoragePhpSdk\BlobStorage\Concerns\HasFakeRequest; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobManager; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\{AccountManager, ContainerManager}; use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; @@ -13,6 +14,8 @@ final class BlobStorageClient { + use HasFakeRequest; + public function __construct(protected RequestContract $request) { azure_app()->instance(RequestContract::class, $this->request); diff --git a/src/BlobStorage/Concerns/HasFakeRequest.php b/src/BlobStorage/Concerns/HasFakeRequest.php new file mode 100644 index 0000000..bbf1aee --- /dev/null +++ b/src/BlobStorage/Concerns/HasFakeRequest.php @@ -0,0 +1,20 @@ +group('authentications'); diff --git a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php index a4d313b..3a2957e 100644 --- a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php +++ b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php @@ -9,7 +9,7 @@ use Xray\AzureStoragePhpSdk\Contracts\Authentication\SharedAccessSignature; use Xray\AzureStoragePhpSdk\Exceptions\Authentication\InvalidAuthenticationMethodException; use Xray\AzureStoragePhpSdk\Exceptions\InvalidResourceTypeException; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('authentications', 'shared-access-signatures'); covers(UserDelegationSas::class); diff --git a/tests/Feature/Authentication/SharedKeyAuthTest.php b/tests/Feature/Authentication/SharedKeyAuthTest.php index b3d2bda..8754649 100644 --- a/tests/Feature/Authentication/SharedKeyAuthTest.php +++ b/tests/Feature/Authentication/SharedKeyAuthTest.php @@ -7,8 +7,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; +use Xray\AzureStoragePhpSdk\Fakes\Http\RequestFake; use Xray\AzureStoragePhpSdk\Http\Headers; -use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; pest()->group('authentications'); covers(SharedKeyAuth::class); diff --git a/tests/Feature/BlobStorage/BlobStorageClientTest.php b/tests/Feature/BlobStorage/BlobStorageClientTest.php index 6e64da4..268e723 100644 --- a/tests/Feature/BlobStorage/BlobStorageClientTest.php +++ b/tests/Feature/BlobStorage/BlobStorageClientTest.php @@ -6,7 +6,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobManager; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\{AccountManager, ContainerManager}; use Xray\AzureStoragePhpSdk\BlobStorage\{BlobStorageClient, Config}; -use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; +use Xray\AzureStoragePhpSdk\Fakes\Http\RequestFake; pest()->group('blob-storage'); covers(BlobStorageClient::class); diff --git a/tests/Feature/BlobStorage/Concerns/HasFakeRequestTest.php b/tests/Feature/BlobStorage/Concerns/HasFakeRequestTest.php new file mode 100644 index 0000000..4966f4c --- /dev/null +++ b/tests/Feature/BlobStorage/Concerns/HasFakeRequestTest.php @@ -0,0 +1,26 @@ +group('blob-storage', 'concerns'); +covers(HasFakeRequest::class); + +it('should create a fake instance', function () { + $class = ClientToHasFakeRequestTest::fake(); + + expect($class) + ->toBeInstanceOf(ClientToHasFakeRequestTest::class) + ->request->toBeInstanceOf(RequestFake::class); +}); + +readonly class ClientToHasFakeRequestTest +{ + use HasFakeRequest; + + public function __construct(public RequestContract $request) + { + // + } +} diff --git a/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php b/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php index 78e7e5f..f9004f1 100644 --- a/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php +++ b/tests/Feature/BlobStorage/Entities/Container/BlobStorageContainerTest.php @@ -8,8 +8,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Container\ContainerLeaseManager; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\ContainerManager; use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'entities', 'containers'); covers(Container::class); diff --git a/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php b/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php index 267419b..cfeef11 100644 --- a/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Account/BlobStoragePreflightBlobRequestManagerTest.php @@ -5,7 +5,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Enums\HttpVerb; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Account\PreflightBlobRequestManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; -use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; +use Xray\AzureStoragePhpSdk\Fakes\Http\RequestFake; pest()->group('blob-storage', 'managers', 'account'); covers(PreflightBlobRequestManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php b/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php index 1b10b65..be7034a 100644 --- a/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Account/BlobStorageStoragePropertyManagerTest.php @@ -6,8 +6,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Account\BlobStorageProperty\{BlobProperty, DeleteRetentionPolicy, HourMetrics, Logging, MinuteMetrics, StaticWebsite}; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Account\StoragePropertyManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'account'); covers(StoragePropertyManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobLeaseManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobLeaseManagerTest.php index a72177f..6686a13 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobLeaseManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobLeaseManagerTest.php @@ -3,7 +3,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Blob\BlobLease; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobLeaseManager; use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'blob'); covers(BlobLeaseManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php index 73aed78..c0a9ffc 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php @@ -15,8 +15,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resources\File; use Xray\AzureStoragePhpSdk\BlobStorage\{Resource, SignatureResource}; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; use function Xray\Tests\mock; diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php index c9e7fe7..ebdc338 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobMetadataManagerTest.php @@ -5,7 +5,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Blob\BlobMetadata; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobMetadataManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'blobs'); covers(BlobMetadataManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php index 7865be6..eab404e 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPageManagerTest.php @@ -7,8 +7,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\BlobStorage\Resources\File; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'blobs'); covers(BlobPageManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php index 107eeff..ffe5c40 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobPropertyManagerTest.php @@ -5,7 +5,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Blob\BlobProperty; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobPropertyManager; use Xray\AzureStoragePhpSdk\Contracts\Http\Request; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'blobs'); covers(BlobPropertyManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php index 7a24a88..71ba081 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobTagManagerTest.php @@ -5,8 +5,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Blob\BlobTag; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobTagManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'blobs'); covers(BlobTagManager::class); diff --git a/tests/Feature/BlobStorage/Managers/BlobStorageAccountManagerTest.php b/tests/Feature/BlobStorage/Managers/BlobStorageAccountManagerTest.php index e05ba2c..bbcee96 100644 --- a/tests/Feature/BlobStorage/Managers/BlobStorageAccountManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/BlobStorageAccountManagerTest.php @@ -5,7 +5,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Account\{AccountInformation, GeoReplication, KeyInfo, UserDelegationKey}; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Account\{PreflightBlobRequestManager, StoragePropertyManager}; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\AccountManager; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'accounts'); covers(AccountManager::class); diff --git a/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php b/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php index 18585ff..1674fa3 100644 --- a/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/BlobStorageContainerManagerTest.php @@ -9,8 +9,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Managers\ContainerManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'containers'); covers(ContainerManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php index 9307682..7245093 100644 --- a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerAccessLevelManagerTest.php @@ -5,7 +5,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Container\AccessLevel\{ContainerAccessLevel, ContainerAccessLevels}; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Container\ContainerAccessLevelManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'containers'); covers(ContainerAccessLevelManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerLeaseManagerTest.php b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerLeaseManagerTest.php index a44c53e..b817ea9 100644 --- a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerLeaseManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerLeaseManagerTest.php @@ -5,7 +5,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Entities\Container\ContainerLease; use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Container\ContainerLeaseManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'containers'); covers(ContainerLeaseManager::class); diff --git a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php index 9b62d25..3674e47 100644 --- a/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Container/BlobStorageContainerMetadataManagerTest.php @@ -6,7 +6,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Container\ContainerMetadataManager; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake, ResponseFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; pest()->group('blob-storage', 'managers', 'containers'); covers(ContainerMetadataManager::class); diff --git a/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php b/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php index 0d5f0ef..1335726 100644 --- a/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php +++ b/tests/Feature/BlobStorage/Queries/BlobTagQueryTest.php @@ -3,7 +3,7 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Managers\Blob\BlobManager; use Xray\AzureStoragePhpSdk\BlobStorage\Queries\BlobTagQuery as QueriesBlobTagQuery; use Xray\AzureStoragePhpSdk\Exceptions\{InvalidArgumentException, RequiredFieldException}; -use Xray\AzureStoragePhpSdk\Tests\Http\{RequestFake}; +use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake}; pest()->group('blob-storage', 'queries'); covers(QueriesBlobTagQuery::class); diff --git a/tests/TestCase.php b/tests/TestCase.php index e80fa37..45016c7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase as BaseTestCase; use Xray\AzureStoragePhpSdk\Contracts\Http\Request; -use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; +use Xray\AzureStoragePhpSdk\Fakes\Http\RequestFake; abstract class TestCase extends BaseTestCase { diff --git a/tests/Unit/Concerns/HasRequestSharedTest.php b/tests/Unit/Concerns/HasRequestSharedTest.php index 425b292..d819142 100644 --- a/tests/Unit/Concerns/HasRequestSharedTest.php +++ b/tests/Unit/Concerns/HasRequestSharedTest.php @@ -4,7 +4,7 @@ use Xray\AzureStoragePhpSdk\Concerns\HasRequestShared; use Xray\AzureStoragePhpSdk\Contracts\Http\Request; -use Xray\AzureStoragePhpSdk\Tests\Http\RequestFake; +use Xray\AzureStoragePhpSdk\Fakes\Http\RequestFake; pest()->group('concerns', 'traits'); covers(HasRequestShared::class); From 0538da4c905743922609a4027c2d1179de39ca9c Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 12:46:25 -0300 Subject: [PATCH 16/17] remove final from client --- src/BlobStorage/BlobStorageClient.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BlobStorage/BlobStorageClient.php b/src/BlobStorage/BlobStorageClient.php index e2381a0..4ca5ef2 100644 --- a/src/BlobStorage/BlobStorageClient.php +++ b/src/BlobStorage/BlobStorageClient.php @@ -12,7 +12,7 @@ use Xray\AzureStoragePhpSdk\Contracts\{Converter, Parser}; use Xray\AzureStoragePhpSdk\Http\Request; -final class BlobStorageClient +class BlobStorageClient { use HasFakeRequest; @@ -25,6 +25,7 @@ public function __construct(protected RequestContract $request) /** @param array{version?: string, parser?: Parser, converter?: Converter} $config */ public static function create(Auth $auth, array $config = []): static { + /** @phpstan-ignore-next-line */ return new static(new Request($auth, new Config($config))); } From 6a396c9c0be658530c31055d4bd464eef74fc17b Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 14 Sep 2024 15:59:29 -0300 Subject: [PATCH 17/17] enhance container name validation --- src/BlobStorage/Concerns/ValidateContainerName.php | 2 +- .../Feature/BlobStorage/Concerns/ValidateContainerNameTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BlobStorage/Concerns/ValidateContainerName.php b/src/BlobStorage/Concerns/ValidateContainerName.php index 4080cbb..a807159 100644 --- a/src/BlobStorage/Concerns/ValidateContainerName.php +++ b/src/BlobStorage/Concerns/ValidateContainerName.php @@ -13,7 +13,7 @@ protected function validateContainerName(string $name): void { $replaced = preg_replace('/[^a-z0-9-]/', '', $name); - if ($replaced !== $name) { + if (trim($name) === '' || $replaced !== $name) { throw InvalidArgumentException::create("Invalid container name: {$name}"); } } diff --git a/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php b/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php index f85a7e7..068856b 100644 --- a/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php +++ b/tests/Feature/BlobStorage/Concerns/ValidateContainerNameTest.php @@ -37,4 +37,5 @@ public function assertContainerName(string $name): void 'With Capital Letters' => ['TEST'], 'With Spaces' => ['test test'], 'With Special Chars' => ['test*'], + 'Empty String' => [''], ]);