1 | <?php // phpcs:ignore WordPress.Files.FileName |
||
13 | class WP_Test_Autoloader_Handler extends TestCase { |
||
14 | |||
15 | /** |
||
16 | * Tests that the latest autoloader can be recognized as the current. |
||
17 | * |
||
18 | * @runInSeparateProcess |
||
19 | * @preserveGlobalState disabled |
||
20 | */ |
||
21 | public function test_is_latest_autoloader_does_nothing_if_this_is_it() { |
||
34 | |||
35 | /** |
||
36 | * Tests that the latest autoloader will be required if not this. |
||
37 | * |
||
38 | * @runInSeparateProcess |
||
39 | * @preserveGlobalState disabled |
||
40 | */ |
||
41 | public function test_is_latest_autoloader_requires_latest_if_this_is_not_it() { |
||
58 | |||
59 | /** |
||
60 | * Tests should_autoloader_reset() with an already active plugin. |
||
61 | */ |
||
62 | public function test_should_autoloader_reset_known_plugin() { |
||
63 | global $jetpack_autoloader_activating_plugins_paths; |
||
64 | |||
65 | $autoloader_handler = new Autoloader_Handler( |
||
66 | TEST_DATA_PATH . '/plugins/plugin_current', |
||
67 | array( TEST_DATA_PATH . '/plugins/plugin_current' ), |
||
68 | new Autoloader_Locator( new Version_Selector() ), |
||
69 | new Version_Selector() |
||
70 | ); |
||
71 | |||
72 | $this->assertFalse( $autoloader_handler->should_autoloader_reset() ); |
||
73 | $this->assertEmpty( $jetpack_autoloader_activating_plugins_paths ); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Tests should_autoloader_reset() with an activating, unknown plugin. |
||
78 | */ |
||
79 | public function test_should_autoloader_reset_unknown_plugin() { |
||
80 | global $jetpack_autoloader_activating_plugins_paths; |
||
81 | |||
82 | $autoloader_handler = new Autoloader_Handler( |
||
83 | TEST_DATA_PATH . '/plugins/plugin_current', |
||
84 | array(), |
||
85 | new Autoloader_Locator( new Version_Selector() ), |
||
86 | new Version_Selector() |
||
87 | ); |
||
88 | |||
89 | $this->assertTrue( $autoloader_handler->should_autoloader_reset() ); |
||
90 | $this->assertCount( 1, $jetpack_autoloader_activating_plugins_paths ); |
||
91 | $this->assertEquals( TEST_DATA_PATH . '/plugins/plugin_current', $jetpack_autoloader_activating_plugins_paths[0] ); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Tests that the handler is able to build a loader. |
||
96 | */ |
||
97 | public function test_builds_autoloader() { |
||
112 | } |
||
113 |