From 72f15c4ef18dce6fa10cde93f7d68cb272366717 Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Fri, 10 Feb 2023 22:29:02 +0530
Subject: [PATCH 01/11] Add admin tools page

---
 includes/Admin/Admin_Page.php    | 62 ++++++++++++++++++++++++++++++++
 includes/Plugin_Main.php         |  5 +++
 templates/admin-page.php         | 40 +++++++++++++++++++++
 tests/Admin/Admin_Page_Tests.php | 50 ++++++++++++++++++++++++++
 4 files changed, 157 insertions(+)
 create mode 100644 includes/Admin/Admin_Page.php
 create mode 100644 templates/admin-page.php
 create mode 100644 tests/Admin/Admin_Page_Tests.php

diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php
new file mode 100644
index 000000000..f4c7ffc4f
--- /dev/null
+++ b/includes/Admin/Admin_Page.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Class WordPress\Plugin_Check\Admin\Admin_Page
+ *
+ * @package plugin-check
+ */
+
+namespace WordPress\Plugin_Check\Admin;
+
+/**
+ * Class is handling admin tools page functionality.
+ *
+ * @since n.e.x.t
+ */
+class Admin_Page {
+
+	/**
+	 * Initialize hooks.
+	 */
+	public function add_hooks() {
+		add_action( 'admin_menu', array( $this, 'add_page' ) );
+	}
+
+	/**
+	 * Register the admin page under the tools menu.
+	 */
+	public function add_page() {
+		add_management_page( __( 'Plugin Check', 'plugin-check' ), __( 'Plugin Check', 'plugin-check' ), 'activate_plugins', 'plugin-check', array( $this, 'render_page' ) );
+	}
+
+	/**
+	 * Returns the list of plugins.
+	 *
+	 * @return array List of plugins.
+	 */
+	public function get_available_plugins() {
+
+		$available_plugins = get_plugins();
+
+		if ( empty( $available_plugins ) ) {
+			return array();
+		}
+
+		$plugin_check_base_name = plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE );
+
+		if ( isset( $available_plugins[ $plugin_check_base_name ] ) ) {
+			unset( $available_plugins[ $plugin_check_base_name ] );
+		}
+
+		return $available_plugins;
+	}
+
+	/**
+	 * Render the "Plugin Check" page.
+	 */
+	public function render_page() {
+
+		$available_plugins = $this->get_available_plugins();
+
+		require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/admin-page.php';
+	}
+}
diff --git a/includes/Plugin_Main.php b/includes/Plugin_Main.php
index 3f0199040..d5e0be9c3 100644
--- a/includes/Plugin_Main.php
+++ b/includes/Plugin_Main.php
@@ -7,6 +7,8 @@
 
 namespace WordPress\Plugin_Check;
 
+use WordPress\Plugin_Check\Admin\Admin_Page;
+
 /**
  * Main class for the plugin.
  *
@@ -52,5 +54,8 @@ public function context() {
 	 */
 	public function add_hooks() {
 		// @TODO: Update to register CLI command to WordPress as part of issue #30
+
+		$admin_page = new Admin_Page();
+		$admin_page->add_hooks();
 	}
 }
