Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding test parameters to 'getQRCodeGoogleUrl' #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/GoogleAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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()
{
Expand Down