Skip to content

Commit bf9ad0b

Browse files
committed
phpunit: fix warnings from deprecated getMock() method
1 parent 0de1374 commit bf9ad0b

File tree

1 file changed

+72
-78
lines changed

1 file changed

+72
-78
lines changed

tests/phpunit/tests/classes/query.php

Lines changed: 72 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,10 @@ public function test_cache_not_set_if_error() {
910910
, 'WordPoints_Top_Users_In_Period_PHPUnit_Mock_Query_Cache'
911911
);
912912

913-
$stub = $this->getMock(
914-
'WordPoints_Top_Users_In_Period_Query'
915-
, array( 'get_sql_for_both' )
916-
, array( new DateTime( '-1 months' ) )
917-
);
913+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
914+
->setMethods( array( 'get_sql_for_both' ) )
915+
->setConstructorArgs( array( new DateTime( '-1 months' ) ) )
916+
->getMock();
918917

919918
$stub->method( 'get_sql_for_both' )
920919
->willReturn( new WP_Error() );
@@ -932,11 +931,10 @@ public function test_cache_not_set_if_error() {
932931
*/
933932
public function test_should_not_use_block_logs() {
934933

935-
$stub = $this->getMock(
936-
'WordPoints_Top_Users_In_Period_Query'
937-
, array( 'get_sql_for_points_logs' )
938-
, array( new DateTime( '-1 day' ) )
939-
);
934+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
935+
->setMethods( array( 'get_sql_for_points_logs' ) )
936+
->setConstructorArgs( array( new DateTime( '-1 day' ) ) )
937+
->getMock();
940938

941939
$stub->expects( $this->once() )
942940
->method( 'get_sql_for_points_logs' )
@@ -952,11 +950,10 @@ public function test_should_not_use_block_logs() {
952950
*/
953951
public function test_should_use_block_logs() {
954952

955-
$stub = $this->getMock(
956-
'WordPoints_Top_Users_In_Period_Query'
957-
, array( 'get_sql_for_both' )
958-
, array( new DateTime( '-1 month' ) )
959-
);
953+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
954+
->setMethods( array( 'get_sql_for_both' ) )
955+
->setConstructorArgs( array( new DateTime( '-1 month' ) ) )
956+
->getMock();
960957

961958
$stub->expects( $this->once() )
962959
->method( 'get_sql_for_both' )
@@ -977,11 +974,10 @@ public function test_should_use_block_logs_filter() {
977974
, '__return_true'
978975
);
979976

980-
$stub = $this->getMock(
981-
'WordPoints_Top_Users_In_Period_Query'
982-
, array( 'get_sql_for_both' )
983-
, array( new DateTime( '-1 day' ) )
984-
);
977+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
978+
->setMethods( array( 'get_sql_for_both' ) )
979+
->setConstructorArgs( array( new DateTime( '-1 day' ) ) )
980+
->getMock();
985981

986982
$stub->expects( $this->once() )
987983
->method( 'get_sql_for_both' )
@@ -1002,11 +998,10 @@ public function test_should_use_block_logs_filter_disable() {
1002998
, '__return_false'
1003999
);
10041000

1005-
$stub = $this->getMock(
1006-
'WordPoints_Top_Users_In_Period_Query'
1007-
, array( 'get_sql_for_points_logs' )
1008-
, array( new DateTime( '-1 month' ) )
1009-
);
1001+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
1002+
->setMethods( array( 'get_sql_for_points_logs' ) )
1003+
->setConstructorArgs( array( new DateTime( '-1 month' ) ) )
1004+
->getMock();
10101005

10111006
$stub->expects( $this->once() )
10121007
->method( 'get_sql_for_points_logs' )
@@ -1029,14 +1024,15 @@ public function test_should_use_block_logs_two_blocks() {
10291024
$second_info = $block->get_block_info( current_time( 'timestamp' ) );
10301025
$first_info = $block->get_block_info( $second_info['start'] - 1 );
10311026

1032-
$stub = $this->getMock(
1033-
'WordPoints_Top_Users_In_Period_Query'
1034-
, array( 'get_sql_for_both' )
1035-
, array(
1036-
new DateTime( '@' . $first_info['start'] ),
1037-
new DateTime( '@' . ( $second_info['end'] - 50 ) ),
1027+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
1028+
->setMethods( array( 'get_sql_for_both' ) )
1029+
->setConstructorArgs(
1030+
array(
1031+
new DateTime( '@' . $first_info['start'] ),
1032+
new DateTime( '@' . ( $second_info['end'] - 50 ) ),
1033+
)
10381034
)
1039-
);
1035+
->getMock();
10401036

10411037
$stub->expects( $this->once() )
10421038
->method( 'get_sql_for_both' )
@@ -1059,14 +1055,15 @@ public function test_should_use_block_logs_two_blocks_end() {
10591055
$second_info = $block->get_block_info( current_time( 'timestamp' ) );
10601056
$first_info = $block->get_block_info( $second_info['start'] - 1 );
10611057

1062-
$stub = $this->getMock(
1063-
'WordPoints_Top_Users_In_Period_Query'
1064-
, array( 'get_sql_for_both' )
1065-
, array(
1066-
new DateTime( '@' . ( $first_info['start'] + 50 ) ),
1067-
new DateTime( '@' . $second_info['end'] ),
1058+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
1059+
->setMethods( array( 'get_sql_for_both' ) )
1060+
->setConstructorArgs(
1061+
array(
1062+
new DateTime( '@' . ( $first_info['start'] + 50 ) ),
1063+
new DateTime( '@' . $second_info['end'] ),
1064+
)
10681065
)
1069-
);
1066+
->getMock();
10701067

10711068
$stub->expects( $this->once() )
10721069
->method( 'get_sql_for_both' )
@@ -1088,14 +1085,15 @@ public function test_should_use_block_logs_only_one_block() {
10881085

10891086
$info = $block->get_block_info( current_time( 'timestamp' ) );
10901087

1091-
$stub = $this->getMock(
1092-
'WordPoints_Top_Users_In_Period_Query'
1093-
, array( 'get_sql_for_block_logs' )
1094-
, array(
1095-
new DateTime( '@' . $info['start'] ),
1096-
new DateTime( '@' . $info['end'] ),
1088+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
1089+
->setMethods( array( 'get_sql_for_block_logs' ) )
1090+
->setConstructorArgs(
1091+
array(
1092+
new DateTime( '@' . $info['start'] ),
1093+
new DateTime( '@' . $info['end'] ),
1094+
)
10971095
)
1098-
);
1096+
->getMock();
10991097

11001098
$stub->expects( $this->once() )
11011099
->method( 'get_sql_for_block_logs' )
@@ -1120,14 +1118,15 @@ public function test_should_use_block_logs_only_multiple_blocks() {
11201118
$end_info['start'] - 2 * WEEK_IN_SECONDS
11211119
);
11221120

1123-
$stub = $this->getMock(
1124-
'WordPoints_Top_Users_In_Period_Query'
1125-
, array( 'get_sql_for_block_logs' )
1126-
, array(
1127-
new DateTime( '@' . $start_info['start'] ),
1128-
new DateTime( '@' . $end_info['end'] ),
1121+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
1122+
->setMethods( array( 'get_sql_for_block_logs' ) )
1123+
->setConstructorArgs(
1124+
array(
1125+
new DateTime( '@' . $start_info['start'] ),
1126+
new DateTime( '@' . $end_info['end'] ),
1127+
)
11291128
)
1130-
);
1129+
->getMock();
11311130

11321131
$stub->expects( $this->once() )
11331132
->method( 'get_sql_for_block_logs' )
@@ -2420,11 +2419,10 @@ public function test_arg_blog_id(
24202419
*/
24212420
public function test_get_sql_for_block_logs_error() {
24222421

2423-
$stub = $this->getMock(
2424-
'WordPoints_Top_Users_In_Period_Query'
2425-
, array( 'get_and_verify_blocks' )
2426-
, array( new DateTime( '-1 months' ) )
2427-
);
2422+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
2423+
->setMethods( array( 'get_and_verify_blocks' ) )
2424+
->setConstructorArgs( array( new DateTime( '-1 months' ) ) )
2425+
->getMock();
24282426

24292427
$error = new WP_Error();
24302428

@@ -2441,11 +2439,10 @@ public function test_get_sql_for_block_logs_error() {
24412439
*/
24422440
public function test_get_and_verify_blocks_get_blocks_error() {
24432441

2444-
$stub = $this->getMock(
2445-
'WordPoints_Top_Users_In_Period_Query'
2446-
, array( 'get_blocks' )
2447-
, array( new DateTime( '-1 months' ) )
2448-
);
2442+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
2443+
->setMethods( array( 'get_blocks' ) )
2444+
->setConstructorArgs( array( new DateTime( '-1 months' ) ) )
2445+
->getMock();
24492446

24502447
$error = new WP_Error();
24512448

@@ -2507,11 +2504,10 @@ public function test_get_and_verify_blocks_draft_blocks() {
25072504
*/
25082505
public function test_get_blocks_error() {
25092506

2510-
$stub = $this->getMock(
2511-
'WordPoints_Top_Users_In_Period_Query'
2512-
, array( 'get_query_signature_id' )
2513-
, array( new DateTime( '-1 months' ) )
2514-
);
2507+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
2508+
->setMethods( array( 'get_query_signature_id' ) )
2509+
->setConstructorArgs( array( new DateTime( '-1 months' ) ) )
2510+
->getMock();
25152511

25162512
$stub->method( 'get_query_signature_id' )
25172513
->willReturn( false );
@@ -2705,11 +2701,10 @@ public function test_get_blocks_outside_period() {
27052701
*/
27062702
public function test_get_and_verify_blocks_failed_filling_block_logs() {
27072703

2708-
$stub = $this->getMock(
2709-
'WordPoints_Top_Users_In_Period_Query'
2710-
, array( 'fill_block_logs' )
2711-
, array( new DateTime( '-1 months' ) )
2712-
);
2704+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
2705+
->setMethods( array( 'fill_block_logs' ) )
2706+
->setConstructorArgs( array( new DateTime( '-1 months' ) ) )
2707+
->getMock();
27132708

27142709
$stub->method( 'fill_block_logs' )->willReturn( false );
27152710

@@ -2993,11 +2988,10 @@ public function data_provider_blocks() {
29932988
*/
29942989
public function test_fill_block_logs_error_saving_draft_block() {
29952990

2996-
$stub = $this->getMock(
2997-
'WordPoints_Top_Users_In_Period_Query'
2998-
, array( 'save_draft_block' )
2999-
, array( new DateTime( '-1 month' ) )
3000-
);
2991+
$stub = $this->getMockBuilder( 'WordPoints_Top_Users_In_Period_Query' )
2992+
->setMethods( array( 'save_draft_block' ) )
2993+
->setConstructorArgs( array( new DateTime( '-1 month' ) ) )
2994+
->getMock();
30012995

30022996
$stub->method( 'save_draft_block' )->willReturn( false );
30032997

0 commit comments

Comments
 (0)