

Nextrek
@ 461
Nextrek / Android / SmartCharging / endPoints / nightly / fb_SDK / tests / GraphObjectTest.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 |
<?php use Facebook\FacebookRequest; use Facebook\GraphObject; use Facebook\FacebookResponse; use Facebook\GraphUser; class GraphObjectTest extends PHPUnit_Framework_TestCase { public function testFriends() { $response = ( new FacebookRequest( FacebookTestHelper::$testSession, 'GET', '/me/friends' ))->execute()->getGraphObjectList(); $this->assertTrue(is_array($response)); } public function testArrayProperties() { $backingData = array( 'id' => 42, 'friends' => array( 'data' => array( array( 'id' => 1, 'name' => 'David' ), array( 'id' => 2, 'name' => 'Fosco' ) ), 'paging' => array( 'next' => 'nexturl' ) ) ); $obj = new GraphObject($backingData); $friends = $obj->getPropertyAsArray('friends'); $this->assertEquals(2, count($friends)); $this->assertTrue($friends[0] instanceof GraphObject); $this->assertTrue($friends[1] instanceof GraphObject); $this->assertEquals('David', $friends[0]->getProperty('name')); $this->assertEquals('Fosco', $friends[1]->getProperty('name')); $backingData = array( 'id' => 42, 'friends' => array( array( 'id' => 1, 'name' => 'Ilya' ), array( 'id' => 2, 'name' => 'Kevin' ) ) ); $obj = new GraphObject($backingData); $friends = $obj->getPropertyAsArray('friends'); $this->assertEquals(2, count($friends)); $this->assertTrue($friends[0] instanceof GraphObject); $this->assertTrue($friends[1] instanceof GraphObject); $this->assertEquals('Ilya', $friends[0]->getProperty('name')); $this->assertEquals('Kevin', $friends[1]->getProperty('name')); } public function testAsList() { $backingData = array( 'data' => array( array( 'id' => 1, 'name' => 'David' ), array( 'id' => 2, 'name' => 'Fosco' ) ) ); $enc = json_encode($backingData); $response = new FacebookResponse(null, json_decode($enc), $enc); $list = $response->getGraphObjectList(GraphUser::className()); $this->assertEquals(2, count($list)); $this->assertTrue($list[0] instanceof GraphObject); $this->assertTrue($list[1] instanceof GraphObject); $this->assertEquals('David', $list[0]->getName()); $this->assertEquals('Fosco', $list[1]->getName()); } } |
Commits for Nextrek/Android/SmartCharging/endPoints/nightly/fb_SDK/tests/GraphObjectTest.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. |