From 12fa142233ff404b72a1d38ffb6e83a43b5c7113 Mon Sep 17 00:00:00 2001 From: Nate Weller Date: Wed, 15 Jan 2025 15:24:19 -0700 Subject: [PATCH] adjust tests --- .../protect-status/tests/php/test-status.php | 98 +++++++++---------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/projects/packages/protect-status/tests/php/test-status.php b/projects/packages/protect-status/tests/php/test-status.php index c948f560ec54e..89cdf250dfd65 100644 --- a/projects/packages/protect-status/tests/php/test-status.php +++ b/projects/packages/protect-status/tests/php/test-status.php @@ -161,7 +161,31 @@ public function get_sample_api_response() { public function get_sample_status() { global $wp_version; - $sample_plugin_1 = new Extension_Model( + $vulnerability_1 = new Vulnerability_Model( + array( + 'id' => 'test-vuln-1', + 'title' => 'Test Vuln 1', + 'fixed_in' => '1.0.0', + ) + ); + + $vulnerability_2 = new Vulnerability_Model( + array( + 'id' => 'test-vuln-2', + 'title' => 'Test Vuln 2', + 'fixed_in' => '2.0.0', + ) + ); + + $vulnerability_3 = new Vulnerability_Model( + array( + 'id' => 'test-vuln-3', + 'title' => 'Test Vuln 3', + 'fixed_in' => null, + ) + ); + + $plugin_1 = new Extension_Model( array( 'version' => '1.0.2', 'name' => 'Sample Plugin 1', @@ -171,7 +195,7 @@ public function get_sample_status() { ) ); - $sample_theme_1 = new Extension_Model( + $theme_1 = new Extension_Model( array( 'version' => '1.0.2', 'name' => 'Sample Theme 1', @@ -181,7 +205,7 @@ public function get_sample_status() { ) ); - $sample_core = new Extension_Model( + $core = new Extension_Model( array( 'version' => $wp_version, 'name' => 'WordPress', @@ -191,37 +215,13 @@ public function get_sample_status() { ) ); - $vulnerability_1 = new Vulnerability_Model( - array( - 'id' => 'test-vuln-1', - 'title' => 'Test Vuln 1', - 'fixed_in' => '1.0.0', - ) - ); - - $vulnerability_2 = new Vulnerability_Model( - array( - 'id' => 'test-vuln-2', - 'title' => 'Test Vuln 2', - 'fixed_in' => '2.0.0', - ) - ); - - $vulnerability_3 = new Vulnerability_Model( - array( - 'id' => 'test-vuln-3', - 'title' => 'Test Vuln 3', - 'fixed_in' => null, - ) - ); - $plugin_1_threat = new Threat_Model( array( 'id' => 'plugins-plugin-1-1.0.2', 'title' => 'Vulnerable plugin: Sample Plugin 1 (version 1.0.2)', 'description' => 'The installed version of Sample Plugin 1 (1.0.2) has a known security vulnerability.', 'fixed_in' => '2.0.0', - 'source' => null, // 'https://jetpack.com/redirect/?source=jetpack-protect-vul-info&site=example.org&path=test-vuln-1', + 'source' => null, 'vulnerabilities' => array( $vulnerability_2 ), ) ); @@ -232,7 +232,7 @@ public function get_sample_status() { 'title' => 'Vulnerable theme: Sample Theme 1 (version 1.0.2)', 'description' => 'The installed version of Sample Theme 1 (1.0.2) has a known security vulnerability.', 'fixed_in' => '1.0.0', - 'source' => null, // 'https://jetpack.com/redirect/?source=jetpack-protect-vul-info&site=example.org&path=test-vuln-1', + 'source' => null, 'vulnerabilities' => array( $vulnerability_1 ), ) ); @@ -243,30 +243,28 @@ public function get_sample_status() { 'title' => 'Vulnerable WordPress (version ' . $wp_version . ')', 'description' => 'The installed version of WordPress (' . $wp_version . ') has a known security vulnerability.', 'fixed_in' => null, - 'source' => null, // 'https://jetpack.com/redirect/?source=jetpack-protect-vul-info&site=example.org&path=test-vuln-3', + 'source' => null, 'vulnerabilities' => array( $vulnerability_3 ), ) ); - $core_threat_extension = clone $core_threat; - $core_threat_extension->extension = $sample_core; + $core_threat_with_extension = clone $core_threat; + $core_threat_with_extension->extension = $core; - $plugin_1_threat_extension = clone $plugin_1_threat; - $plugin_1_threat_extension->extension = $sample_plugin_1; + $plugin_1_threat_with_extension = clone $plugin_1_threat; + $plugin_1_threat_with_extension->extension = $plugin_1; - $theme_1_threat_extension = clone $theme_1_threat; - $theme_1_threat_extension->extension = $sample_theme_1; + $theme_1_threat_with_extension = clone $theme_1_threat; + $theme_1_threat_with_extension->extension = $theme_1; - $sample_plugin_1_threats = clone $sample_plugin_1; - $sample_plugin_1_threats->threats = array( $plugin_1_threat ); - unset( $sample_plugin_1_threats->extension ); + $plugin_1_with_threats = clone $plugin_1; + $plugin_1_with_threats->threats = array( $plugin_1_threat ); - $sample_theme_1_threats = clone $sample_theme_1; - $sample_theme_1_threats->threats = array( $theme_1_threat ); - unset( $sample_theme_1_threats->extension ); + $theme_1_with_threats = clone $theme_1; + $theme_1_with_threats->threats = array( $theme_1_threat ); - $sample_core_threats = clone $sample_core; - $sample_core_threats->threats = array( $core_threat ); + $core_with_threats = clone $core; + $core_with_threats->threats = array( $core_threat ); return new Status_Model( array( @@ -287,16 +285,16 @@ public function get_sample_status() { 'slug' => 'plugin-2', ) ), - $sample_plugin_1_threats, + $plugin_1_with_threats, ), 'themes' => array( - $sample_theme_1_threats, + $theme_1_with_threats, ), - 'core' => $sample_core_threats, + 'core' => $core_with_threats, 'threats' => array( - $theme_1_threat_extension, - $plugin_1_threat_extension, - $core_threat_extension, + $theme_1_threat_with_extension, + $plugin_1_threat_with_extension, + $core_threat_with_extension, ), ) );