Skip to content

Commit

Permalink
Merge pull request #13 from mostafaznv/dev
Browse files Browse the repository at this point in the history
GetValue method added to CacheEnum.php
  • Loading branch information
mostafaznv authored Jun 2, 2023
2 parents 8b321dd + 137c6c5 commit 0f4e488
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Utils/CacheEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ public static function __callStatic(string $name, array $arguments): self
return new static($name);
}

public function getValue(): int|string
{
return $this->value;
}

public function equals(self $other): bool
{
return get_class($this) === get_class($other) and $this->value === $other->value;
return get_class($this) === get_class($other) and $this->getValue() === $other->getValue();
}
}
21 changes: 21 additions & 0 deletions tests/Unit/CacheStatusTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Mostafaznv\LaraCache\DTOs\CacheStatus;


it('can determine if two cache status are equal', function() {
$isEqual = CacheStatus::CREATED()->equals(CacheStatus::CREATED());
expect($isEqual)->toBeTrue();

$isEqual = CacheStatus::CREATED()->equals(CacheStatus::DELETED());
expect($isEqual)->toBeFalse();
});

it('can get value of cache status', function(CacheStatus $status, string $value) {
expect($status->getValue())->toBe($value);
})->with([
'NOT_CREATED' => ['status' => CacheStatus::NOT_CREATED(), 'value' => 'NOT_CREATED'],
'CREATING' => ['status' => CacheStatus::CREATING(), 'value' => 'CREATING'],
'CREATED' => ['status' => CacheStatus::CREATED(), 'value' => 'CREATED'],
'DELETED' => ['status' => CacheStatus::DELETED(), 'value' => 'DELETED'],
]);

0 comments on commit 0f4e488

Please sign in to comment.