@@ 109-129 (lines=21) @@ | ||
106 | /** |
|
107 | * Tests that the autoloader resolves symlinks to plugins so that those environments can be handled correctly. |
|
108 | */ |
|
109 | public function test_autoloader_resolves_symlinks() { |
|
110 | $symlink_key = 'current_symlink'; |
|
111 | ||
112 | // Install the autoloader as a symlink so that we can execute it. |
|
113 | $this->install_autoloader_symlink( Test_Plugin_Factory::CURRENT, false, $symlink_key ); |
|
114 | ||
115 | // Activate the symlink autoloader so it won't be unknown. |
|
116 | $this->activate_autoloader( $symlink_key ); |
|
117 | ||
118 | // Load and shutdown the autoloader safely. |
|
119 | $this->load_plugin_autoloader( $symlink_key ); |
|
120 | $this->trigger_shutdown( true ); |
|
121 | ||
122 | // Make sure the autoloader worked as expected. |
|
123 | $this->assertAutoloaderVersion( Test_Plugin_Factory::CURRENT ); |
|
124 | $this->assertAutoloaderResetCount( 0 ); |
|
125 | $this->assertAutoloaderNotFoundUnknown( $symlink_key ); |
|
126 | // The symlink is stored in the cache resolved to the original directory. |
|
127 | $this->assertAutoloaderCacheEquals( Test_Plugin_Factory::CURRENT ); |
|
128 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Current\UniqueTestClass::class ); |
|
129 | } |
|
130 | } |
|
131 |
@@ 120-140 (lines=21) @@ | ||
117 | /** |
|
118 | * Tests that the autoloader resolves symlinks to plugins pulled from cache so that those environments can be handled correctly. |
|
119 | */ |
|
120 | public function test_autoloader_resolves_cached_symlinks() { |
|
121 | $symlink_key = 'current_symlink'; |
|
122 | ||
123 | // Install the autoloader as a symlink so that we can execute it. |
|
124 | $this->install_autoloader_symlink( Test_Plugin_Factory::CURRENT, false, $symlink_key ); |
|
125 | ||
126 | // Store the symlink in the cache so that we can make sure it is resolved correctly. |
|
127 | $this->cache_plugin( $symlink_key ); |
|
128 | ||
129 | // Load and shutdown the autoloader safely. |
|
130 | $this->load_plugin_autoloader( $symlink_key ); |
|
131 | $this->trigger_shutdown( true ); |
|
132 | ||
133 | // Make sure the autoloader worked as expected. |
|
134 | $this->assertAutoloaderVersion( Test_Plugin_Factory::CURRENT ); |
|
135 | $this->assertAutoloaderResetCount( 0 ); |
|
136 | $this->assertAutoloaderNotFoundUnknown( $symlink_key ); |
|
137 | // The cache shouldn't get updated since nothing has technically changed. |
|
138 | $this->assertAutoloaderCacheEquals( $symlink_key ); |
|
139 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Current\UniqueTestClass::class ); |
|
140 | } |
|
141 | ||
142 | /** |
|
143 | * Tests that the autoloader does not cache plugins that are about to deactivate. |