2018-05-28 09:18:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Meta
|
|
|
|
* @package WooCommerce\Tests\Importer
|
|
|
|
*/
|
|
|
|
class WC_Tests_Tax_CSV_Importer extends WC_Unit_Test_Case {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test CSV file path.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $csv_file = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load up the importer classes since they aren't loaded by default.
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->csv_file = dirname( __FILE__ ) . '/sample_tax_rates.csv';
|
|
|
|
|
|
|
|
$bootstrap = WC_Unit_Tests_Bootstrap::instance();
|
|
|
|
require_once ABSPATH . '/wp-admin/includes/class-wp-importer.php';
|
|
|
|
require_once $bootstrap->plugin_dir . '/includes/admin/importers/class-wc-tax-rate-importer.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test import.
|
|
|
|
* @since 3.1.0
|
|
|
|
*/
|
|
|
|
public function test_import() {
|
|
|
|
global $wpdb;
|
|
|
|
$importer = new WC_Tax_Rate_Importer();
|
|
|
|
ob_start();
|
2018-05-29 05:33:19 +00:00
|
|
|
$importer->import( $this->csv_file );
|
2018-05-29 11:59:46 +00:00
|
|
|
ob_end_clean();
|
2018-05-28 09:18:42 +00:00
|
|
|
$rate_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_tax_rates" );
|
|
|
|
$this->assertEquals( 5, $rate_count );
|
|
|
|
}
|
|
|
|
}
|