| 1 |  |  | <?php namespace League\OAuth2\Client\Test\Provider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Flipbox\OAuth2\Client\Provider\GuardianResourceOwner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | class GuardianResourceOwnerTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     public function testEmailIsNullWithoutResponse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |         $user = new GuardianResourceOwner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |         $value = $user->getEmail(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |         $this->assertNull($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     public function testIdIsNullWithoutResponse() | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |         $user = new GuardianResourceOwner; | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |         $value = $user->getId(); | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |         $this->assertNull($value); | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     public function testDomainIsNullWithoutResponse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $user = new GuardianResourceOwner; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $value = $user->getDomain(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertNull($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     public function testResponsePropertyMapping() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $response = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             'token' => uniqid() . uniqid(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'email' => uniqid() . '@' . uniqid() . '.com', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'domain' => uniqid() . '.com', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'scopes' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                 'contacts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |                 'content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 'oauth' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             'expires' => rand(6, 10), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             'id' => rand(6, 10), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             'token_type' => 'access' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $user = new GuardianResourceOwner($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $this->assertEquals($response['domain'], $user->getDomain()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $this->assertEquals($response['email'], $user->getEmail()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->assertEquals($response['id'], $user->getId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->assertEquals($response['scopes'], $user->getScopes()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->assertEquals($response['expires'], $user->getExpires()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 58 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |  |