Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

fix(Parameter): allow required boolean with value false #36

Closed
wants to merge 1 commit into from

Conversation

jutein
Copy link

@jutein jutein commented Nov 20, 2020

A boolean false is considered as an "empty" value, so if this parameter is required, it will throw an exception

Fix this by checking the type and the value of the parameter

@coveralls
Copy link

coveralls commented Nov 20, 2020

Coverage Status

Coverage increased (+0.3%) to 93.113% when pulling 6866f95 on jutein:master into 020d03b on RETFU:master.

src/Parameter.php Outdated Show resolved Hide resolved
@yannickroger
Copy link
Collaborator

You can add this test in tests/units/Parameters.php it should do the trick:

    public function testAssertValueOnMandatoryFalseBoolean()
    {
        $this->newTestedInstance('name', 'boolean', true);
        $this
            ->given($this->testedInstance)
            ->variable($this->testedInstance->assertValue(false))
            ->isNull
        ;
    }

@jutein
Copy link
Author

jutein commented Nov 20, 2020

Test added

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants