diff options
author | rdalverny <rdalverny@gmail.com> | 2022-01-24 11:10:02 +0100 |
---|---|---|
committer | rdalverny <rdalverny@gmail.com> | 2022-01-24 11:10:02 +0100 |
commit | d972d625d68c8f86137182ff9a8fb6be5ef271dd (patch) | |
tree | f5533ce25181280a1e30ad0d64c26d295475411f /tests/CSRFTest.php | |
parent | 94218b1009199a947c58cf88dbb358953249f10c (diff) | |
download | planet-d972d625d68c8f86137182ff9a8fb6be5ef271dd.tar planet-d972d625d68c8f86137182ff9a8fb6be5ef271dd.tar.gz planet-d972d625d68c8f86137182ff9a8fb6be5ef271dd.tar.bz2 planet-d972d625d68c8f86137182ff9a8fb6be5ef271dd.tar.xz planet-d972d625d68c8f86137182ff9a8fb6be5ef271dd.zip |
Factor some tests with dataProvideruser/rda/rda-10-dev
Diffstat (limited to 'tests/CSRFTest.php')
-rw-r--r-- | tests/CSRFTest.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/CSRFTest.php b/tests/CSRFTest.php index 39fda58..ccb63e9 100644 --- a/tests/CSRFTest.php +++ b/tests/CSRFTest.php @@ -23,14 +23,24 @@ class CSRFTest extends TestCase CSRF::generate(null); } - public function testVerify() + public function verifyProvider() { $token = CSRF::generate("some-action"); - $this->assertEquals(CSRF::verify($token, "some-action"), true); - $this->assertEquals(CSRF::verify($token, "other-action"), false); - $this->assertEquals(CSRF::verify("anything-else", "some-action"), false); - $this->assertEquals(CSRF::verify(1, "string"), false); - $this->assertEquals(CSRF::verify("string", 2), false); - $this->assertEquals(CSRF::verify(null, null), false); + return [ + 'valid pair' => [$token, 'some-action', true], + 'different action' => [$token, 'other-action', false], + 'wrong token value' => ['anything-else', 'some-action', false], + 'wrong token type' => [1, 'string', false], + 'wrong action type' => ['string', 2, false], + 'null token/action' => [null, null, false] + ]; + } + + /** + * @dataProvider verifyProvider + */ + public function testVerify($token, $action, $expected) + { + $this->assertEquals(CSRF::verify($token, $action), $expected); } } |