

Nextrek
@ 461
Nextrek / Android / SmartCharging / endPoints / nightly / fb_SDK / tests / FacebookSessionTest.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
<?php use Mockery as m; use Facebook\FacebookSession; use Facebook\GraphSessionInfo; class FacebookSessionTest extends PHPUnit_Framework_TestCase { public function tearDown() { m::close(); } public function testSessionToken() { $session = new FacebookSession(FacebookTestHelper::getAppToken()); $this->assertEquals( FacebookTestHelper::getAppToken(), $session->getToken() ); } public function testGetSessionInfo() { $response = FacebookTestHelper::$testSession->getSessionInfo(); $this->assertTrue($response instanceof GraphSessionInfo); $this->assertNotNull($response->getAppId()); $this->assertTrue($response->isValid()); $scopes = $response->getPropertyAsArray('scopes'); $this->assertTrue(is_array($scopes)); $this->assertEquals(4, count($scopes)); } public function testExtendAccessToken() { $response = FacebookTestHelper::$testSession->getLongLivedSession(); $this->assertTrue($response instanceof FacebookSession); $info = $response->getSessionInfo(); $nextWeek = time() + (60 * 60 * 24 * 7); $this->assertTrue( $info->getProperty('expires_at') > $nextWeek ); } public function testSessionFromSignedRequest() { $signedRequest = m::mock('Facebook\Entities\SignedRequest'); $signedRequest ->shouldReceive('get') ->with('code') ->once() ->andReturn(null); $signedRequest ->shouldReceive('get') ->with('oauth_token') ->once() ->andReturn('foo_token'); $signedRequest ->shouldReceive('get') ->with('expires', 0) ->once() ->andReturn(time() + (60 * 60 * 24)); $signedRequest ->shouldReceive('getUserId') ->once() ->andReturn('123'); $session = FacebookSession::newSessionFromSignedRequest($signedRequest); $this->assertInstanceOf('Facebook\FacebookSession', $session); $this->assertEquals('foo_token', $session->getToken()); $this->assertEquals('123', $session->getUserId()); } public function testAppSessionValidates() { $session = FacebookSession::newAppSession(); try { $session->validate(); } catch (\Facebook\FacebookSDKException $ex) { $this->fail('Exception thrown validating app session.'); } } } |
Commits for Nextrek/Android/SmartCharging/endPoints/nightly/fb_SDK/tests/FacebookSessionTest.php
Revision | Author | Commited | Message |
---|---|---|---|
461 |
![]() |
Mon 03 Aug, 2015 10:04:56 +0000 | Aggiunto supporto login Facebook, logout utente e modifiche (solo lato repo) all’utente e al locale. |