summaryrefslogtreecommitdiffstats
path: root/tests/CSRFTest.php
diff options
context:
space:
mode:
authorrdalverny <rdalverny@gmail.com>2022-01-24 11:10:02 +0100
committerrdalverny <rdalverny@gmail.com>2022-01-24 11:10:02 +0100
commitd972d625d68c8f86137182ff9a8fb6be5ef271dd (patch)
treef5533ce25181280a1e30ad0d64c26d295475411f /tests/CSRFTest.php
parent94218b1009199a947c58cf88dbb358953249f10c (diff)
downloadplanet-user/rda/rda-10-dev.tar
planet-user/rda/rda-10-dev.tar.gz
planet-user/rda/rda-10-dev.tar.bz2
planet-user/rda/rda-10-dev.tar.xz
planet-user/rda/rda-10-dev.zip
Factor some tests with dataProvideruser/rda/rda-10-dev
Diffstat (limited to 'tests/CSRFTest.php')
-rw-r--r--tests/CSRFTest.php24
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);
}
}