Code Duplication    Length = 10-14 lines in 5 locations

projects/packages/autoloader/tests/php/tests/integration/test-autoloader-scenarios.php 5 locations

@@ 61-70 (lines=10) @@
58
	/**
59
	 * Tests that the autoloader works as expected.
60
	 */
61
	public function test_autoloader_init() {
62
		$this->activate_plugin( 'plugin_current' );
63
64
		$this->load_autoloader( 'plugin_current' );
65
66
		$this->assertAutoloaderVersion( '2.6.0.0' );
67
68
		$this->shutdown_autoloader( true );
69
		$this->assertAutoloaderCache( array( 'plugin_current' ) );
70
	}
71
72
	/**
73
	 * Tests that the autoloader does not initialize twice.
@@ 178-189 (lines=12) @@
175
	/**
176
	 * Tests that the autoloader updates the cache.
177
	 */
178
	public function test_autoloader_updates_cache() {
179
		$this->activate_plugin( 'plugin_current' );
180
181
		// Write an empty cache so we can make sure it was updated.
182
		$this->cache_plugins( array() );
183
184
		$this->load_autoloader( 'plugin_current' );
185
		$this->shutdown_autoloader( true );
186
187
		$this->assertAutoloaderVersion( '2.6.0.0' );
188
		$this->assertAutoloaderCache( array( 'plugin_current' ) );
189
	}
190
191
	/**
192
	 * Tests that the autoloader does not update the cache if it has not changed.
@@ 215-228 (lines=14) @@
212
	/**
213
	 * Tests that the autoloader empties the cache if shutdown happens before plugins_loaded.
214
	 */
215
	public function test_autoloader_empties_cache_on_early_shutdown() {
216
		$this->activate_plugin( 'plugin_current' );
217
218
		// Write a cache that we can use when loading the autoloader.
219
		$this->cache_plugins( array( 'plugin_current' ) );
220
221
		$this->load_autoloader( 'plugin_current' );
222
223
		// Make sure to shutdown prematurely so that the cache will be erased instead of saved.
224
		$this->shutdown_autoloader( false );
225
226
		$this->assertAutoloaderVersion( '2.6.0.0' );
227
		$this->assertAutoloaderCache( array() );
228
	}
229
230
	/**
231
	 * Tests that the autoloader is able to resolve symbolic links to avoid duplicate plugin entries.
@@ 233-243 (lines=11) @@
230
	/**
231
	 * Tests that the autoloader is able to resolve symbolic links to avoid duplicate plugin entries.
232
	 */
233
	public function test_autoloader_resolves_symlinks() {
234
		$this->activate_plugin( 'plugin_current', 'plugin_symlink' );
235
236
		$this->load_autoloader( 'plugin_symlink' );
237
238
		$this->assertAutoloaderVersion( '2.6.0.0' );
239
240
		$this->shutdown_autoloader( true );
241
		// Since there's no cache we should expect the resolved path.
242
		$this->assertAutoloaderCache( array( 'plugin_current' ) );
243
	}
244
245
	/**
246
	 * Tests that the autoloader can handle cases where the cached path is a symlink.
@@ 248-260 (lines=13) @@
245
	/**
246
	 * Tests that the autoloader can handle cases where the cached path is a symlink.
247
	 */
248
	public function test_autoloader_resolves_cached_symlinks() {
249
		$this->cache_plugins( array( 'plugin_symlink' ) );
250
251
		$this->activate_plugin( 'plugin_current', 'plugin_symlink' );
252
253
		$this->load_autoloader( 'plugin_symlink' );
254
255
		$this->assertAutoloaderVersion( '2.6.0.0' );
256
257
		$this->shutdown_autoloader( true );
258
		// The cache shouldn't be updated since internally real paths are always used.
259
		$this->assertAutoloaderCache( array( 'plugin_symlink' ) );
260
	}
261
262
	/**
263
	 * Generates a new autoloader from the current source files for the "plugin_current" plugin.