Fix PHPCS errors in WC_Tests_Data_Store class file

This commit is contained in:
Rodrigo Primo 2019-11-21 10:41:27 -03:00
parent 44b09cb15a
commit ed1c4b11b8
1 changed files with 20 additions and 10 deletions

View File

@ -1,7 +1,13 @@
<?php <?php
/** /**
* Data Store Tests * Data Store tests
*
* @package WooCommerce\Tests\Product * @package WooCommerce\Tests\Product
*/
/**
* Class for Data Store tests
*
* @since 3.0.0 * @since 3.0.0
*/ */
class WC_Tests_Data_Store extends WC_Unit_Test_Case { class WC_Tests_Data_Store extends WC_Unit_Test_Case {
@ -12,9 +18,9 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
* *
* @since 3.0.0 * @since 3.0.0
*/ */
function test_invalid_store_throws_exception() { public function test_invalid_store_throws_exception() {
try { try {
$product_store = new WC_Data_Store( 'bogus' ); new WC_Data_Store( 'bogus' );
} catch ( Exception $e ) { } catch ( Exception $e ) {
$this->assertEquals( $e->getMessage(), 'Invalid data store.' ); $this->assertEquals( $e->getMessage(), 'Invalid data store.' );
return; return;
@ -27,9 +33,9 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
* *
* @since 3.0.0 * @since 3.0.0
*/ */
function test_invalid_store_load_throws_exception() { public function test_invalid_store_load_throws_exception() {
try { try {
$product_store = WC_Data_Store::load( 'does-not-exist' ); WC_Data_Store::load( 'does-not-exist' );
} catch ( Exception $e ) { } catch ( Exception $e ) {
$this->assertEquals( $e->getMessage(), 'Invalid data store.' ); $this->assertEquals( $e->getMessage(), 'Invalid data store.' );
return; return;
@ -42,7 +48,7 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
* *
* @since 3.0.0 * @since 3.0.0
*/ */
function test_store_swap() { public function test_store_swap() {
$this->load_dummy_store(); $this->load_dummy_store();
$store = new WC_Data_Store( 'dummy' ); $store = new WC_Data_Store( 'dummy' );
@ -61,7 +67,7 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
* *
* @since 3.0.0 * @since 3.0.0
*/ */
function test_store_sub_type() { public function test_store_sub_type() {
$this->load_dummy_store(); $this->load_dummy_store();
$store = WC_Data_Store::load( 'dummy-sub' ); $store = WC_Data_Store::load( 'dummy-sub' );
$this->assertEquals( 'WC_Dummy_Data_Store_CPT', $store->get_current_class_name() ); $this->assertEquals( 'WC_Dummy_Data_Store_CPT', $store->get_current_class_name() );
@ -74,7 +80,7 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
* *
* @since 3.0.0 * @since 3.0.0
*/ */
function load_dummy_store() { private function load_dummy_store() {
include_once dirname( dirname( dirname( __FILE__ ) ) ) . '/framework/class-wc-dummy-data-store.php'; include_once dirname( dirname( dirname( __FILE__ ) ) ) . '/framework/class-wc-dummy-data-store.php';
add_filter( 'woocommerce_data_stores', array( $this, 'add_dummy_data_store' ) ); add_filter( 'woocommerce_data_stores', array( $this, 'add_dummy_data_store' ) );
} }
@ -82,9 +88,11 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
/** /**
* Adds a default class for the 'dummy' data store. * Adds a default class for the 'dummy' data store.
* *
* @param array $stores Loaded data stores.
* @return array Modified list of data stores.
* @since 3.0.0 * @since 3.0.0
*/ */
function add_dummy_data_store( $stores ) { public function add_dummy_data_store( $stores ) {
$stores['dummy'] = 'WC_Dummy_Data_Store_CPT'; $stores['dummy'] = 'WC_Dummy_Data_Store_CPT';
return $stores; return $stores;
} }
@ -92,9 +100,11 @@ class WC_Tests_Data_Store extends WC_Unit_Test_Case {
/** /**
* Helper function/filter to swap out the default dummy store for a different one. * Helper function/filter to swap out the default dummy store for a different one.
* *
* @param string $store Data store class name.
* @return string New data store class name.
* @since 3.0.0 * @since 3.0.0
*/ */
function set_dummy_store( $store ) { public function set_dummy_store( $store ) {
return 'WC_Dummy_Data_Store_Custom_Table'; return 'WC_Dummy_Data_Store_Custom_Table';
} }
} }