diff options
author | Chris Cornutt <chris.cornutt@hp.com> | 2015-01-15 11:46:20 -0600 |
---|---|---|
committer | Chris Cornutt <chris.cornutt@hp.com> | 2015-01-15 11:46:20 -0600 |
commit | c80a27ef22476f069bded1e3e29af9315b88e8f4 (patch) | |
tree | bdc23bd840dd07bef879e7fcbf2368df013b3cf5 | |
parent | edb777666f989684c7d32fab34e3f9b558d4b696 (diff) | |
download | gatekeeper-c80a27ef22476f069bded1e3e29af9315b88e8f4.zip gatekeeper-c80a27ef22476f069bded1e3e29af9315b88e8f4.tar.gz gatekeeper-c80a27ef22476f069bded1e3e29af9315b88e8f4.tar.bz2 |
adding Gatekeeper test
-rw-r--r-- | tests/Psecio/Gatekeeper/GatekeeperTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/Psecio/Gatekeeper/GatekeeperTest.php b/tests/Psecio/Gatekeeper/GatekeeperTest.php new file mode 100644 index 0000000..92ea54f --- /dev/null +++ b/tests/Psecio/Gatekeeper/GatekeeperTest.php @@ -0,0 +1,56 @@ +<?php + +namespace Psecio\Gatekeeper; + +class GatekeeperTest extends \Psecio\Gatekeeper\Base +{ + public function setUp() + { + // $config = array('test' => 1); + // Gatekeeper::init(null, $config); + } + public function tearDown() + { + + } + + /** + * Test the enable/disable of throttling + */ + public function testEnableDisableThrottle() + { + Gatekeeper::disableThrottle(); + $this->assertFalse(Gatekeeper::throttleStatus()); + + Gatekeeper::enableThrottle(); + $this->assertTrue(Gatekeeper::throttleStatus()); + } + + /** + * Test getting the user's throttle information (model instance) + */ + public function testGetUserThrottle() + { + $userId = 42; + + // This is our model that will be returned + $ds = $this->buildMock(null); + $throttle1 = new ThrottleModel($ds, array('userId' => $userId)); + + $ds = $this->buildMock($throttle1, 'find'); + $throttle = new ThrottleModel($ds); + + $gk = $this->getMockBuilder('\Psecio\Gatekeeper\Gatekeeper') + ->setMethods(array('findThrottleByUserId')) + ->getMock(); + + $config = array('name' => 'test'); + $gk::init(null, $config, $ds); + + $gk->method('findThrottleByUserId') + ->willReturn($throttle); + + $result = $gk::getUserThrottle($userId); + $this->assertEquals(42, $result->userId); + } +}
\ No newline at end of file |