@@ 111-130 (lines=20) @@ | ||
108 | /** |
|
109 | * Tests that it can guess plugins that are stored in an option. |
|
110 | */ |
|
111 | public function test_using_option_finds_in_option() { |
|
112 | add_test_option( |
|
113 | 'test_plugin_paths', |
|
114 | array( 'dummy_current/dummy_current.php' ) |
|
115 | ); |
|
116 | ||
117 | $this->path_processor->expects( $this->exactly( 2 ) ) |
|
118 | ->method( 'find_directory_with_autoloader' ) |
|
119 | ->withConsecutive( |
|
120 | array( 0 ), |
|
121 | array( 'dummy_current/dummy_current.php' ) |
|
122 | ) |
|
123 | ->willReturnOnConsecutiveCalls( false, WP_PLUGIN_DIR . '/dummy_current' ); |
|
124 | ||
125 | $plugin_paths = $this->locator->find_using_option( 'test_plugin_paths' ); |
|
126 | ||
127 | $this->assertTrue( is_array( $plugin_paths ) ); |
|
128 | $this->assertCount( 1, $plugin_paths ); |
|
129 | $this->assertContains( WP_PLUGIN_DIR . '/dummy_current', $plugin_paths ); |
|
130 | } |
|
131 | ||
132 | /** |
|
133 | * Tests that it can find plugins that are stored in a site option. |
|
@@ 135-154 (lines=20) @@ | ||
132 | /** |
|
133 | * Tests that it can find plugins that are stored in a site option. |
|
134 | */ |
|
135 | public function test_using_option_finds_in_site_option() { |
|
136 | add_test_site_option( |
|
137 | 'test_plugin_paths', |
|
138 | array( 'dummy_current/dummy_current.php' ) |
|
139 | ); |
|
140 | ||
141 | $this->path_processor->expects( $this->exactly( 2 ) ) |
|
142 | ->method( 'find_directory_with_autoloader' ) |
|
143 | ->withConsecutive( |
|
144 | array( 0 ), |
|
145 | array( 'dummy_current/dummy_current.php' ) |
|
146 | ) |
|
147 | ->willReturnOnConsecutiveCalls( false, WP_PLUGIN_DIR . '/dummy_current' ); |
|
148 | ||
149 | $plugin_paths = $this->locator->find_using_option( 'test_plugin_paths', true ); |
|
150 | ||
151 | $this->assertTrue( is_array( $plugin_paths ) ); |
|
152 | $this->assertCount( 1, $plugin_paths ); |
|
153 | $this->assertContains( WP_PLUGIN_DIR . '/dummy_current', $plugin_paths ); |
|
154 | } |
|
155 | ||
156 | /** |
|
157 | * Tests that it can guess plugins that are stored in an option's key. |
|
@@ 159-178 (lines=20) @@ | ||
156 | /** |
|
157 | * Tests that it can guess plugins that are stored in an option's key. |
|
158 | */ |
|
159 | public function test_using_option_finds_plugin_in_key() { |
|
160 | add_test_option( |
|
161 | 'test_plugin_paths', |
|
162 | array( 'dummy_current/dummy_current.php' => 123456 ) |
|
163 | ); |
|
164 | ||
165 | $this->path_processor->expects( $this->exactly( 2 ) ) |
|
166 | ->method( 'find_directory_with_autoloader' ) |
|
167 | ->withConsecutive( |
|
168 | array( 'dummy_current/dummy_current.php' ), |
|
169 | array( 123456 ) |
|
170 | ) |
|
171 | ->willReturnOnConsecutiveCalls( WP_PLUGIN_DIR . '/dummy_current', false ); |
|
172 | ||
173 | $plugin_paths = $this->locator->find_using_option( 'test_plugin_paths' ); |
|
174 | ||
175 | $this->assertTrue( is_array( $plugin_paths ) ); |
|
176 | $this->assertCount( 1, $plugin_paths ); |
|
177 | $this->assertContains( WP_PLUGIN_DIR . '/dummy_current', $plugin_paths ); |
|
178 | } |
|
179 | ||
180 | /** |
|
181 | * Tests that it does not give errors or warnings when the option contains unexpected data. |