Skip to content

Commit e2b8129

Browse files
committed
added tests of OAuthStorage::markAuthCodeAsUsed()
#193
1 parent 6f097ad commit e2b8129

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Tests/Storage/OAuthStorageTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,40 @@ public function testDoubleSetGrantExtension()
461461

462462
$this->assertEquals($grantExtension2, $grantExtensions[$uri]);
463463
}
464+
465+
public function testMarkAuthCodeAsUsedIfAuthCodeFound()
466+
{
467+
$authCode = $this->getMock('FOS\OAuthServerBundle\Model\AuthCodeInterface');
468+
469+
$this->authCodeManager->expects($this->atLeastOnce())
470+
->method('findAuthCodeByToken')
471+
->with('123_abc')
472+
->will($this->returnValue($authCode))
473+
;
474+
475+
$this->authCodeManager->expects($this->atLeastOnce())
476+
->method('deleteAuthCode')
477+
->with($authCode)
478+
->will($this->returnValue(null))
479+
;
480+
481+
$this->storage->markAuthCodeAsUsed('123_abc');
482+
}
483+
484+
public function testMarkAuthCodeAsUsedIfAuthCodeNotFound()
485+
{
486+
$this->authCodeManager->expects($this->atLeastOnce())
487+
->method('findAuthCodeByToken')
488+
->with('123_abc')
489+
->will($this->returnValue(null))
490+
;
491+
492+
$this->authCodeManager->expects($this->never())
493+
->method('deleteAuthCode')
494+
;
495+
496+
$this->storage->markAuthCodeAsUsed('123_abc');
497+
}
464498
}
465499

466500
class User implements UserInterface

0 commit comments

Comments
 (0)