| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use WP_Mock\Tools\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Auutomattic\Jetpack\Options\Manager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | class ManagerTest extends TestCase { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 	public function setUp() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 		\WP_Mock::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 		$this->manager = new Manager_Test(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	function test_get_private_option_returns_value() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 			'args' => array( 'jetpack_private_options' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 			'return' => array( 'private_name' => true ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		$value = $this->manager->get_option( 'private_name' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		// Did Jetpack_Options::get_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		$this->assertTrue( $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 26 |  | View Code Duplication | 	function test_get_network_option_returns_value() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		\WP_Mock::userFunction( 'get_site_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 			'args' => array( 'jetpack_network_name', false ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		\WP_Mock::userFunction( 'is_multisite', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 			'args' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		$value = $this->manager->get_option( 'network_name' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		// Did Jetpack_Options::get_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		$this->assertTrue( $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 44 |  | View Code Duplication | 	function test_get_non_compact_option_returns_value() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			'args' => array( 'jetpack_uncompact_option_name', false ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		\WP_Mock::userFunction( 'is_multisite', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 			'args' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 			'return' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		$value = $this->manager->get_option( 'uncompact_option_name' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		// Did Jetpack_Options::get_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		$this->assertTrue( $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 62 |  | View Code Duplication | 	function test_delete_non_compact_option_returns_true_when_successfully_deleted() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			'args' => array( 'jetpack_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 			'return' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 			'args' => array( 'jetpack_private_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 			'return' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		\WP_Mock::userFunction( 'delete_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 			'args' => array( 'jetpack_uncompact_option_name' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		\WP_Mock::userFunction( 'is_multisite', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			'args' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			'return' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		$deleted = $this->manager->delete_option( 'uncompact_option_name' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		// Did Jetpack_Options::delete_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		$this->assertTrue( $deleted ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 90 |  | View Code Duplication | 	function test_delete_network_option_returns_true_when_successfully_deleted() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 			'args' => array( 'jetpack_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 			'return' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 			'args' => array( 'jetpack_private_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			'return' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		\WP_Mock::userFunction( 'is_multisite', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 			'args' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		\WP_Mock::userFunction( 'delete_site_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			'args' => array( 'jetpack_network_name' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		$deleted = $this->manager->delete_option( 'network_name' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		// Did Jetpack_Options::delete_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		$this->assertTrue( $deleted ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	function test_delete_private_option_returns_true_when_successfully_deleted() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			'args' => array( 'jetpack_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 			'return' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		\WP_Mock::userFunction( 'get_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 			'args' => array( 'jetpack_private_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 			'return' => array( 'private_name' => false ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		\WP_Mock::userFunction( 'update_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			'args' => array( 'jetpack_private_options', array() ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 		$deleted = $this->manager->delete_option( 'private_name' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 		// Did Jetpack_Options::delete_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 		$this->assertTrue( $deleted ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 141 |  | View Code Duplication | 	function test_update_non_compact_option_returns_true_when_successfully_updated() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		\WP_Mock::expectAction( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 			'pre_update_jetpack_option_uncompact_option_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 			'uncompact_option_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 			true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		\WP_Mock::userFunction( 'update_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 			'args' => array( 'jetpack_uncompact_option_name', true, NULL ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		\WP_Mock::userFunction( 'is_multisite', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 			'args' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 			'return' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		$updated = $this->manager->update_option( 'uncompact_option_name', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		// Did Jetpack_Options::delete_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 		$this->assertTrue( $updated ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 165 |  | View Code Duplication | 	function test_update_network_option_returns_true_when_successfully_updated() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		\WP_Mock::expectAction( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 			'pre_update_jetpack_option_network_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 			'network_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 			true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		\WP_Mock::userFunction( 'update_site_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 			'args' => array( 'jetpack_network_name', true ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		\WP_Mock::userFunction( 'is_multisite', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 			'args' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 		$updated = $this->manager->update_option( 'network_name', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		// Did Jetpack_Options::update_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		$this->assertTrue( $updated ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 	function test_update_private_option_returns_true_when_successfully_updated() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 		\WP_Mock::expectAction( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			'pre_update_jetpack_option_private_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 			'private_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 			true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 		\WP_Mock::userFunction( 'update_option', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 			'times' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 			'args' => array( 'jetpack_private_options', array( 'private_name' => true ) ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 			'return' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 		$updated = $this->manager->update_option( 'private_name', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 		// Did Jetpack_Options::update_option() properly return true? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 		$this->assertTrue( $updated ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	public function tearDown() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		\WP_Mock::tearDown(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | class Manager_Test extends Manager { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 	 * Returns an array of option names for a given type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 	 * @param string $type The type of option to return. Defaults to 'compact'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 	 * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 221 |  |  | 	 */ | 
            
                                                        
            
                                    
            
            
                | 222 |  |  | 	public function get_option_names( $type = 'compact' ) { | 
            
                                                        
            
                                    
            
            
                | 223 |  |  | 		switch ( $type ) { | 
            
                                                        
            
                                    
            
            
                | 224 |  |  | 		case 'non-compact' : | 
            
                                                        
            
                                    
            
            
                | 225 |  |  | 		case 'non_compact' : | 
            
                                                        
            
                                    
            
            
                | 226 |  |  | 			return array( | 
            
                                                        
            
                                    
            
            
                | 227 |  |  | 				'network_name', | 
            
                                                        
            
                                    
            
            
                | 228 |  |  | 				'uncompact_option_name', | 
            
                                                        
            
                                    
            
            
                | 229 |  |  | 			); | 
            
                                                        
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 231 |  |  | 		case 'private' : | 
            
                                                        
            
                                    
            
            
                | 232 |  |  | 			return array( | 
            
                                                        
            
                                    
            
            
                | 233 |  |  | 				'private_name' | 
            
                                                        
            
                                    
            
            
                | 234 |  |  | 			); | 
            
                                                        
            
                                    
            
            
                | 235 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 236 |  |  | 		case 'network' : | 
            
                                                        
            
                                    
            
            
                | 237 |  |  | 			return array( | 
            
                                                        
            
                                    
            
            
                | 238 |  |  | 				'network_name' // Network options must be listed a second time | 
            
                                                        
            
                                    
            
            
                | 239 |  |  | 			); | 
            
                                                        
            
                                    
            
            
                | 240 |  |  | 		} | 
            
                                                        
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 242 |  |  | 		return array( | 
            
                                                        
            
                                    
            
            
                | 243 |  |  | 			'id' | 
            
                                                        
            
                                    
            
            
                | 244 |  |  | 		); | 
            
                                                        
            
                                    
            
            
                | 245 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 246 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 247 |  |  |  | 
            
                        
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.