| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace OAuth\Unit\UserData\Extractor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use OAuth\UserData\Extractor\Harvest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-07 at 22:32:44. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class HarvestTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     const RESPONSE_PROFILE = | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | '{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |   "user": { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     "id": "012345678", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     "email": "[email protected]", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     "first_name": "John", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     "last_name": "Doe", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     "avatar_url": "something_n.jpg", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     "timezone": "Pacific Time (US & Canada)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     "admin": true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | }'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @var Harvest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     protected $extractor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * Sets up the fixture, for example, opens a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * This method is called before a test is executed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->extractor = new Harvest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $service = $this->getMockBuilder('\\OAuth\\OAuth2\\Service\\Harvest') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             ->disableOriginalConstructor() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             ->setMethods(array('request')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             ->getMock(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $service->expects($this->any()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             ->method('request') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             ->with(Harvest::REQUEST_PROFILE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             ->will($this->returnValue(HarvestTest::RESPONSE_PROFILE)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |          * @var \OAuth\Common\Service\ServiceInterface $service | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->extractor->setService($service); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * Tears down the fixture, for example, closes a network connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * This method is called after a test is executed. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |     protected function tearDown() | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     public function testGetUniqueId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertEquals('012345678', $this->extractor->getUniqueId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     public function testGetUsername() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->assertEquals('[email protected]', $this->extractor->getUsername()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function testGetFirstName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $this->assertEquals('John', $this->extractor->getFirstName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     public function testGetLastName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $this->assertEquals('Doe', $this->extractor->getLastName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     public function testGetFullName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->assertEquals('John Doe', $this->extractor->getFullName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function testGetEmail() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $this->assertEquals('[email protected]', $this->extractor->getEmail()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     public function testGetImageUrl() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->assertEquals('https://api.harvestapp.com/something_n.jpg', $this->extractor->getImageUrl()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     public function testGetExtra() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $extras = $this->extractor->getExtras(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->assertArrayHasKey('timezone', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $this->assertArrayHasKey('admin', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $this->assertArrayNotHasKey('id', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $this->assertArrayNotHasKey('name', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $this->assertArrayNotHasKey('first_name', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->assertArrayNotHasKey('last_name', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->assertArrayNotHasKey('email', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $this->assertArrayNotHasKey('avatar_url', $extras); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 108 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 109 |  |  |  |