| @@ 54-77 (lines=24) @@ | ||
| 51 | /** |
|
| 52 | * Tests that the autoloader does not reset when all of the plugins are known during initialization. |
|
| 53 | */ |
|
| 54 | public function test_autoloader_does_not_reset_when_all_plugins_are_known() { |
|
| 55 | // Activate the current autoloader so that the mu-plugin autoloader can see it. |
|
| 56 | $this->activate_autoloader( Test_Plugin_Factory::CURRENT ); |
|
| 57 | ||
| 58 | // Load and shutdown the autoloaders safely. |
|
| 59 | $this->execute_autoloader_chain( |
|
| 60 | array( |
|
| 61 | self::CURRENT_MU, |
|
| 62 | Test_Plugin_Factory::CURRENT, |
|
| 63 | ), |
|
| 64 | true |
|
| 65 | ); |
|
| 66 | ||
| 67 | // Make sure the autoloader worked as expected. |
|
| 68 | $this->assertAutoloaderVersion( Test_Plugin_Factory::CURRENT ); |
|
| 69 | $this->assertAutoloaderResetCount( 0 ); |
|
| 70 | $this->assertAutoloaderFoundUnknown( self::CURRENT_MU ); |
|
| 71 | $this->assertAutoloaderCacheEquals( array( self::CURRENT_MU, Test_Plugin_Factory::CURRENT ) ); |
|
| 72 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\SharedTestClass::class ); |
|
| 73 | ||
| 74 | $this->markTestIncomplete( 'The autoloader does not currently support PSR-4 loading from multiple directories.' ); |
|
| 75 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Current\UniqueTestClass::class ); |
|
| 76 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Currentmu\UniqueTestClass::class ); |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * Tests that the autoloader resets when it encounters unknown plugins. |
|
| @@ 82-104 (lines=23) @@ | ||
| 79 | /** |
|
| 80 | * Tests that the autoloader resets when it encounters unknown plugins. |
|
| 81 | */ |
|
| 82 | public function test_autoloader_resets_when_plugins_are_unknown() { |
|
| 83 | // Do not activate any plugins so that all are considered unknown. |
|
| 84 | ||
| 85 | // Load and shutdown the autoloaders safely. |
|
| 86 | $this->execute_autoloader_chain( |
|
| 87 | array( |
|
| 88 | self::CURRENT_MU, |
|
| 89 | Test_Plugin_Factory::CURRENT, |
|
| 90 | ), |
|
| 91 | true |
|
| 92 | ); |
|
| 93 | ||
| 94 | // Make sure the autoloader worked as expected. |
|
| 95 | $this->assertAutoloaderVersion( Test_Plugin_Factory::CURRENT ); |
|
| 96 | $this->assertAutoloaderResetCount( 1 ); |
|
| 97 | $this->assertAutoloaderFoundUnknown( self::CURRENT_MU ); |
|
| 98 | $this->assertAutoloaderCacheEquals( array( self::CURRENT_MU, Test_Plugin_Factory::CURRENT ) ); |
|
| 99 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\SharedTestClass::class ); |
|
| 100 | ||
| 101 | $this->markTestIncomplete( 'The autoloader does not currently support PSR-4 loading from multiple directories.' ); |
|
| 102 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Current\UniqueTestClass::class ); |
|
| 103 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Currentmu\UniqueTestClass::class ); |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Tests that the autoloader resolves symlinks to plugins so that those environments can be handled correctly. |
|
| @@ 64-87 (lines=24) @@ | ||
| 61 | /** |
|
| 62 | * Tests that the autoloader does not reset when it encounters unknown plugins that are in the cache already. |
|
| 63 | */ |
|
| 64 | public function test_autoloader_does_not_reset_when_unknown_plugins_are_cached() { |
|
| 65 | // Cache the plugins so that they will not be unknown. |
|
| 66 | $this->cache_plugin( array( self::CURRENT_MU, Test_Plugin_Factory::CURRENT ) ); |
|
| 67 | ||
| 68 | // Load and shutdown the autoloaders safely. |
|
| 69 | $this->execute_autoloader_chain( |
|
| 70 | array( |
|
| 71 | self::CURRENT_MU, |
|
| 72 | Test_Plugin_Factory::CURRENT, |
|
| 73 | ), |
|
| 74 | true |
|
| 75 | ); |
|
| 76 | ||
| 77 | // Make sure the autoloader worked as expected. |
|
| 78 | $this->assertAutoloaderVersion( Test_Plugin_Factory::CURRENT ); |
|
| 79 | $this->assertAutoloaderResetCount( 0 ); |
|
| 80 | $this->assertAutoloaderFoundUnknown( self::CURRENT_MU ); |
|
| 81 | $this->assertAutoloaderCacheEquals( array( self::CURRENT_MU, Test_Plugin_Factory::CURRENT ) ); |
|
| 82 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\SharedTestClass::class ); |
|
| 83 | ||
| 84 | $this->markTestIncomplete( 'The autoloader does not currently support PSR-4 loading from multiple directories.' ); |
|
| 85 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Current\UniqueTestClass::class ); |
|
| 86 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Currentmu\UniqueTestClass::class ); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * Tests that the autoloader is able to add new plugins to the cache. |
|
| @@ 92-115 (lines=24) @@ | ||
| 89 | /** |
|
| 90 | * Tests that the autoloader is able to add new plugins to the cache. |
|
| 91 | */ |
|
| 92 | public function test_autoloader_adds_new_plugins_to_cache() { |
|
| 93 | // Cache only one of the plugins so that it won't be unknown. |
|
| 94 | $this->cache_plugin( array( Test_Plugin_Factory::CURRENT ) ); |
|
| 95 | ||
| 96 | // Load and shutdown the autoloaders safely. |
|
| 97 | $this->execute_autoloader_chain( |
|
| 98 | array( |
|
| 99 | self::CURRENT_MU, |
|
| 100 | Test_Plugin_Factory::CURRENT, |
|
| 101 | ), |
|
| 102 | true |
|
| 103 | ); |
|
| 104 | ||
| 105 | // Make sure the autoloader worked as expected. |
|
| 106 | $this->assertAutoloaderVersion( Test_Plugin_Factory::CURRENT ); |
|
| 107 | $this->assertAutoloaderResetCount( 0 ); |
|
| 108 | $this->assertAutoloaderFoundUnknown( self::CURRENT_MU ); |
|
| 109 | $this->assertAutoloaderCacheEquals( array( self::CURRENT_MU, Test_Plugin_Factory::CURRENT ) ); |
|
| 110 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\SharedTestClass::class ); |
|
| 111 | ||
| 112 | $this->markTestIncomplete( 'The autoloader does not currently support PSR-4 loading from multiple directories.' ); |
|
| 113 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Current\UniqueTestClass::class ); |
|
| 114 | $this->assertAutoloaderProvidesClass( \Automattic\Jetpack\AutoloaderTesting\Currentmu\UniqueTestClass::class ); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Tests that the autoloader resolves symlinks to plugins pulled from cache so that those environments can be handled correctly. |
|