This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sorting to push Storefront to the top of the theme list (#4187)
* Fix sorting to push Storefront to the top of the theme list * Add test to ensure Storefront is sorted in get_themes() * copy paste cleanup * Refactor sorting logic. * Fix linting errors * Updates per feedback. * Add check for products property * Fix for 5.6 CI. * Oh hey another CI fix Co-authored-by: Timmy Crawford <timmydcrawford@gmail.com>
- Loading branch information
Showing
2 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Onboarding Themes Tests. | ||
* | ||
* @package WooCommerce\Tests\Onboarding-themes | ||
*/ | ||
|
||
use \Automattic\WooCommerce\Admin\Features\Onboarding; | ||
|
||
/** | ||
* Class WC_Tests_Onboarding | ||
*/ | ||
class WC_Tests_Onboarding extends WC_Unit_Test_Case { | ||
|
||
/** | ||
* Verifies that given an array of theme objects, the object containing Storefront will be sorted to the first position. | ||
*/ | ||
public function test_sort_woocommerce_themes() { | ||
$theme1 = (object) array( | ||
'id' => 1, | ||
'slug' => 'ribs', | ||
); | ||
$theme2 = (object) array( | ||
'id' => 2, | ||
'slug' => 'chicken', | ||
); | ||
$theme3 = (object) array( | ||
'id' => 3, | ||
'slug' => 'Storefront', | ||
); | ||
$theme4 = (object) array( | ||
'id' => 4, | ||
'slug' => 'poutine', | ||
); | ||
$some_themes = array( $theme1, $theme2, $theme3, $theme4 ); | ||
$sorted_themes = \Automattic\WooCommerce\Admin\Features\Onboarding::sort_woocommerce_themes( $some_themes ); | ||
$this->assertEquals( 'Storefront', $sorted_themes[0]->slug ); | ||
} | ||
|
||
} |