From be0672777413d453e2198cf46d0e150f3ba74247 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Tue, 1 Dec 2020 16:27:24 +0100 Subject: [PATCH 1/2] Calypsoify: fix Masterbar reference after its refactor In #17762 and #17783 we've refactored the Masterbar, but forgot to update references to it in the Calypsoify feature, thus causing Fatal errors. --- modules/calypsoify/class.jetpack-calypsoify.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/calypsoify/class.jetpack-calypsoify.php b/modules/calypsoify/class.jetpack-calypsoify.php index 293636135f4ad..f3937495f20ef 100644 --- a/modules/calypsoify/class.jetpack-calypsoify.php +++ b/modules/calypsoify/class.jetpack-calypsoify.php @@ -4,6 +4,7 @@ * Ported from an internal Automattic plugin. */ +use Automattic\Jetpack\Dashboard_Customizations\Masterbar; use Automattic\Jetpack\Redirect; use Automattic\Jetpack\Status; @@ -76,8 +77,8 @@ public function admin_color_override( $color ) { } public function mock_masterbar_activation() { - include_once JETPACK__PLUGIN_DIR . 'modules/masterbar/masterbar.php'; - new A8C_WPCOM_Masterbar; + include_once JETPACK__PLUGIN_DIR . 'modules/masterbar/masterbar/class-masterbar.php'; + new Masterbar(); } public function remove_core_menus() { From c2360153d0ec6abbfaa66aa401cbf48b6d429c7c Mon Sep 17 00:00:00 2001 From: Brandon Kraft Date: Tue, 1 Dec 2020 13:24:26 -0600 Subject: [PATCH 2/2] Calypsoify: Add test to fail under 9.2 (#17942) --- phpunit.xml.dist | 3 ++ .../test-class.jetpack-calypsoify.php | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/php/modules/calypsoify/test-class.jetpack-calypsoify.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4bde03b85c4d1..f366b871676cf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -30,6 +30,9 @@ tests/php/modules/comment-likes + + tests/php/modules/calypsoify + tests/php/modules/likes diff --git a/tests/php/modules/calypsoify/test-class.jetpack-calypsoify.php b/tests/php/modules/calypsoify/test-class.jetpack-calypsoify.php new file mode 100644 index 0000000000000..1847fbca84fd9 --- /dev/null +++ b/tests/php/modules/calypsoify/test-class.jetpack-calypsoify.php @@ -0,0 +1,37 @@ +instance = Jetpack_Calypsoify::getInstance(); + } + + /** + * Sets up the Masterbar mock. + * + * For sites when Masterbar is not active, we mock it. This test confirms that functions. + * + * @covers Jetpack_Calypsoify::mock_masterbar_activation + * @see https://github.com/Automattic/jetpack/pull/17939 + */ + public function test_mock_masterbar_activation() { + $this->instance->mock_masterbar_activation(); + $this->assertTrue( class_exists( '\Automattic\Jetpack\Dashboard_Customizations\Masterbar' ) ); + } +}