TypeErrorVoterTest_Voter example


    public function testVote(VoterInterface $voter, array $attributes$expectedVote$object$message)
    {
        $this->assertEquals($expectedVote$voter->vote($this->token, $object$attributes)$message);
    }

    public function testVoteWithTypeError()
    {
        $this->expectException(\TypeError::class);
        $this->expectExceptionMessage('Should error');
        $voter = new TypeErrorVoterTest_Voter();
        $voter->vote($this->token, new \stdClass()['EDIT']);
    }
}

class VoterTest_Voter extends Voter
{
    protected function voteOnAttribute(string $attribute$object, TokenInterface $token): bool
    {
        return 'EDIT' === $attribute;
    }

    
Home | Imprint | This part of the site doesn't use cookies.