

Nextrek
@ 461
Nextrek / Android / SmartCharging / endPoints / nightly / fb_SDK / tests / FacebookRequestTest.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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
<?php use Facebook\FacebookRequest; use Facebook\FacebookSession; class FacebookRequestTest extends PHPUnit_Framework_TestCase { public function testGetsTheLoggedInUsersProfile() { $response = ( new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/me' ))->execute()->getGraphObject(); $this->assertNotNull($response->getProperty('id')); $this->assertNotNull($response->getProperty('name')); } public function testCanPostAndDelete() { // Create a test user $params = array( 'name' => 'Foo User', ); $response = ( new FacebookRequest( new FacebookSession(FacebookTestHelper::getAppToken()), 'POST', '/' . FacebookTestCredentials::$appId . '/accounts/test-users', $params ))->execute()->getGraphObject(); $user_id = $response->getProperty('id'); $this->assertNotNull($user_id); // Delete test user $response = ( new FacebookRequest( new FacebookSession(FacebookTestHelper::getAppToken()), 'DELETE', '/' . $user_id ))->execute()->getGraphObject()->asArray(); $this->assertEquals(['success' => true], $response); } public function testETagHit() { $response = ( new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/104048449631599' ))->execute(); $response = ( new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/104048449631599', null, null, $response->getETag() ))->execute(); $this->assertTrue($response->isETagHit()); $this->assertNull($response->getETag()); } public function testETagMiss() { $response = ( new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/104048449631599', null, null, 'someRandomValue' ))->execute(); $this->assertFalse($response->isETagHit()); $this->assertNotNull($response->getETag()); } public function testGracefullyHandlesUrlAppending() { $params = array(); $url = 'https://www.foo.com/'; $processed_url = FacebookRequest::appendParamsToUrl($url, $params); $this->assertEquals('https://www.foo.com/', $processed_url); $params = array( 'access_token' => 'foo', ); $url = 'https://www.foo.com/'; $processed_url = FacebookRequest::appendParamsToUrl($url, $params); $this->assertEquals('https://www.foo.com/?access_token=foo', $processed_url); $params = array( 'access_token' => 'foo', 'bar' => 'baz', ); $url = 'https://www.foo.com/?foo=bar'; $processed_url = FacebookRequest::appendParamsToUrl($url, $params); $this->assertEquals('https://www.foo.com/?access_token=foo&bar=baz&foo=bar', $processed_url); $params = array( 'access_token' => 'foo', ); $url = 'https://www.foo.com/?foo=bar&access_token=bar'; $processed_url = FacebookRequest::appendParamsToUrl($url, $params); $this->assertEquals('https://www.foo.com/?access_token=bar&foo=bar', $processed_url); } public function testAppSecretProof() { $enableAppSecretProof = FacebookSession::useAppSecretProof(); FacebookSession::enableAppSecretProof(true); $request = new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/me' ); $this->assertTrue(isset($request->getParameters()['appsecret_proof'])); FacebookSession::enableAppSecretProof(false); $request = new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/me' ); $this->assertFalse(isset($request->getParameters()['appsecret_proof'])); FacebookSession::enableAppSecretProof($enableAppSecretProof); } } |
Commits for Nextrek/Android/SmartCharging/endPoints/nightly/fb_SDK/tests/FacebookRequestTest.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. |