Skip to content

Commit 7066556

Browse files
authored
Merge pull request #826 from Kit/tests-use-named-arguments-2
Tests: Use Named Arguments, Part 2
2 parents e3bfd8b + da6c814 commit 7066556

39 files changed

Lines changed: 1725 additions & 787 deletions

tests/EndToEnd/forms/post-types/CPTFormCest.php

Lines changed: 130 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public function testAccessibility(EndToEndTester $I)
6464
public function testNoOptionsOrOutputOnPrivateCustomPostType(EndToEndTester $I)
6565
{
6666
// Add a Private CPT using the Gutenberg editor.
67-
$I->addGutenbergPage($I, 'private', 'Kit: Private: Form: None');
67+
$I->addGutenbergPage(
68+
$I,
69+
postType: 'private',
70+
title: 'Kit: Private: Form: None'
71+
);
6872

6973
// Check that the metabox is not displayed.
7074
$I->dontSeeElementInDOM('#wp-convertkit-meta-box');
@@ -128,7 +132,11 @@ public function testAddNewCPTUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin(
128132
$I->setupKitPluginResources($I);
129133

130134
// Add a CPT using the Gutenberg editor.
131-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: None');
135+
$I->addGutenbergPage(
136+
$I,
137+
postType: 'article',
138+
title: 'Kit: CPT: Form: Default: None'
139+
);
132140

133141
// Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms.
134142
$I->checkSelectFormOptionOrder(
@@ -143,8 +151,8 @@ public function testAddNewCPTUsingDefaultFormWithNoDefaultFormSpecifiedInPlugin(
143151
// Configure metabox's Form setting = Default.
144152
$I->configureMetaboxSettings(
145153
$I,
146-
'wp-convertkit-meta-box',
147-
[
154+
metabox: 'wp-convertkit-meta-box',
155+
configuration: [
148156
'form' => [ 'select2', 'Default' ],
149157
]
150158
);
@@ -176,13 +184,17 @@ public function testAddNewCPTUsingDefaultForm(EndToEndTester $I)
176184
$I->setupKitPluginResources($I);
177185

178186
// Add a CPT using the Gutenberg editor.
179-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default');
187+
$I->addGutenbergPage(
188+
$I,
189+
postType: 'article',
190+
title: 'Kit: CPT: Form: Default'
191+
);
180192

181193
// Configure metabox's Form setting = Default.
182194
$I->configureMetaboxSettings(
183195
$I,
184-
'wp-convertkit-meta-box',
185-
[
196+
metabox: 'wp-convertkit-meta-box',
197+
configuration: [
186198
'form' => [ 'select2', 'Default' ],
187199
]
188200
);
@@ -217,16 +229,20 @@ public function testAddNewCPTUsingDefaultFormBeforeContent(EndToEndTester $I)
217229
$I->setupKitPluginResources($I);
218230

219231
// Add a CPT using the Gutenberg editor.
220-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: Before Content');
232+
$I->addGutenbergPage(
233+
$I,
234+
postType: 'article',
235+
title: 'Kit: CPT: Form: Default: Before Content'
236+
);
221237

222238
// Add paragraph to CPT.
223239
$I->addGutenbergParagraphBlock($I, 'CPT content');
224240

225241
// Configure metabox's Form setting = Default.
226242
$I->configureMetaboxSettings(
227243
$I,
228-
'wp-convertkit-meta-box',
229-
[
244+
metabox: 'wp-convertkit-meta-box',
245+
configuration: [
230246
'form' => [ 'select2', 'Default' ],
231247
]
232248
);
@@ -261,16 +277,20 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste
261277
$I->setupKitPluginResources($I);
262278

263279
// Add a CPT using the Gutenberg editor.
264-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Default: Before and After Content');
280+
$I->addGutenbergPage(
281+
$I,
282+
postType: 'article',
283+
title: 'Kit: CPT: Form: Default: Before and After Content'
284+
);
265285

266286
// Add paragraph to CPT.
267287
$I->addGutenbergParagraphBlock($I, 'CPT content');
268288

269289
// Configure metabox's Form setting = Default.
270290
$I->configureMetaboxSettings(
271291
$I,
272-
'wp-convertkit-meta-box',
273-
[
292+
metabox: 'wp-convertkit-meta-box',
293+
configuration: [
274294
'form' => [ 'select2', 'Default' ],
275295
]
276296
);
@@ -279,7 +299,11 @@ public function testAddNewCPTUsingDefaultFormBeforeAndAfterContent(EndToEndTeste
279299
$I->publishAndViewGutenbergPage($I);
280300

281301
// Confirm that two Kit Forms are output in the DOM before and after the CPT content.
282-
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'before_after_content');
302+
$I->seeFormOutput(
303+
$I,
304+
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
305+
position: 'before_after_content'
306+
);
283307
}
284308

285309
/**
@@ -306,7 +330,11 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(EndToEndTeste
306330
$I->setupKitPluginResources($I);
307331

308332
// Setup Article with placeholder content.
309-
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 3rd Paragraph Element');
333+
$pageID = $I->addGutenbergPageToDatabase(
334+
$I,
335+
postType: 'article',
336+
title: 'Kit: CPT: Form: Default: After 3rd Paragraph Element'
337+
);
310338

311339
// View the CPT on the frontend site.
312340
$I->amOnPage('?p=' . $pageID);
@@ -315,7 +343,13 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(EndToEndTeste
315343
$I->checkNoWarningsAndNoticesOnScreen($I);
316344

317345
// Confirm that one Kit Form is output in the DOM after the third paragraph.
318-
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3);
346+
$I->seeFormOutput(
347+
$I,
348+
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
349+
position: 'after_element',
350+
element: 'p',
351+
elementIndex: 3
352+
);
319353

320354
// Confirm character encoding is not broken due to using DOMDocument.
321355
$I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium');
@@ -348,7 +382,11 @@ public function testAddNewCPTUsingDefaultNonInlineFormAfterParagraphElement(EndT
348382
$I->setupKitPluginResources($I);
349383

350384
// Setup CPT with placeholder content.
351-
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Non-Inline Form: Default: After 3rd Paragraph Element');
385+
$pageID = $I->addGutenbergPageToDatabase(
386+
$I,
387+
postType: 'article',
388+
title: 'Kit: CPT: Non-Inline Form: Default: After 3rd Paragraph Element'
389+
);
352390

353391
// View the Page on the frontend site.
354392
$I->amOnPage('?p=' . $pageID);
@@ -391,7 +429,11 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(EndToEndTester
391429
$I->setupKitPluginResources($I);
392430

393431
// Setup Article with placeholder content.
394-
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 2nd H2 Element');
432+
$pageID = $I->addGutenbergPageToDatabase(
433+
$I,
434+
postType: 'article',
435+
title: 'Kit: CPT: Form: Default: After 2nd H2 Element'
436+
);
395437

396438
// View the CPT on the frontend site.
397439
$I->amOnPage('?p=' . $pageID);
@@ -400,7 +442,13 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(EndToEndTester
400442
$I->checkNoWarningsAndNoticesOnScreen($I);
401443

402444
// Confirm that one Kit Form is output in the DOM after the second <h2> element.
403-
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2);
445+
$I->seeFormOutput(
446+
$I,
447+
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
448+
position: 'after_element',
449+
element: 'h2',
450+
elementIndex: 2
451+
);
404452

405453
// Confirm character encoding is not broken due to using DOMDocument.
406454
$I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium');
@@ -433,7 +481,11 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(EndToEndTester $I
433481
$I->setupKitPluginResources($I);
434482

435483
// Setup Article with placeholder content.
436-
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 2nd Image Element');
484+
$pageID = $I->addGutenbergPageToDatabase(
485+
$I,
486+
postType: 'article',
487+
title: 'Kit: CPT: Form: Default: After 2nd Image Element'
488+
);
437489

438490
// View the CPT on the frontend site.
439491
$I->amOnPage('?p=' . $pageID);
@@ -442,7 +494,13 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(EndToEndTester $I
442494
$I->checkNoWarningsAndNoticesOnScreen($I);
443495

444496
// Confirm that one Kit Form is output in the DOM after the second <img> element.
445-
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2);
497+
$I->seeFormOutput(
498+
$I,
499+
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
500+
position: 'after_element',
501+
element: 'img',
502+
elementIndex: 2
503+
);
446504

447505
// Confirm character encoding is not broken due to using DOMDocument.
448506
$I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium');
@@ -475,7 +533,11 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(EndToEndTes
475533
$I->setupKitPluginResources($I);
476534

477535
// Setup Article with placeholder content.
478-
$pageID = $I->addGutenbergPageToDatabase($I, 'article', 'Kit: CPT: Form: Default: After 9th Paragraph Element');
536+
$pageID = $I->addGutenbergPageToDatabase(
537+
$I,
538+
postType: 'article',
539+
title: 'Kit: CPT: Form: Default: After 9th Paragraph Element'
540+
);
479541

480542
// View the CPT on the frontend site.
481543
$I->amOnPage('?p=' . $pageID);
@@ -485,7 +547,11 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(EndToEndTes
485547

486548
// Confirm that one Kit Form is output in the DOM after the content, as
487549
// the number of paragraphs is less than the position.
488-
$I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content');
550+
$I->seeFormOutput(
551+
$I,
552+
formID: $_ENV['CONVERTKIT_API_FORM_ID'],
553+
position: 'after_content'
554+
);
489555

490556
// Confirm character encoding is not broken due to using DOMDocument.
491557
$I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium');
@@ -516,7 +582,11 @@ public function testAddNewCPTUsingDefaultLegacyForm(EndToEndTester $I)
516582
$I->setupKitPluginResources($I);
517583

518584
// Add a CPT using the Gutenberg editor.
519-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: Legacy: Default');
585+
$I->addGutenbergPage(
586+
$I,
587+
postType: 'article',
588+
title: 'Kit: CPT: Form: Legacy: Default'
589+
);
520590

521591
// Configure metabox's Form setting = Default.
522592
$I->configureMetaboxSettings(
@@ -554,13 +624,17 @@ public function testAddNewCPTUsingNoForm(EndToEndTester $I)
554624
$I->setupKitPluginResources($I);
555625

556626
// Add a CPT using the Gutenberg editor.
557-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: None');
627+
$I->addGutenbergPage(
628+
$I,
629+
postType: 'article',
630+
title: 'Kit: CPT: Form: None'
631+
);
558632

559633
// Configure metabox's Form setting = None.
560634
$I->configureMetaboxSettings(
561635
$I,
562-
'wp-convertkit-meta-box',
563-
[
636+
metabox: 'wp-convertkit-meta-box',
637+
configuration: [
564638
'form' => [ 'select2', 'None' ],
565639
]
566640
);
@@ -592,13 +666,17 @@ public function testAddNewCPTUsingDefinedForm(EndToEndTester $I)
592666
$I->setupKitPluginResources($I);
593667

594668
// Add a CPT using the Gutenberg editor.
595-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']);
669+
$I->addGutenbergPage(
670+
$I,
671+
postType: 'article',
672+
title: 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_FORM_NAME']
673+
);
596674

597675
// Configure metabox's Form setting = None.
598676
$I->configureMetaboxSettings(
599677
$I,
600-
'wp-convertkit-meta-box',
601-
[
678+
metabox: 'wp-convertkit-meta-box',
679+
configuration: [
602680
'form' => [ 'select2', $_ENV['CONVERTKIT_API_FORM_NAME'] ],
603681
]
604682
);
@@ -633,13 +711,17 @@ public function testAddNewCPTUsingDefinedLegacyForm(EndToEndTester $I)
633711
$I->setupKitPluginResources($I);
634712

635713
// Add a CPT using the Gutenberg editor.
636-
$I->addGutenbergPage($I, 'article', 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']);
714+
$I->addGutenbergPage(
715+
$I,
716+
postType: 'article',
717+
title: 'Kit: CPT: Form: ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME']
718+
);
637719

638720
// Configure metabox's Form setting = None.
639721
$I->configureMetaboxSettings(
640722
$I,
641-
'wp-convertkit-meta-box',
642-
[
723+
metabox: 'wp-convertkit-meta-box',
724+
configuration: [
643725
'form' => [ 'select2', $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'] ],
644726
]
645727
);
@@ -735,9 +817,9 @@ public function testQuickEditUsingDefaultForm(EndToEndTester $I)
735817
// Quick Edit the CPT in the CPTs WP_List_Table.
736818
$I->quickEdit(
737819
$I,
738-
'article',
739-
$postID,
740-
[
820+
postType: 'article',
821+
postID: $postID,
822+
configuration: [
741823
'form' => [ 'select', 'Default' ],
742824
]
743825
);
@@ -783,9 +865,9 @@ public function testQuickEditUsingDefinedForm(EndToEndTester $I)
783865
// Quick Edit the CPT in the CPTs WP_List_Table.
784866
$I->quickEdit(
785867
$I,
786-
'article',
787-
$postID,
788-
[
868+
postType: 'article',
869+
postID: $postID,
870+
configuration: [
789871
'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ],
790872
]
791873
);
@@ -839,9 +921,9 @@ public function testBulkEditUsingDefaultForm(EndToEndTester $I)
839921
// Bulk Edit the CPTs in the CPTs WP_List_Table.
840922
$I->bulkEdit(
841923
$I,
842-
'article',
843-
$postIDs,
844-
[
924+
postType: 'article',
925+
postIDs: $postIDs,
926+
configuration: [
845927
'form' => [ 'select', 'Default' ],
846928
]
847929
);
@@ -898,9 +980,9 @@ public function testBulkEditUsingDefinedForm(EndToEndTester $I)
898980
// Bulk Edit the CPTs in the CPTs WP_List_Table.
899981
$I->bulkEdit(
900982
$I,
901-
'article',
902-
$postIDs,
903-
[
983+
postType: 'article',
984+
postIDs: $postIDs,
985+
configuration: [
904986
'form' => [ 'select', $_ENV['CONVERTKIT_API_FORM_NAME'] ],
905987
]
906988
);
@@ -971,9 +1053,9 @@ public function testBulkEditWithNoChanges(EndToEndTester $I)
9711053
// Bulk Edit the CPTs in the CPTs WP_List_Table.
9721054
$I->bulkEdit(
9731055
$I,
974-
'article',
975-
$postIDs,
976-
[
1056+
postType: 'article',
1057+
postIDs: $postIDs,
1058+
configuration: [
9771059
'form' => [ 'select', '— No Change —' ],
9781060
]
9791061
);

0 commit comments

Comments
 (0)