This commit is contained in:
Mike Jolley 2019-02-07 20:35:45 +00:00
parent dca47d5d14
commit 0e21b3f4ce
1 changed files with 13 additions and 9 deletions

View File

@ -4,6 +4,10 @@
*
* @package WooCommerce\Tests\Gateways\Paypal
*/
/**
* Class WC_Tests_Paypal_Gateway_Request.
*/
class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
/**
@ -96,7 +100,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
* @param array $product_prices Array of prices to use for created products. Leave empty for default prices.
* @param bool $calc_order_totals Whether the WC_Order::calculate_totals() should be triggered when creating order.
* @return string
* @throws WC_Data_Exception
* @throws WC_Data_Exception Exception on failure.
*/
protected function get_request_url( $product_count, $testmode, $product_prices = array(), $calc_order_totals = true ) {
// Create products.
@ -179,7 +183,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
*
* @param bool $shipping_tax_included Whether the shipping tax should be included or not.
* @param bool $testmode Whether to use Paypal sandbox.
* @throws WC_Data_Exception
* @throws WC_Data_Exception Exception on failure.
*/
protected function check_large_order( $shipping_tax_included, $testmode ) {
$request_url = $this->get_request_url( 30, $testmode );
@ -198,7 +202,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
$query_array = array();
parse_str( $query_string, $query_array );
foreach ( $fields_limited_to_127_chars as $field_name ) {
$this->assertLessThanOrEqual( 127, strlen( $query_array[ $field_name ] ) );
$this->assertLessThanOrEqual( 127, mb_strlen( $query_array[ $field_name ] ) );
}
// Check that there is actually only one item for order with URL length > limit.
@ -230,7 +234,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
* @param bool $testmode Whether to use Paypal sandbox.
* @param array $product_prices Array of prices to use for created products. Leave empty for default prices.
* @param bool $calc_order_totals Whether the WC_Order::calculate_totals() should be triggered when creating order.
* @throws WC_Data_Exception
* @throws WC_Data_Exception Exception on failure.
*/
protected function check_small_order( $product_count, $shipping_tax_included, $testmode, $product_prices = array(), $calc_order_totals = true ) {
$request_url = $this->get_request_url( $product_count, $testmode, $product_prices, $calc_order_totals );
@ -258,8 +262,8 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
$this->assertTrue( array_key_exists( 'cmd', $query_array ) );
$this->assertEquals( '_cart', $query_array['cmd'] );
$this->assertLessThanOrEqual( 127, strlen( $query_array[ 'item_name_' . $i ] ) );
$this->assertLessThanOrEqual( 127, strlen( $query_array[ 'item_number_' . $i ] ) );
$this->assertLessThanOrEqual( 127, mb_strlen( $query_array[ 'item_name_' . $i ] ) );
$this->assertLessThanOrEqual( 127, mb_strlen( $query_array[ 'item_number_' . $i ] ) );
}
@ -272,7 +276,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
* will return false.
*
* @param bool $testmode Whether PayPal request should point to sandbox or live production.
* @throws WC_Data_Exception
* @throws WC_Data_Exception Exception on failure.
*/
protected function check_negative_amount( $testmode ) {
$shipping_tax_included = true;
@ -286,7 +290,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
* will return false.
*
* @param bool $testmode Whether PayPal request should point to sandbox or live production.
* @throws WC_Data_Exception
* @throws WC_Data_Exception Exception on failure.
*/
protected function check_totals_mismatch( $testmode ) {
// totals mismatch forces tax inclusion and single line item.
@ -298,7 +302,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
* Test for request_url() method.
*
* @group timeout
* @throws WC_Data_Exception
* @throws WC_Data_Exception Exception on failure.
*/
public function test_request_url() {
// User set up.