woocommerce/plugins/woocommerce-admin/tests/features/class-wc-tests-onboarding.php

41 lines
994 B
PHP

<?php
/**
* Onboarding Themes Tests.
*
* @package WooCommerce\Admin\Tests\OnboardingThemes
*/
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 );
}
}