2019-11-27 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Unit tests for the shipping class.
|
|
|
|
*
|
|
|
|
* @package WooCommerce\Tests\Shipping
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_Tests_Shipping tests.
|
|
|
|
*
|
|
|
|
* @package WooCommerce\Tests\Shipping
|
2020-01-31 17:03:54 +00:00
|
|
|
* @since 4.0.0
|
2019-11-27 16:15:54 +00:00
|
|
|
*/
|
|
|
|
class WC_Tests_Shipping extends WC_Unit_Test_Case {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that whether or not a package is shippable is evaluated correctly.
|
|
|
|
*
|
2020-01-31 17:03:54 +00:00
|
|
|
* @since 4.0.0
|
2019-11-27 16:15:54 +00:00
|
|
|
*/
|
|
|
|
public function test_is_package_shippable() {
|
|
|
|
$shipping = new WC_Shipping();
|
|
|
|
|
2020-03-13 16:15:31 +00:00
|
|
|
// Success for no country.
|
2019-11-27 16:15:54 +00:00
|
|
|
$result = $shipping->is_package_shippable(
|
|
|
|
array(
|
|
|
|
'destination' => array(
|
|
|
|
'country' => '',
|
|
|
|
'state' => 'CA',
|
|
|
|
'postcode' => '99999',
|
|
|
|
'address' => '',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
2020-03-13 16:15:31 +00:00
|
|
|
$this->assertTrue( $result );
|
2019-11-27 16:15:54 +00:00
|
|
|
|
|
|
|
// Failure for disallowed country.
|
|
|
|
$result = $shipping->is_package_shippable(
|
|
|
|
array(
|
|
|
|
'destination' => array(
|
|
|
|
'country' => 'TEST',
|
|
|
|
'state' => 'CA',
|
|
|
|
'postcode' => '99999',
|
|
|
|
'address' => '',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->assertFalse( $result );
|
|
|
|
|
2020-03-13 16:15:31 +00:00
|
|
|
// Success for correct country.
|
2019-11-27 16:15:54 +00:00
|
|
|
$result = $shipping->is_package_shippable(
|
|
|
|
array(
|
|
|
|
'destination' => array(
|
|
|
|
'country' => 'US',
|
|
|
|
'state' => '',
|
2020-03-13 16:15:31 +00:00
|
|
|
'postcode' => '',
|
2019-11-27 16:15:54 +00:00
|
|
|
'address' => '',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->assertTrue( $result );
|
|
|
|
}
|
|
|
|
}
|