Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to compare enums by using static access. Closes #61 #62

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

dionysiosarvanitis
Copy link

@dionysiosarvanitis dionysiosarvanitis commented Jul 17, 2020

fixes #61

It works for the case. Hope rest of the tests will pass! :)

@Gummibeer
Copy link
Collaborator

Thanks for your fast fix! 🚀

Something bad happened in CI. 😮
I will merge it into a dedicated feature branch and fix CI/code if needed. Your changes look good! 🙂

@Gummibeer Gummibeer merged commit 3e7d9bf into spatie:master Jul 17, 2020
@Gummibeer
Copy link
Collaborator

Okay, we really had tests that tested for the behavior you fixed. 🤯

enum/tests/BoolEnumTest.php

Lines 301 to 316 in 3e7d9bf

public function can_not_check_for_static_equality_with_invalid_value()
{
$this->expectException(InvalidValueException::class);
$this->expectExceptionMessage('The given value [foobar] is not available in this enum Spatie\Enum\Tests\Enums\BoolEnum');
BoolEnum::isFalse('foobar');
}
/** @test */
public function can_not_check_for_static_equality_with_invalid_index()
{
$this->expectException(InvalidIndexException::class);
$this->expectExceptionMessage('The given index [2] is not available in this enum Spatie\Enum\Tests\Enums\BoolEnum');
BoolEnum::isFalse(2);
}

No idea why - But I agree that an equality check method shouldn't throw an exception in false case - only in total exceptional case - which is the case after your fix!
So I will proceed to release it and have adjusted the two tests.

@Gummibeer
Copy link
Collaborator

@dionysiosarvanitis dionysiosarvanitis deleted the fix/61 branch July 17, 2020 20:57
@Gummibeer Gummibeer mentioned this pull request Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The given value is not available in this enum
2 participants