Merge pull request #27671 from mahmoudsaeed/master

Make WC_Tax::get_tax_rate_classes() public
This commit is contained in:
Claudio Sanches 2021-02-15 14:31:25 -03:00 committed by GitHub
commit 74bb66dc6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -761,7 +761,7 @@ class WC_Tax {
* @since 3.7.0 * @since 3.7.0
* @return array Array of tax class objects consisting of tax_rate_class_id, name, and slug. * @return array Array of tax class objects consisting of tax_rate_class_id, name, and slug.
*/ */
protected static function get_tax_rate_classes() { public static function get_tax_rate_classes() {
global $wpdb; global $wpdb;
$cache_key = 'tax-rate-classes'; $cache_key = 'tax-rate-classes';

View File

@ -474,8 +474,25 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
$tax_classes = WC_Tax::get_tax_classes(); $tax_classes = WC_Tax::get_tax_classes();
$this->assertEquals( $tax_classes, array( 'Reduced rate', 'Zero rate' ) ); $this->assertEquals( $tax_classes, array( 'Reduced rate', 'Zero rate' ) );
$tax_classes = WC_Tax::get_tax_class_slugs(); $tax_class_slugs = WC_Tax::get_tax_class_slugs();
$this->assertEquals( $tax_classes, array( 'reduced-rate', 'zero-rate' ) ); $this->assertEquals( $tax_class_slugs, array( 'reduced-rate', 'zero-rate' ) );
$tax_rate_classes = WC_Tax::get_tax_rate_classes();
$this->assertEquals(
$tax_rate_classes,
array(
(object) array(
'tax_rate_class_id' => '1',
'name' => 'Reduced rate',
'slug' => 'reduced-rate',
),
(object) array(
'tax_rate_class_id' => '2',
'name' => 'Zero rate',
'slug' => 'zero-rate',
),
)
);
} }
/** /**