Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for WP 6.1 #5049

Merged
merged 7 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-wp-6.1-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Fix tests with WordPress 6.1
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class WC_REST_Payments_Settings_Controller_Test extends WCPAY_UnitTestCase {
*/
private $mock_db_cache;

/**
* Mock WC_Payments_Token_Service.
*
* @var WC_Payments_Token_Service
*/
private $mock_token_service;

/**
* Pre-test setup
*/
Expand All @@ -101,6 +108,7 @@ public function set_up() {
$action_scheduler_service = new WC_Payments_Action_Scheduler_Service( $this->mock_api_client );
$mock_rate_limiter = $this->createMock( Session_Rate_Limiter::class );
$order_service = new WC_Payments_Order_Service( $this->mock_api_client );
$this->mock_token_service = $this->createMock( 'WC_Payments_Token_Service' );
RadoslavGeorgiev marked this conversation as resolved.
Show resolved Hide resolved

$this->gateway = new WC_Payment_Gateway_WCPay(
$this->mock_api_client,
Expand All @@ -126,6 +134,7 @@ public function set_up() {
Ideal_Payment_Method::class,
Link_Payment_Method::class,
];

foreach ( $payment_method_classes as $payment_method_class ) {
$mock_payment_method = $this->getMockBuilder( $payment_method_class )
->setConstructorArgs( [ $this->mock_token_service ] )
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test-class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ class WC_Payment_Gateway_WCPay_Test extends WCPAY_UnitTestCase {
*/
private $payments_checkout;

/**
* @var string
*/
private $mock_charge_id = 'ch_mock';

/**
* @var integer
*/
private $mock_charge_created = 1653076178;

/**
* Pre-test setup
*/
Expand Down
43 changes: 43 additions & 0 deletions tests/unit/test-class-wc-payments-webhook-processing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,11 @@ public function test_payment_intent_successful_and_completes_order() {

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->exactly( 5 ) )
->method( 'update_meta_data' )
Expand Down Expand Up @@ -614,6 +619,11 @@ public function test_payment_intent_successful_and_completes_order_without_inten

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->exactly( 5 ) )
->method( 'update_meta_data' )
Expand Down Expand Up @@ -691,6 +701,11 @@ public function test_payment_intent_successful_when_retrying() {

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->exactly( 4 ) )
->method( 'update_meta_data' )
Expand Down Expand Up @@ -773,6 +788,11 @@ public function test_payment_intent_successful_and_send_card_reader_receipt() {

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->exactly( 2 ) )
->method( 'has_status' )
Expand Down Expand Up @@ -848,6 +868,11 @@ public function test_payment_intent_fails_and_fails_order() {

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->exactly( 2 ) )
->method( 'get_meta' )
Expand Down Expand Up @@ -911,6 +936,12 @@ public function test_dispute_created_order_note() {
];

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->once() )
->method( 'add_order_note' )
Expand Down Expand Up @@ -948,6 +979,12 @@ public function test_dispute_closed_order_note() {
];

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->once() )
->method( 'add_order_note' )
Expand Down Expand Up @@ -984,6 +1021,12 @@ public function test_dispute_updated_order_note() {
];

$mock_order = $this->createMock( WC_Order::class );

$mock_order
->expects( $this->any() )
->method( 'get_id' )
->willReturn( 1234 );

$mock_order
->expects( $this->once() )
->method( 'add_order_note' )
Expand Down