| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | class LDAPFakeGateway extends LDAPGateway implements TestOnly | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |         // do nothing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     private static $data = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |         'groups' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |             'CN=Users,DC=playpen,DC=local' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |                 array('dn' => 'CN=Group1,CN=Users,DC=playpen,DC=local'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |                 array('dn' => 'CN=Group2,CN=Users,DC=playpen,DC=local'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |                 array('dn' => 'CN=Group3,CN=Users,DC=playpen,DC=local'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |                 array('dn' => 'CN=Group4,CN=Users,DC=playpen,DC=local'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |                 array('dn' => 'CN=Group5,CN=Users,DC=playpen,DC=local') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |             'CN=Others,DC=playpen,DC=local' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |                 array('dn' => 'CN=Group6,CN=Others,DC=playpen,DC=local'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |                 array('dn' => 'CN=Group7,CN=Others,DC=playpen,DC=local'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |                 array('dn' => 'CN=Group8,CN=Others,DC=playpen,DC=local') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         'users' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             '123' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |                 'distinguishedname' => 'CN=Joe,DC=playpen,DC=local', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |                 'objectguid' => '123', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |                 'cn' => 'jbloggs', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |                 'useraccountcontrol' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                 'givenname' => 'Joe', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |                 'sn' => 'Bloggs', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |                 'mail' => '[email protected]' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     public function authenticate($username, $password) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |     public function getNodes($baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = array(), $sort = '') | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     public function getGroups($baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = array(), $sort = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         if (isset($baseDn)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             return !empty(self::$data['groups'][$baseDn]) ? self::$data['groups'][$baseDn] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function getNestedGroups($dn, $baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function getGroupByGUID($guid, $baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     public function getUsers($baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = array(), $sort = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function getUserByGUID($guid, $baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         return array(self::$data['users'][$guid]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     public function update($dn, array $attributes) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public function delete($dn, $recursively = false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     public function move($fromDn, $toDn, $recursively = false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function add($dn, array $attributes) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 81 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 82 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.