diff --git a/templates/admin-page.php b/templates/admin-page.php
new file mode 100644
index 000000000..799c670ee
--- /dev/null
+++ b/templates/admin-page.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Template for the Admin page.
+ *
+ * @package plugin-check
+ */
+
+if ( empty( $available_plugins ) ) {
+	return;
+}
+?>
+
+<div class="wrap">
+
+	<h1><?php esc_html_e( 'Plugin Check', 'plugin-check' ); ?></h1>
+
+	<div class="card">
+
+		<form>
+			<h2>
+				<label class="title" for="plugin-check__plugins">
+					<?php esc_html_e( 'Check the Plugin', 'plugin-check' ); ?>
+				</label>
+			</h2>
+
+			<select id="plugin-check__plugins">
+				<option><?php esc_html_e( 'Select Plugin', 'plugin-check' ); ?></option>
+				<?php foreach ( $available_plugins as $plugin_basename => $available_plugin ) { ?>
+					<option value="<?php echo esc_attr( $plugin_basename ); ?>">
+						<?php echo esc_html( $available_plugin['Name'] ); ?>
+					</option>
+				<?php } ?>
+			</select>
+
+			<input type="submit" value="<?php esc_attr_e( 'Check it!', 'plugin-check' ); ?>" />
+		</form>
+
+	</div>
+
+</div>
diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
new file mode 100644
index 000000000..e7e5c93c5
--- /dev/null
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Tests for the Admin_Page class.
+ *
+ * @package plugin-check
+ */
+
+namespace Admin;
+
+use WordPress\Plugin_Check\Admin\Admin_Page;
+use WP_UnitTestCase;
+
+class Admin_Page_Tests extends WP_UnitTestCase {
+
+	protected $admin_page;
+
+	public function set_up() {
+		parent::set_up();
+		$this->admin_page = new Admin_Page();
+	}
+
+	public function test_add_hooks() {
+		$this->admin_page->add_hooks();
+		$this->assertEquals( 10, has_action( 'admin_menu', array( $this->admin_page, 'add_page' ) ) );
+	}
+
+	public function test_add_page() {
+		global $_parent_pages;
+
+		$admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+		wp_set_current_user( $admin_user );
+		set_current_screen( 'dashboard' );
+
+		$this->admin_page->add_page();
+
+		$this->assertArrayHasKey( 'plugin-check', $_parent_pages );
+		$this->assertEquals( 'tools.php', $_parent_pages['plugin-check'] );
+	}
+
+	public function test_get_plugins() {
+		$available_plugins      = get_plugins();
+		$plugin_check_base_name = plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE );
+
+		if ( isset( $available_plugins[ $plugin_check_base_name ] ) ) {
+			unset( $available_plugins[ $plugin_check_base_name ] );
+		}
+
+		$this->assertEquals( $available_plugins, $this->admin_page->get_available_plugins() );
+	}
+}

From e047148284e7552d8e9f60e79c963b5517cc9dfa Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Fri, 10 Feb 2023 22:39:29 +0530
Subject: [PATCH 02/11] Add admin tools page

