Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add active plugin list to compatibility service #7933

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add active plugins array to compatibility data.
3 changes: 3 additions & 0 deletions includes/class-compatibility-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ public function init_hooks() {
* @return void
*/
public function update_compatibility_data() {
$active_plugins = get_option( 'active_plugins' );

try {
$this->payments_api_client->update_compatibility_data(
[
'woopayments_version' => WCPAY_VERSION_NUMBER,
'woocommerce_version' => WC_VERSION,
'active_plugins' => $active_plugins,
]
);
} catch ( API_Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test-class-compatibility-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,30 @@ public function test_update_compatibility_data() {
$expected = [
'woopayments_version' => WCPAY_VERSION_NUMBER,
'woocommerce_version' => WC_VERSION,
'active_plugins' => [
'woocommerce/woocommerce.php',
'woocommerce-payments/woocommerce-payments.php',
],
];

// Arrange/Assert: Set the expectations for update_compatibility_data.
add_filter( 'option_active_plugins', [ $this, 'active_plugins_filter_return' ] );

$this->mock_api_client
->expects( $this->once() )
->method( 'update_compatibility_data' )
->with( $expected );

// Act: Call the method we're testing.
$this->compatibility_service->update_compatibility_data();

remove_filter( 'option_active_plugins', [ $this, 'active_plugins_filter_return' ] );
}

public function active_plugins_filter_return() {
return [
'woocommerce/woocommerce.php',
'woocommerce-payments/woocommerce-payments.php',
];
}
}
Loading