| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | class CodeReviewGeneralTest extends PHPUnit_Framework_TestCase { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 	public function setUp() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | 		$path = dirname(__FILE__) . '/test_files/fake_elgg/'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 		require_once($path . 'engine/start.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 		code_review::initConfig(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 			'path' => $path, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 			'engine_path' => $path . 'engine/', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 			'pluginspath' => $path . 'mod/', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | 	public function testGetDeprecatedFunctionsList() { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  | 		$functions = code_review::getDeprecatedFunctionsList('1.2'); | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | 		$this->assertArrayHasKey('dummy_deprecated_function1', $functions); | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 		$deprecatedFunction = $functions['dummy_deprecated_function1']; | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 		$this->assertInstanceOf('CodeReview_Issues_Deprecated', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | 		$this->assertInstanceOf('ArrayAccess', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 		$this->assertFalse(is_array($deprecatedFunction)); | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 		$this->assertArrayHasKey('name', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 		$this->assertArrayHasKey('version', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 		$this->assertArrayHasKey('file', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 		$this->assertArrayHasKey('line', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 		$this->assertArrayHasKey('deprecated', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 		$this->assertArrayHasKey('reason', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 		$this->assertArrayHasKey('fixinfoshort', $deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 		$this->assertEquals('dummy_deprecated_function1', $deprecatedFunction['name']); | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 		$this->assertEquals('1.1', $deprecatedFunction['version']); | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 		$this->assertEquals(true, $deprecatedFunction['deprecated']); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 		$this->assertEquals('deprecated', $deprecatedFunction['reason']); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 		$this->assertEquals('Remove it', $deprecatedFunction['fixinfoshort']); | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 		$this->assertEquals("Line " . $deprecatedFunction['line'] . ":\tFunction call: " | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | 			. $deprecatedFunction['name'] . " (deprecated since 1.1) Remove it", | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | 			(string)$deprecatedFunction); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 		$functions = code_review::getDeprecatedFunctionsList('1.1'); | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 		$this->assertArrayNotHasKey('dummy_deprecated_function1', $functions); | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	public function testGetPrivateFunctionsList() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		$functions = code_review::getPrivateFunctionsList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		$this->assertArrayNotHasKey('dummy_deprecated_function1', $functions); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		 * foobar_private_api | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		$this->assertArrayHasKey('foobar_private_api', $functions); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		$privateFunction = $functions['foobar_private_api']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		$this->assertInstanceOf('CodeReview_Issues_Private', $privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		$this->assertInstanceOf('ArrayAccess', $privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		$this->assertFalse(is_array($privateFunction)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		$this->assertArrayHasKey('name', $privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		$this->assertArrayHasKey('file', $privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		$this->assertArrayHasKey('line', $privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		$this->assertArrayHasKey('reason', $privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		$this->assertEquals('foobar_private_api', $privateFunction['name']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		$this->assertEquals('private', $privateFunction['reason']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		$this->assertEquals("Line " . $privateFunction['line'] . ":\tFunction call: " | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 			. $privateFunction['name'] . " (use of function marked private is unsafe)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 			(string)$privateFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 		 * foobar_undocumented | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		$this->assertArrayHasKey('foobar_undocumented', $functions); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		$undocumentedFunction = $functions['foobar_undocumented']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 		$this->assertInstanceOf('CodeReview_Issues_NotDocumented', $undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		$this->assertInstanceOf('ArrayAccess', $undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$this->assertFalse(is_array($undocumentedFunction)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		$this->assertArrayHasKey('name', $undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		$this->assertArrayHasKey('file', $undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		$this->assertArrayHasKey('line', $undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		$this->assertArrayHasKey('reason', $undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		$this->assertEquals('foobar_undocumented', $undocumentedFunction['name']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		$this->assertEquals('not_documented', $undocumentedFunction['reason']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		$this->assertEquals("Line " . $undocumentedFunction['line'] . ":\tFunction call: " | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 			. $undocumentedFunction['name'] . " (use of undocumented core function is unsafe)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 			(string)$undocumentedFunction); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 96 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 97 |  |  |  | 
            
                        
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.