woocommerce/tests/unit-tests/util/main-class.php

69 lines
1.6 KiB
PHP
Raw Normal View History

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
/**
2015-11-03 13:31:20 +00:00
* Class Main_Class.
2015-03-06 15:32:40 +00:00
* @package WooCommerce\Tests\Util
2014-09-01 06:59:35 +00:00
*/
class WC_Tests_Main_Class extends WC_Unit_Test_Case {
2014-09-01 06:59:35 +00:00
/** @var \WooCommerce instance */
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() {
2015-03-06 15:32:40 +00:00
$this->assertEquals( str_replace( 'tests/unit-tests/util/', '', 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 );
$this->assertEquals( 4, WC_ROUNDING_PRECISION );
2015-03-06 15:32:40 +00:00
$this->assertContains( WC_TAX_ROUNDING_MODE, array( 2, 1 ) );
2014-09-01 06:59:35 +00:00
$this->assertEquals( '|', WC_DELIMITER );
$this->assertNotEquals( WC_LOG_DIR, '' );
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() {
$this->wc->init();
$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 );
$this->assertInstanceOf( 'WC_Integrations', $this->wc->integrations );
2014-09-05 06:35:53 +00:00
$this->assertInstanceOf( 'WC_Mock_Session_Handler', $this->wc->session );
2014-09-01 06:59:35 +00:00
$this->assertInstanceOf( 'WC_Cart', $this->wc->cart );
$this->assertInstanceOf( 'WC_Customer', $this->wc->customer );
}
}