Skip to content

Commit 1507bee

Browse files
committed
Fix PHPCS violations in PHPUnit connector tests.
Align array and call indentation via PHPCBF, fix Yoda conditions, and correct assignment alignment for lint-tests.
1 parent aeaf5d9 commit 1507bee

4 files changed

Lines changed: 74 additions & 76 deletions

File tree

‎tests/phpunit/connectors/Connector_Comments_Test.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function test_callback_wp_insert_comment() {
6464
}
6565

6666
public function test_callback_wp_insert_comment_reply() {
67-
$post_id = wp_insert_post(
67+
$post_id = wp_insert_post(
6868
array(
6969
'post_title' => 'Test post',
7070
'post_content' => 'Lorem ipsum dolor...',

‎tests/phpunit/connectors/Connector_Media_Test.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function assert_add_attachment_no_parent_context( $context ): bool
6464
}
6565

6666
public function test_callback_add_attachment_with_parent() {
67-
$post_id = self::factory()->post->create( array( 'post_title' => 'Test post' ) );
67+
$post_id = self::factory()->post->create( array( 'post_title' => 'Test post' ) );
6868
self::$expected_parent_id = $post_id;
6969

7070
$this->mock->expects( $this->once() )
@@ -112,7 +112,7 @@ public static function assert_add_attachment_with_parent_context( $context ): bo
112112
return is_array( $context )
113113
&& 'Document one' === ( $context['name'] ?? null )
114114
&& 'Test post' === ( $context['parent_title'] ?? null )
115-
&& self::$expected_parent_id === ( $context['parent_id'] ?? null );
115+
&& ( $context['parent_id'] ?? null ) === self::$expected_parent_id;
116116
}
117117

118118
public function test_callback_add_attachment_with_invalid_parent() {

‎tests/phpunit/connectors/Connector_Posts_Test.php‎

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ public function setUp(): void {
4848
*/
4949
public function test_callback_transition_post_status_drafted() {
5050

51-
5251
self::$expected_post_context = array(
53-
'post_title' => 'Test post',
54-
'singular_name' => 'post',
55-
'new_status' => 'draft',
56-
'old_status' => 'new',
57-
);
52+
'post_title' => 'Test post',
53+
'singular_name' => 'post',
54+
'new_status' => 'draft',
55+
'old_status' => 'new',
56+
);
5857

5958
$this->mock->expects( $this->once() )
6059
->method( 'log' )
@@ -89,7 +88,7 @@ public function test_callback_transition_post_status_drafted() {
8988
* Tests transition_post_status: published.
9089
*/
9190
public function test_callback_transition_post_status_published() {
92-
$post_id = wp_insert_post(
91+
$post_id = wp_insert_post(
9392
array(
9493
'post_title' => 'Test post',
9594
'post_content' => 'Lorem ipsum dolor...',
@@ -100,11 +99,11 @@ public function test_callback_transition_post_status_published() {
10099
);
101100

102101
self::$expected_post_context = array(
103-
'post_title' => 'Test post',
104-
'singular_name' => 'post',
105-
'new_status' => 'publish',
106-
'old_status' => 'draft',
107-
);
102+
'post_title' => 'Test post',
103+
'singular_name' => 'post',
104+
'new_status' => 'publish',
105+
'old_status' => 'draft',
106+
);
108107

109108
$this->mock->expects( $this->once() )
110109
->method( 'log' )
@@ -136,7 +135,7 @@ public function test_callback_transition_post_status_published() {
136135
* Tests transition_post_status: unpublished.
137136
*/
138137
public function test_callback_transition_post_status_unpublished() {
139-
$post_id = wp_insert_post(
138+
$post_id = wp_insert_post(
140139
array(
141140
'post_title' => 'Test post',
142141
'post_content' => 'Lorem ipsum dolor...',
@@ -147,11 +146,11 @@ public function test_callback_transition_post_status_unpublished() {
147146
);
148147

149148
self::$expected_post_context = array(
150-
'post_title' => 'Test post',
151-
'singular_name' => 'post',
152-
'new_status' => 'draft',
153-
'old_status' => 'publish',
154-
);
149+
'post_title' => 'Test post',
150+
'singular_name' => 'post',
151+
'new_status' => 'draft',
152+
'old_status' => 'publish',
153+
);
155154

156155
$this->mock->expects( $this->once() )
157156
->method( 'log' )
@@ -183,7 +182,7 @@ public function test_callback_transition_post_status_unpublished() {
183182
* Tests transition_post_status: draft_saved.
184183
*/
185184
public function test_callback_transition_post_status_draft_saved() {
186-
$post_id = wp_insert_post(
185+
$post_id = wp_insert_post(
187186
array(
188187
'post_title' => 'Test post',
189188
'post_content' => 'Lorem ipsum dolor...',
@@ -194,11 +193,11 @@ public function test_callback_transition_post_status_draft_saved() {
194193
);
195194

196195
self::$expected_post_context = array(
197-
'post_title' => 'Test post',
198-
'singular_name' => 'post',
199-
'new_status' => 'draft',
200-
'old_status' => 'draft',
201-
);
196+
'post_title' => 'Test post',
197+
'singular_name' => 'post',
198+
'new_status' => 'draft',
199+
'old_status' => 'draft',
200+
);
202201

203202
$this->mock->expects( $this->once() )
204203
->method( 'log' )
@@ -230,7 +229,7 @@ public function test_callback_transition_post_status_draft_saved() {
230229
* Tests transition_post_status: pending.
231230
*/
232231
public function test_callback_transition_post_status_pending() {
233-
$post_id = wp_insert_post(
232+
$post_id = wp_insert_post(
234233
array(
235234
'post_title' => 'Test post',
236235
'post_content' => 'Lorem ipsum dolor...',
@@ -241,11 +240,11 @@ public function test_callback_transition_post_status_pending() {
241240
);
242241

243242
self::$expected_post_context = array(
244-
'post_title' => 'Test post',
245-
'singular_name' => 'post',
246-
'new_status' => 'pending',
247-
'old_status' => 'draft',
248-
);
243+
'post_title' => 'Test post',
244+
'singular_name' => 'post',
245+
'new_status' => 'pending',
246+
'old_status' => 'draft',
247+
);
249248

250249
$this->mock->expects( $this->once() )
251250
->method( 'log' )
@@ -277,7 +276,7 @@ public function test_callback_transition_post_status_pending() {
277276
* Tests transition_post_status: scheduled.
278277
*/
279278
public function test_callback_transition_post_status_scheduled() {
280-
$post_id = wp_insert_post(
279+
$post_id = wp_insert_post(
281280
array(
282281
'post_title' => 'Test post',
283282
'post_content' => 'Lorem ipsum dolor...',
@@ -288,11 +287,11 @@ public function test_callback_transition_post_status_scheduled() {
288287
);
289288

290289
self::$expected_post_context = array(
291-
'post_title' => 'Test post',
292-
'singular_name' => 'post',
293-
'new_status' => 'future',
294-
'old_status' => 'pending',
295-
);
290+
'post_title' => 'Test post',
291+
'singular_name' => 'post',
292+
'new_status' => 'future',
293+
'old_status' => 'pending',
294+
);
296295

297296
$this->mock->expects( $this->once() )
298297
->method( 'log' )
@@ -327,7 +326,7 @@ public function test_callback_transition_post_status_scheduled() {
327326
* Tests transition_post_status: scheduled_published.
328327
*/
329328
public function test_callback_transition_post_status_scheduled_published() {
330-
$time = strtotime( 'tomorrow' );
329+
$time = strtotime( 'tomorrow' );
331330
$post_id = wp_insert_post(
332331
array(
333332
'post_title' => 'Test post',
@@ -339,11 +338,11 @@ public function test_callback_transition_post_status_scheduled_published() {
339338
);
340339

341340
self::$expected_post_context = array(
342-
'post_title' => 'Test post',
343-
'singular_name' => 'post',
344-
'new_status' => 'publish',
345-
'old_status' => 'future',
346-
);
341+
'post_title' => 'Test post',
342+
'singular_name' => 'post',
343+
'new_status' => 'publish',
344+
'old_status' => 'future',
345+
);
347346

348347
$this->mock->expects( $this->once() )
349348
->method( 'log' )
@@ -378,7 +377,7 @@ public function test_callback_transition_post_status_scheduled_published() {
378377
* Tests transition_post_status: private.
379378
*/
380379
public function test_callback_transition_post_status_private() {
381-
$post_id = wp_insert_post(
380+
$post_id = wp_insert_post(
382381
array(
383382
'post_title' => 'Test post',
384383
'post_content' => 'Lorem ipsum dolor...',
@@ -389,11 +388,11 @@ public function test_callback_transition_post_status_private() {
389388
);
390389

391390
self::$expected_post_context = array(
392-
'post_title' => 'Test post',
393-
'singular_name' => 'post',
394-
'new_status' => 'private',
395-
'old_status' => 'publish',
396-
);
391+
'post_title' => 'Test post',
392+
'singular_name' => 'post',
393+
'new_status' => 'private',
394+
'old_status' => 'publish',
395+
);
397396

398397
$this->mock->expects( $this->once() )
399398
->method( 'log' )
@@ -425,7 +424,7 @@ public function test_callback_transition_post_status_private() {
425424
* Tests transition_post_status: trashed.
426425
*/
427426
public function test_callback_transition_post_status_trashed() {
428-
$post_id = wp_insert_post(
427+
$post_id = wp_insert_post(
429428
array(
430429
'post_title' => 'Test post',
431430
'post_content' => 'Lorem ipsum dolor...',
@@ -436,11 +435,11 @@ public function test_callback_transition_post_status_trashed() {
436435
);
437436

438437
self::$expected_post_context = array(
439-
'post_title' => 'Test post',
440-
'singular_name' => 'post',
441-
'new_status' => 'trash',
442-
'old_status' => 'private',
443-
);
438+
'post_title' => 'Test post',
439+
'singular_name' => 'post',
440+
'new_status' => 'trash',
441+
'old_status' => 'private',
442+
);
444443

445444
$this->mock->expects( $this->once() )
446445
->method( 'log' )
@@ -472,7 +471,7 @@ public function test_callback_transition_post_status_trashed() {
472471
* Tests transition_post_status: untrashed.
473472
*/
474473
public function test_callback_transition_post_status_untrashed() {
475-
$post_id = wp_insert_post(
474+
$post_id = wp_insert_post(
476475
array(
477476
'post_title' => 'Test post',
478477
'post_content' => 'Lorem ipsum dolor...',
@@ -483,11 +482,11 @@ public function test_callback_transition_post_status_untrashed() {
483482
);
484483

485484
self::$expected_post_context = array(
486-
'post_title' => 'Test post',
487-
'singular_name' => 'post',
488-
'new_status' => 'publish',
489-
'old_status' => 'trash',
490-
);
485+
'post_title' => 'Test post',
486+
'singular_name' => 'post',
487+
'new_status' => 'publish',
488+
'old_status' => 'trash',
489+
);
491490

492491
$this->mock->expects( $this->once() )
493492
->method( 'log' )
@@ -519,7 +518,7 @@ public function test_callback_transition_post_status_untrashed() {
519518
* Tests transition_post_status: updated.
520519
*/
521520
public function test_callback_transition_post_status_updated() {
522-
$post_id = wp_insert_post(
521+
$post_id = wp_insert_post(
523522
array(
524523
'post_title' => 'Test post',
525524
'post_content' => 'Lorem ipsum dolor...',
@@ -530,11 +529,11 @@ public function test_callback_transition_post_status_updated() {
530529
);
531530

532531
self::$expected_post_context = array(
533-
'post_title' => 'Test post',
534-
'singular_name' => 'post',
535-
'new_status' => 'publish',
536-
'old_status' => 'publish',
537-
);
532+
'post_title' => 'Test post',
533+
'singular_name' => 'post',
534+
'new_status' => 'publish',
535+
'old_status' => 'publish',
536+
);
538537

539538
$this->mock->expects( $this->once() )
540539
->method( 'log' )
@@ -567,13 +566,12 @@ public function test_callback_transition_post_status_updated() {
567566
*/
568567
public function test_callback_transition_post_status_created_published() {
569568

570-
571569
self::$expected_post_context = array(
572-
'post_title' => 'Test post',
573-
'singular_name' => 'post',
574-
'new_status' => 'publish',
575-
'old_status' => 'new',
576-
);
570+
'post_title' => 'Test post',
571+
'singular_name' => 'post',
572+
'new_status' => 'publish',
573+
'old_status' => 'new',
574+
);
577575

578576
$this->mock->expects( $this->once() )
579577
->method( 'log' )

‎tests/phpunit/connectors/Connector_Settings_Test.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function test_non_secret_setting_is_not_redacted() {
290290
*/
291291
public static function assert_mailserver_login_not_redacted( $logged ): bool {
292292
return is_array( $logged )
293-
&& self::$expected_mailserver_login_old === ( $logged['old_value'] ?? null )
293+
&& ( $logged['old_value'] ?? null ) === self::$expected_mailserver_login_old
294294
&& 'new-login' === ( $logged['value'] ?? null )
295295
&& '' !== ( $logged['value'] ?? null );
296296
}

0 commit comments

Comments
 (0)