---
 tests/Admin/Admin_Page_Tests.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index e7e5c93c5..99000ab42 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -27,6 +27,8 @@ public function test_add_hooks() {
 	public function test_add_page() {
 		global $_parent_pages;
 
+		$current_screen = get_current_screen();
+
 		$admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
 		wp_set_current_user( $admin_user );
 		set_current_screen( 'dashboard' );
@@ -35,6 +37,8 @@ public function test_add_page() {
 
 		$this->assertArrayHasKey( 'plugin-check', $_parent_pages );
 		$this->assertEquals( 'tools.php', $_parent_pages['plugin-check'] );
+
+		set_current_screen( $current_screen );
 	}
 
 	public function test_get_plugins() {

From 6afe441ebb7b09cd5f86fb4e49c342476c56fe1c Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Mon, 20 Feb 2023 17:44:11 +0530
Subject: [PATCH 03/11] Address feedbacks

---
 includes/Admin/Admin_Page.php    | 14 +++++++---
 templates/admin-page.php         | 44 +++++++++++++++++---------------
 tests/Admin/Admin_Page_Tests.php | 14 ++++++++--
 3 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php
index f4c7ffc4f..3d84b822b 100644
--- a/includes/Admin/Admin_Page.php
+++ b/includes/Admin/Admin_Page.php
@@ -15,17 +15,23 @@
 class Admin_Page {
 
 	/**
-	 * Initialize hooks.
+	 * Initializes hooks.
 	 */
 	public function add_hooks() {
 		add_action( 'admin_menu', array( $this, 'add_page' ) );
 	}
 
 	/**
-	 * Register the admin page under the tools menu.
+	 * Registers the admin page under the tools menu.
 	 */
 	public function add_page() {
-		add_management_page( __( 'Plugin Check', 'plugin-check' ), __( 'Plugin Check', 'plugin-check' ), 'activate_plugins', 'plugin-check', array( $this, 'render_page' ) );
+		add_management_page(
+			__( 'Plugin Check', 'plugin-check' ),
+			__( 'Plugin Check', 'plugin-check' ),
+			'activate_plugins',
+			'plugin-check',
+			array( $this, 'render_page' )
+		);
 	}
 
 	/**
@@ -33,7 +39,7 @@ public function add_page() {
 	 *
 	 * @return array List of plugins.
 	 */
-	public function get_available_plugins() {
+	private function get_available_plugins() {
 
 		$available_plugins = get_plugins();
 
diff --git a/templates/admin-page.php b/templates/admin-page.php
index 799c670ee..009312801 100644
--- a/templates/admin-page.php
+++ b/templates/admin-page.php
@@ -5,36 +5,40 @@
  * @package plugin-check
  */
 
-if ( empty( $available_plugins ) ) {
-	return;
-}
 ?>
 
 <div class="wrap">
 
 	<h1><?php esc_html_e( 'Plugin Check', 'plugin-check' ); ?></h1>
 
-	<div class="card">
+	<div class="plugin-check-content">
 
-		<form>
-			<h2>
-				<label class="title" for="plugin-check__plugins">
-					<?php esc_html_e( 'Check the Plugin', 'plugin-check' ); ?>
-				</label>
-			</h2>
+		<?php if ( ! empty( $available_plugins ) ) { ?>
 
-			<select id="plugin-check__plugins">
-				<option><?php esc_html_e( 'Select Plugin', 'plugin-check' ); ?></option>
-				<?php foreach ( $available_plugins as $plugin_basename => $available_plugin ) { ?>
-					<option value="<?php echo esc_attr( $plugin_basename ); ?>">
-						<?php echo esc_html( $available_plugin['Name'] ); ?>
-					</option>
-				<?php } ?>
-			</select>
+			<form>
+				<h2>
+					<label class="title" for="plugin-check__plugins">
+						<?php esc_html_e( 'Check the Plugin', 'plugin-check' ); ?>
+					</label>
+				</h2>
 
-			<input type="submit" value="<?php esc_attr_e( 'Check it!', 'plugin-check' ); ?>" />
-		</form>
+				<select id="plugin-check__plugins" name="plugin_check_plugins">
+					<option><?php esc_html_e( 'Select Plugin', 'plugin-check' ); ?></option>
+					<?php foreach ( $available_plugins as $plugin_basename => $available_plugin ) { ?>
+						<option value="<?php echo esc_attr( $plugin_basename ); ?>">
+							<?php echo esc_html( $available_plugin['Name'] ); ?>
+						</option>
+					<?php } ?>
+				</select>
 
+				<input type="submit" value="<?php esc_attr_e( 'Check it!', 'plugin-check' ); ?>" />
+			</form>
+
+		<?php } else { ?>
+
+			<h2><?php esc_html_e( 'No plugins available.', 'plugin-check' ); ?></h2>
+
+		<?php } ?>
 	</div>
 
 </div>
diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index 99000ab42..b2ea12906 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -30,6 +30,7 @@ public function test_add_page() {
 		$current_screen = get_current_screen();
 
 		$admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
+
 		wp_set_current_user( $admin_user );
 		set_current_screen( 'dashboard' );
 
@@ -41,7 +42,7 @@ public function test_add_page() {
 		set_current_screen( $current_screen );
 	}
 
-	public function test_get_plugins() {
+	public function test_render_page() {
 		$available_plugins      = get_plugins();
 		$plugin_check_base_name = plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE );
 
@@ -49,6 +50,15 @@ public function test_get_plugins() {
 			unset( $available_plugins[ $plugin_check_base_name ] );
 		}
 
-		$this->assertEquals( $available_plugins, $this->admin_page->get_available_plugins() );
+		ob_start();
+		$this->admin_page->render_page();
+		$output = ob_get_contents();
+		ob_end_clean();
+
+		$this->assertStringContainsString( 'Check the Plugin', $output );
+		$this->assertStringContainsString( ' id="plugin-check__plugins"', $output );
+		$this->assertStringContainsString( ' name="plugin_check_plugins"', $output );
+		$this->assertStringContainsString( 'Select Plugin', $output );
+		$this->assertStringNotContainsString( ' name="Check it!"', $output );
 	}
 }

From d2ab70fb6ac5cca6fa27f3c69e6453a0089dbcf1 Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Mon, 20 Feb 2023 17:45:39 +0530
Subject: [PATCH 04/11] Address feedbacks

---
 includes/Checker/Preparations/Use_Minimal_Theme_Preparation.php | 2 +-
 includes/Plugin_Main.php                                        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/includes/Checker/Preparations/Use_Minimal_Theme_Preparation.php b/includes/Checker/Preparations/Use_Minimal_Theme_Preparation.php
index 015de78c8..6d942ab81 100644
--- a/includes/Checker/Preparations/Use_Minimal_Theme_Preparation.php
+++ b/includes/Checker/Preparations/Use_Minimal_Theme_Preparation.php
@@ -71,7 +71,7 @@ public function prepare() {
 		add_filter( 'pre_option_template_root', array( $this, 'get_theme_root' ) );
 		add_filter( 'pre_option_stylesheet_root', array( $this, 'get_theme_root' ) );
 
-		// Register the custom themes directory if relevant.
+		// Registers the custom themes directory if relevant.
 		if ( ! empty( $this->themes_dir ) ) {
 			register_theme_directory( $this->themes_dir );
 
diff --git a/includes/Plugin_Main.php b/includes/Plugin_Main.php
index d5e0be9c3..1ae33d5f0 100644
--- a/includes/Plugin_Main.php
+++ b/includes/Plugin_Main.php
@@ -53,7 +53,7 @@ public function context() {
 	 * @since n.e.x.t
 	 */
 	public function add_hooks() {
-		// @TODO: Update to register CLI command to WordPress as part of issue #30
+		// @TODO: Update to registers CLI command to WordPress as part of issue #30
 
 		$admin_page = new Admin_Page();
 		$admin_page->add_hooks();

From 9d56f40f318551c9f820f5be5c4be021a35ea4de Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Mon, 20 Feb 2023 17:46:49 +0530
Subject: [PATCH 05/11] Address feedbacks

---
 includes/Plugin_Main.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/includes/Plugin_Main.php b/includes/Plugin_Main.php
index 1ae33d5f0..d5e0be9c3 100644
--- a/includes/Plugin_Main.php
+++ b/includes/Plugin_Main.php
@@ -53,7 +53,7 @@ public function context() {
 	 * @since n.e.x.t
 	 */
 	public function add_hooks() {
-		// @TODO: Update to registers CLI command to WordPress as part of issue #30
+		// @TODO: Update to register CLI command to WordPress as part of issue #30
 
 		$admin_page = new Admin_Page();
 		$admin_page->add_hooks();

From 30fec5ed29b53cd038eebadcf266d360fccf4e31 Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Tue, 21 Feb 2023 22:42:06 +0530
Subject: [PATCH 06/11] Fix unit test

---
 tests/Admin/Admin_Page_Tests.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index b2ea12906..3b02bcc26 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -31,6 +31,10 @@ public function test_add_page() {
 
 		$admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) );
 
+		if ( is_multisite() ) {
+			grant_super_admin( $admin_user );
+		}
+
 		wp_set_current_user( $admin_user );
 		set_current_screen( 'dashboard' );
 

From 89de72cce950db714b506335659f88410923f1de Mon Sep 17 00:00:00 2001
From: vishalkakadiya <vishal.kakadiya@rtcamp.com>
Date: Wed, 22 Feb 2023 11:21:53 +0530
Subject: [PATCH 07/11] Address feedbacks

---
 tests/Admin/Admin_Page_Tests.php | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index 3b02bcc26..203842223 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -40,19 +40,15 @@ public function test_add_page() {
 
 		$this->admin_page->add_page();
 
-		$this->assertArrayHasKey( 'plugin-check', $_parent_pages );
-		$this->assertEquals( 'tools.php', $_parent_pages['plugin-check'] );
+		$parent_pages = $_parent_pages;
 
 		set_current_screen( $current_screen );
+
+		$this->assertArrayHasKey( 'plugin-check', $parent_pages );
+		$this->assertEquals( 'tools.php', $parent_pages['plugin-check'] );
 	}
 
 	public function test_render_page() {
-		$available_plugins      = get_plugins();
-		$plugin_check_base_name = plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE );
-
-		if ( isset( $available_plugins[ $plugin_check_base_name ] ) ) {
-			unset( $available_plugins[ $plugin_check_base_name ] );
-		}
 
 		ob_start();
 		$this->admin_page->render_page();
@@ -63,6 +59,8 @@ public function test_render_page() {
 		$this->assertStringContainsString( ' id="plugin-check__plugins"', $output );
 		$this->assertStringContainsString( ' name="plugin_check_plugins"', $output );
 		$this->assertStringContainsString( 'Select Plugin', $output );
-		$this->assertStringNotContainsString( ' name="Check it!"', $output );
+		$this->assertStringContainsString( ' type="submit"', $output );
+		$this->assertStringContainsString( ' value="Check it!"', $output );
+		$this->assertStringNotContainsString( plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ), $output );
 	}
 }

From 76108a5ec46c989ac9d6382cf48d9b035141a63f Mon Sep 17 00:00:00 2001
From: jjgrainger <github@jjgrainger.co.uk>
Date: Fri, 24 Feb 2023 13:09:11 +0000
Subject: [PATCH 08/11] add missing since annotations

---
 includes/Admin/Admin_Page.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php
index 3d84b822b..1941f8750 100644
--- a/includes/Admin/Admin_Page.php
+++ b/includes/Admin/Admin_Page.php
@@ -16,6 +16,8 @@ class Admin_Page {
 
 	/**
 	 * Initializes hooks.
+	 *
+	 * @since n.e.x.t
 	 */
 	public function add_hooks() {
 		add_action( 'admin_menu', array( $this, 'add_page' ) );
@@ -23,6 +25,8 @@ public function add_hooks() {
 
 	/**
 	 * Registers the admin page under the tools menu.
+	 *
+	 * @since n.e.x.t
 	 */
 	public function add_page() {
 		add_management_page(
@@ -37,10 +41,11 @@ public function add_page() {
 	/**
 	 * Returns the list of plugins.
 	 *
-	 * @return array List of plugins.
+	 * @since n.e.x.t
+	 *
+	 * @return array List of available plugins.
 	 */
 	private function get_available_plugins() {
-
 		$available_plugins = get_plugins();
 
 		if ( empty( $available_plugins ) ) {
@@ -58,9 +63,10 @@ private function get_available_plugins() {
 
 	/**
 	 * Render the "Plugin Check" page.
+	 *
+	 * @since n.e.x.t
 	 */
 	public function render_page() {
-
 		$available_plugins = $this->get_available_plugins();
 
 		require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/admin-page.php';

From 07377429259b1451f3267d66f113872f0fd9a61f Mon Sep 17 00:00:00 2001
From: jjgrainger <github@jjgrainger.co.uk>
Date: Fri, 24 Feb 2023 13:36:43 +0000
Subject: [PATCH 09/11] update tests

---
 includes/Admin/Admin_Page.php    |  2 +-
 tests/Admin/Admin_Page_Tests.php | 70 ++++++++++++++++++++++++++++----
 2 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php
index 1941f8750..8af87b65b 100644
--- a/includes/Admin/Admin_Page.php
+++ b/includes/Admin/Admin_Page.php
@@ -69,6 +69,6 @@ private function get_available_plugins() {
 	public function render_page() {
 		$available_plugins = $this->get_available_plugins();
 
-		require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/admin-page.php';
+		require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . '/templates/admin-page.php';
 	}
 }
diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index 203842223..78befc0dc 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -8,6 +8,7 @@
 namespace Admin;
 
 use WordPress\Plugin_Check\Admin\Admin_Page;
+use WP_Object_Cache;
 use WP_UnitTestCase;
 
 class Admin_Page_Tests extends WP_UnitTestCase {
@@ -49,18 +50,73 @@ public function test_add_page() {
 	}
 
 	public function test_render_page() {
-
+		global $wp_object_cache;
+
+		// Backup original and create a new WP_Object_Cache.
+		$original_cache  = $wp_object_cache;
+		$wp_object_cache = new WP_Object_Cache();
+
+		// Create the basic information required get_available_plugins.
+		$expected_plugins = array(
+			"hello.php" => array(
+				"Name" => "Hello Dolly",
+			),
+			"akismet/akismet.php" => array(
+				"Name" => "Akistmet",
+			),
+			"Fake-plugin/load.php" => array(
+				"Name" => "Fake Plugin",
+			),
+		);
+
+		// Include the Plugin Checker plugin.
+		$expected_plugins[ plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ] = array( "Name" => "Plugin Checker" );
+
+		// Set the expected plugins in the cache,
+		$wp_object_cache->add( 'plugins', array( "" => $expected_plugins ), 'plugins' );
+
+		// Render the admin page.
 		ob_start();
 		$this->admin_page->render_page();
 		$output = ob_get_contents();
 		ob_end_clean();
 
-		$this->assertStringContainsString( 'Check the Plugin', $output );
-		$this->assertStringContainsString( ' id="plugin-check__plugins"', $output );
-		$this->assertStringContainsString( ' name="plugin_check_plugins"', $output );
-		$this->assertStringContainsString( 'Select Plugin', $output );
-		$this->assertStringContainsString( ' type="submit"', $output );
-		$this->assertStringContainsString( ' value="Check it!"', $output );
+		// Restore the original cache.
+		$wp_object_cache = $original_cache;
+
+		// Remove the plugin checker from exptected plugins for testing.
+		unset( $expected_plugins[ plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ] );
+
+		// Assert the Plugin Checker does not appear in the select dropdown.
 		$this->assertStringNotContainsString( plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ), $output );
+
+		// Assert the expected plugins appear in the select dropdown.
+		foreach ( $expected_plugins as $plugin => $data ) {
+			$this->assertStringContainsString( '<option value="' . $plugin . '">', $output );
+			$this->assertStringContainsString( $data['Name'], $output );
+		}
+	}
+
+	public function test_render_page_with_no_plugins() {
+		global $wp_object_cache;
+
+		// Backup original and create a new WP_Object_Cache.
+		$original_cache  = $wp_object_cache;
+		$wp_object_cache = new WP_Object_Cache();
+
+		// Set the expected plugins to be empty in the cache,
+		$wp_object_cache->add( 'plugins', array( "" => array() ), 'plugins' );
+
+		// Render the admin page.
+		ob_start();
+		$this->admin_page->render_page();
+		$output = ob_get_contents();
+		ob_end_clean();
+
+		// Restore the original cache.
+		$wp_object_cache = $original_cache;
+
+		$this->assertStringContainsString( 'No plugins available.', $output );
+		$this->assertStringNotContainsString( '<select id="plugin-check__plugins"', $output );
 	}
 }

From 40d63ff6a45b77d8815453ce68a70e8fa222f199 Mon Sep 17 00:00:00 2001
From: jjgrainger <github@jjgrainger.co.uk>
Date: Fri, 24 Feb 2023 13:39:28 +0000
Subject: [PATCH 10/11] fix lint issues

---
 tests/Admin/Admin_Page_Tests.php | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index 78befc0dc..f151164d0 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -58,22 +58,22 @@ public function test_render_page() {
 
 		// Create the basic information required get_available_plugins.
 		$expected_plugins = array(
-			"hello.php" => array(
-				"Name" => "Hello Dolly",
+			'hello.php'            => array(
+				'Name' => 'Hello Dolly',
 			),
-			"akismet/akismet.php" => array(
-				"Name" => "Akistmet",
+			'akismet/akismet.php'  => array(
+				'Name' => 'Akistmet',
 			),
-			"Fake-plugin/load.php" => array(
-				"Name" => "Fake Plugin",
+			'Fake-plugin/load.php' => array(
+				'Name' => 'Fake Plugin',
 			),
 		);
 
 		// Include the Plugin Checker plugin.
-		$expected_plugins[ plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ] = array( "Name" => "Plugin Checker" );
+		$expected_plugins[ plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ] = array( 'Name' => 'Plugin Checker' );
 
-		// Set the expected plugins in the cache,
-		$wp_object_cache->add( 'plugins', array( "" => $expected_plugins ), 'plugins' );
+		// Set the expected plugins in the cache.
+		$wp_object_cache->add( 'plugins', array( '' => $expected_plugins ), 'plugins' );
 
 		// Render the admin page.
 		ob_start();
@@ -104,8 +104,8 @@ public function test_render_page_with_no_plugins() {
 		$original_cache  = $wp_object_cache;
 		$wp_object_cache = new WP_Object_Cache();
 
-		// Set the expected plugins to be empty in the cache,
-		$wp_object_cache->add( 'plugins', array( "" => array() ), 'plugins' );
+		// Set the expected plugins to be empty in the cache.
+		$wp_object_cache->add( 'plugins', array( '' => array() ), 'plugins' );
 
 		// Render the admin page.
 		ob_start();

From 18f7240999ec7c8f420a4e5edb680ecf56f689db Mon Sep 17 00:00:00 2001
From: jjgrainger <github@jjgrainger.co.uk>
Date: Fri, 24 Feb 2023 13:55:36 +0000
Subject: [PATCH 11/11] update wp_object_cache usage in tests

---
 tests/Admin/Admin_Page_Tests.php | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/tests/Admin/Admin_Page_Tests.php b/tests/Admin/Admin_Page_Tests.php
index f151164d0..e89d812d3 100644
--- a/tests/Admin/Admin_Page_Tests.php
+++ b/tests/Admin/Admin_Page_Tests.php
@@ -52,9 +52,8 @@ public function test_add_page() {
 	public function test_render_page() {
 		global $wp_object_cache;
 
-		// Backup original and create a new WP_Object_Cache.
-		$original_cache  = $wp_object_cache;
-		$wp_object_cache = new WP_Object_Cache();
+		// Backup original plugins in the object cache.
+		$original_plugins = $wp_object_cache->get( 'plugins', 'plugins' );
 
 		// Create the basic information required get_available_plugins.
 		$expected_plugins = array(
@@ -70,10 +69,11 @@ public function test_render_page() {
 		);
 
 		// Include the Plugin Checker plugin.
-		$expected_plugins[ plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ] = array( 'Name' => 'Plugin Checker' );
+		$plugin_basename                      = plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE );
+		$expected_plugins[ $plugin_basename ] = array( 'Name' => 'Plugin Checker' );
 
 		// Set the expected plugins in the cache.
-		$wp_object_cache->add( 'plugins', array( '' => $expected_plugins ), 'plugins' );
+		$wp_object_cache->set( 'plugins', array( '' => $expected_plugins ), 'plugins' );
 
 		// Render the admin page.
 		ob_start();
@@ -82,13 +82,13 @@ public function test_render_page() {
 		ob_end_clean();
 
 		// Restore the original cache.
-		$wp_object_cache = $original_cache;
+		$wp_object_cache->set( 'plugins', $original_plugins, 'plugins' );
 
 		// Remove the plugin checker from exptected plugins for testing.
-		unset( $expected_plugins[ plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ] );
+		unset( $expected_plugins[ $plugin_basename ] );
 
 		// Assert the Plugin Checker does not appear in the select dropdown.
-		$this->assertStringNotContainsString( plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ), $output );
+		$this->assertStringNotContainsString( $plugin_basename, $output );
 
 		// Assert the expected plugins appear in the select dropdown.
 		foreach ( $expected_plugins as $plugin => $data ) {
@@ -100,9 +100,8 @@ public function test_render_page() {
 	public function test_render_page_with_no_plugins() {
 		global $wp_object_cache;
 
-		// Backup original and create a new WP_Object_Cache.
-		$original_cache  = $wp_object_cache;
-		$wp_object_cache = new WP_Object_Cache();
+		// Backup original plugins in the object cache.
+		$original_plugins = $wp_object_cache->get( 'plugins', 'plugins' );
 
 		// Set the expected plugins to be empty in the cache.
 		$wp_object_cache->add( 'plugins', array( '' => array() ), 'plugins' );
@@ -114,7 +113,7 @@ public function test_render_page_with_no_plugins() {
 		ob_end_clean();
 
 		// Restore the original cache.
-		$wp_object_cache = $original_cache;
+		$wp_object_cache->set( 'plugins', $original_plugins, 'plugins' );
 
 		$this->assertStringContainsString( 'No plugins available.', $output );
 		$this->assertStringNotContainsString( '<select id="plugin-check__plugins"', $output );
