2014-09-01 06:59:35 +00:00
|
|
|
<?php
|
2015-03-06 15:32:40 +00:00
|
|
|
|
2014-09-01 06:59:35 +00:00
|
|
|
/**
|
2017-09-05 19:52:20 +00:00
|
|
|
* WooCommerce class.
|
2017-12-14 10:45:00 +00:00
|
|
|
*
|
2015-03-06 15:32:40 +00:00
|
|
|
* @package WooCommerce\Tests\Util
|
2014-09-01 06:59:35 +00:00
|
|
|
*/
|
2017-09-05 19:52:20 +00:00
|
|
|
class WC_Test_WooCommerce extends WC_Unit_Test_Case {
|
2014-09-01 06:59:35 +00:00
|
|
|
|
2017-09-05 19:52:20 +00:00
|
|
|
/**
|
|
|
|
* WooCommerce instance.
|
|
|
|
*
|
|
|
|
* @var \WooCommerce instance
|
|
|
|
*/
|
2014-09-01 06:59:35 +00:00
|
|
|
protected $wc;
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Setup test.
|
2014-09-01 06:59:35 +00:00
|
|
|
*
|
|
|
|
* @since 2.2
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->wc = WC();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Test WC has static instance.
|
2014-09-01 06:59:35 +00:00
|
|
|
*
|
|
|
|
* @since 2.2
|
|
|
|
*/
|
|
|
|
public function test_wc_instance() {
|
|
|
|
$this->assertClassHasStaticAttribute( '_instance', 'WooCommerce' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Test that all WC constants are set.
|
2014-09-01 06:59:35 +00:00
|
|
|
*
|
|
|
|
* @since 2.2
|
|
|
|
*/
|
|
|
|
public function test_constants() {
|
2017-09-05 19:52:20 +00:00
|
|
|
$this->assertEquals( str_replace( 'tests/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE );
|
2014-09-01 06:59:35 +00:00
|
|
|
$this->assertEquals( $this->wc->version, WC_VERSION );
|
|
|
|
$this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION );
|
2018-01-30 15:00:53 +00:00
|
|
|
$this->assertEquals( 6, WC_ROUNDING_PRECISION );
|
2017-12-14 10:45:00 +00:00
|
|
|
$this->assertEquals( 2, WC_DISCOUNT_ROUNDING_MODE );
|
|
|
|
$this->assertEquals( 'wc_session_id', WC_SESSION_CACHE_GROUP );
|
2017-11-06 21:30:00 +00:00
|
|
|
$this->assertContains( WC_TAX_ROUNDING_MODE, array( 2, 1, 'auto' ) );
|
2014-09-01 06:59:35 +00:00
|
|
|
$this->assertEquals( '|', WC_DELIMITER );
|
2014-10-14 12:23:18 +00:00
|
|
|
$this->assertNotEquals( WC_LOG_DIR, '' );
|
2017-12-14 10:45:00 +00:00
|
|
|
$this->assertEquals( false, WC_TEMPLATE_DEBUG_MODE );
|
|
|
|
$this->assertLessThanOrEqual( 2, WC_TAX_ROUNDING_MODE );
|
|
|
|
$this->assertEquals( $this->wc->template_path(), WC_TEMPLATE_PATH );
|
2014-09-01 06:59:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Test class instance.
|
2014-09-01 06:59:35 +00:00
|
|
|
*
|
|
|
|
* @since 2.2
|
|
|
|
*/
|
|
|
|
public function test_wc_class_instances() {
|
2017-12-14 10:45:00 +00:00
|
|
|
$this->assertInstanceOf( 'WooCommerce', $this->wc );
|
2014-09-01 06:59:35 +00:00
|
|
|
$this->assertInstanceOf( 'WC_Product_Factory', $this->wc->product_factory );
|
|
|
|
$this->assertInstanceOf( 'WC_Order_Factory', $this->wc->order_factory );
|
|
|
|
$this->assertInstanceOf( 'WC_Countries', $this->wc->countries );
|
2015-07-20 11:10:58 +00:00
|
|
|
$this->assertInstanceOf( 'WC_Integrations', $this->wc->integrations );
|
2014-09-01 06:59:35 +00:00
|
|
|
$this->assertInstanceOf( 'WC_Cart', $this->wc->cart );
|
|
|
|
$this->assertInstanceOf( 'WC_Customer', $this->wc->customer );
|
2017-12-14 10:45:00 +00:00
|
|
|
$this->assertInstanceOf( 'WC_Session', $this->wc->session );
|
|
|
|
$this->assertInstanceOf( 'WC_Query', $this->wc->query );
|
|
|
|
$this->assertInstanceOf( 'WC_Structured_Data', $this->wc->structured_data );
|
|
|
|
$this->assertInstanceOf( 'WC_Deprecated_Action_Hooks', $this->wc->deprecated_hook_handlers['actions'] );
|
|
|
|
$this->assertInstanceOf( 'WC_Deprecated_Filter_Hooks', $this->wc->deprecated_hook_handlers['filters'] );
|
|
|
|
$this->assertInstanceOf( 'WC_Emails', $this->wc->mailer() );
|
|
|
|
$this->assertInstanceOf( 'WC_Payment_Gateways', $this->wc->payment_gateways() );
|
|
|
|
$this->assertInstanceOf( 'WC_Checkout', $this->wc->checkout() );
|
2014-09-01 06:59:35 +00:00
|
|
|
}
|
|
|
|
}
|