From 817d0316e8c3d83b879f91f1441541e485ac5bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Piechowiak?= Date: Wed, 19 Oct 2016 20:18:29 +0200 Subject: [PATCH] Adding test parameters to 'getQRCodeGoogleUrl' --- tests/GoogleAuthenticatorTest.php | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/GoogleAuthenticatorTest.php b/tests/GoogleAuthenticatorTest.php index 56fc2c1..adb6d5e 100644 --- a/tests/GoogleAuthenticatorTest.php +++ b/tests/GoogleAuthenticatorTest.php @@ -21,6 +21,19 @@ public function codeProvider() array('SECRET', '1378934578', '705013'), ); } + + public function paramsProvider() + { + return array( + array(null, null, null, '200x200', 'M'), + array(-1, -1, null, '200x200', 'M'), + array(250, 250, 'L', '250x250', 'L'), + array(250, 250, 'M', '250x250', 'M'), + array(250, 250, 'Q', '250x250', 'Q'), + array(250, 250, 'H', '250x250', 'H'), + array(250, 250, 'Z', '250x250', 'M'), + ); + } public function testItCanBeInstantiated() { @@ -75,6 +88,30 @@ public function testGetQRCodeGoogleUrlReturnsCorrectUrl() $this->assertEquals($queryStringArray['chl'], $expectedChl); } + + /** + * @dataProvider paramsProvider + */ + public function testGetQRCodeGoogleUrlReturnsCorrectUrlWithOptionalParameters($width, $height, $level, $expectedSize, $expectedLevel) + { + $secret = 'SECRET'; + $name = 'Test'; + $url = $this->googleAuthenticator->getQRCodeGoogleUrl( + $name, + $secret, + null, + array( + 'width' => $width, + 'height' => $height, + 'level' => $level + )); + $urlParts = parse_url($url); + + parse_str($urlParts['query'], $queryStringArray); + + $this->assertEquals($queryStringArray['chs'], $expectedSize); + $this->assertEquals($queryStringArray['chld'], $expectedLevel.'|0'); + } public function testVerifyCode() {