| | 65 | |
| | 66 | /** |
| | 67 | * @ticket 42670 |
| | 68 | */ |
| | 69 | public function test_return_correct_basename_for_symlinked_plugins_when_wp_plugin_dir_is_a_subdir_of_a_plugin() { |
| | 70 | |
| | 71 | /** |
| | 72 | * A lookup array saved by WordPress for symlinked plugins, used only by `plugin_basename()`. |
| | 73 | * |
| | 74 | * @var array<string, string> $wp_plugin_paths An array of path:realpath where path is the path of the symlink in the WP_PLUGIN_DIR and realpath is the actual location in the filesystem that the symlink is pointing to. |
| | 75 | * @see wp_register_plugin_realpath() |
| | 76 | */ |
| | 77 | global $wp_plugin_paths; |
| | 78 | |
| | 79 | // e.g. `/Users/brianhenry/Sites/plugin-whose-realpath-contains-everything`. |
| | 80 | // aka project directory |
| | 81 | $wp_plugin_dir_grandparent_directory = dirname( WP_PLUGIN_DIR, 3 ); |
| | 82 | |
| | 83 | $wp_plugin_paths = array( |
| | 84 | WP_PLUGIN_DIR . '/plugin-whose-realpath-contains-everything' => $wp_plugin_dir_grandparent_directory, |
| | 85 | WP_PLUGIN_DIR . '/woocommerce' => $wp_plugin_dir_grandparent_directory . '/wp-content/plugins/woocommerce', |
| | 86 | ); |
| | 87 | |
| | 88 | $result = plugin_basename( $wp_plugin_dir_grandparent_directory . '/wp-content/plugins/woocommerce/woocommerce.php' ); |
| | 89 | |
| | 90 | // Actual :'plugin-whose-realpath-contains-everything/wordpress/wp-content/plugins/woocommerce/woocommerce.php'. |
| | 91 | $this->assertEquals( 'woocommerce/woocommerce.php', $result ); |
| | 92 | } |