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 theme name to compatibility service #7952

Merged
merged 5 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/add-3943-send-blog-theme-to-sift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add the active theme name of the blog to the compatibility service
2 changes: 2 additions & 0 deletions includes/class-compatibility-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct( WC_Payments_API_Client $payments_api_client ) {
*/
public function init_hooks() {
add_action( 'woocommerce_payments_account_refreshed', [ $this, 'update_compatibility_data' ] );
add_action( 'after_switch_theme', [ $this, 'update_compatibility_data' ] );
}

/**
Expand All @@ -52,6 +53,7 @@ public function update_compatibility_data() {
[
'woopayments_version' => WCPAY_VERSION_NUMBER,
'woocommerce_version' => WC_VERSION,
'blog_theme' => get_stylesheet(),
]
);
} catch ( API_Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test-class-compatibility-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@ public function set_up() {
public function test_registers_woocommerce_filters_properly() {
$priority = has_filter( 'woocommerce_payments_account_refreshed', [ $this->compatibility_service, 'update_compatibility_data' ] );
$this->assertEquals( 10, $priority );
$priority = has_action( 'after_switch_theme', [ $this->compatibility_service, 'update_compatibility_data' ] );
$this->assertEquals( 10, $priority );
}

public function test_update_compatibility_data() {
$stylesheet = 'my_theme_name';
add_filter(
'stylesheet',
function( $theme ) use ( $stylesheet ) {
return $stylesheet;
}
);

// Arrange: Create the expected value to be passed to update_compatibility_data.
$expected = [
'woopayments_version' => WCPAY_VERSION_NUMBER,
'woocommerce_version' => WC_VERSION,
'blog_theme' => $stylesheet,
];

// Arrange/Assert: Set the expectations for update_compatibility_data.
Expand Down
Loading