-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
isAnyOf()
, isNoneOf()
and doesNotEqualTo()
methods
- Loading branch information
1 parent
29453c2
commit 1e7dc3d
Showing
4 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the IsAnyOfTest class. | ||
* | ||
* @copyright Copyright (c) 2024 Attila Fulop | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2024-02-29 | ||
* | ||
*/ | ||
|
||
namespace Konekt\Enum\Tests; | ||
|
||
use Konekt\Enum\Tests\Fixture\Another123; | ||
use Konekt\Enum\Tests\Fixture\Sample123; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IsAnyOfTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function is_any_of_returns_true_when_passing_the_same_instance() | ||
{ | ||
$one = Sample123::create(1); | ||
|
||
$this->assertTrue($one->isAnyOf($one)); | ||
} | ||
|
||
/** @test */ | ||
public function is_any_of_returns_true_when_passing_the_same_value_but_separate_instances() | ||
{ | ||
$one = Sample123::create(1); | ||
|
||
$this->assertTrue($one->isAnyOf(Sample123::create(1))); | ||
} | ||
|
||
/** @test */ | ||
public function is_any_of_returns_true_when_passing_multiple_values_of_which_one_equals_the() | ||
{ | ||
$one = Sample123::create(1); | ||
|
||
$this->assertTrue($one->isAnyOf(Sample123::ONE(), Sample123::TWO())); | ||
} | ||
|
||
/** @test */ | ||
public function is_none_of_returns_true_when_passing_nothing() | ||
{ | ||
$one = Sample123::create(1); | ||
|
||
$this->assertTrue($one->isNoneOf()); | ||
} | ||
|
||
/** @test */ | ||
public function is_none_of_returns_true_when_passing_enums_of_which_none_equals_the_base_enum() | ||
{ | ||
$three = Sample123::create(3); | ||
|
||
$this->assertTrue($three->isNoneOf(Sample123::ONE(), Sample123::TWO())); | ||
} | ||
|
||
/** @test */ | ||
public function mixing_separate_enums_with_same_underlying_values_will_not_match() | ||
{ | ||
$two = Sample123::TWO(); | ||
|
||
$this->assertTrue($two->isNoneOf(Another123::TWO())); | ||
} | ||
} |