Skip to content

Commit 8043eb5

Browse files
authored
chore: update deps, backfill tests, cleanup readme links (#426)
1 parent d5b1ea8 commit 8043eb5

File tree

8 files changed

+262
-187
lines changed

8 files changed

+262
-187
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- chore: Declare `strict_types` in all PHP files.
2020
- chore: Update Composer dev-dependencies and fix test compatibility with `wp-graphql-test-case` v3.0.x.
2121
- docs: Add docs on using Multi-page forms.
22+
- tests: Add test for `GFUtils::get_last_form_page()`.
2223

2324
## v0.12.6.1
2425

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
A WordPress plugin that adds <a href="https://wpgraphql.com" target="_blank">WPGraphQL</a> support for <a href="https://gravityforms.com" target="_blank">Gravity Forms</a>.
55

6-
* [Join the WPGraphQL community on Slack.](https://join.slack.com/t/wp-graphql/shared_invite/zt-3vloo60z-PpJV2PFIwEathWDOxCTTLA)
6+
* [Join the WPGraphQL community on Discord.](https://discord.gg/Hp6fQbqvwe)
77
* [Documentation](#documentation)
88

99
-----
@@ -58,7 +58,7 @@ v0.x.y.z: "Patch" releases. These releases are reserved for addressing issue wit
5858

5959
Development of WPGraphQL for Gravity Forms is provided by [AxePress Development](https://axepress.dev). Community contributions are _welcome_ and **encouraged**.
6060

61-
Basic support is provided for free, both in [this repo](https://github.com/axewp/wp-graphql-gravity-forms/issues) and in [WPGraphQL Slack](https://join.slack.com/t/wp-graphql/shared_invite/zt-3vloo60z-PpJV2PFIwEathWDOxCTTLA).
61+
Basic support is provided for free, both in [this repo](https://github.com/axewp/wp-graphql-gravity-forms/issues) and in [WPGraphQL's official Discord](https://discord.gg/Hp6fQbqvwe).
6262

6363
Priority support and custom development are available to [our Sponsors](https://github.com/sponsors/AxeWP).
6464

composer.lock

Lines changed: 138 additions & 135 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/wpunit/FormFieldConnectionPageFilterTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function tearDown(): void {
4646
}
4747

4848
private function generate_form_pages( int $count = 1 ): array {
49-
$fields = [];
49+
$fields = [];
5050
$field_id = 1;
5151

5252
for ( $i = 0; $i < $count; $i++ ) {
@@ -137,12 +137,12 @@ public function testFilterByPageNumber(): void {
137137
* Test with empty offset.
138138
*/
139139
$variables = [
140-
'formId' => $this->form_id,
140+
'formId' => $this->form_id,
141141
'pageNumber' => 0,
142142
];
143143

144144
$expected = $wp_query;
145-
$actual = $this->graphql( compact( 'query', 'variables' ) );
145+
$actual = $this->graphql( compact( 'query', 'variables' ) );
146146

147147
$this->assertResponseIsValid( $actual );
148148
$this->assertArrayNotHasKey( 'errors', $actual );
@@ -170,7 +170,6 @@ public function testFilterByPageNumber(): void {
170170

171171
$this->assertValidPageFields( $expected, $actual );
172172

173-
174173
/**
175174
* Test the last two results.
176175
*/
@@ -198,14 +197,15 @@ private function assertValidPageFields( array $expected, array $actual ): void {
198197
$this->assertArrayHasKey( 'data', $actual );
199198
$this->assertCount( 2, $actual['data']['gfForm']['formFields']['nodes'] );
200199

201-
202200
$this->assertEquals( $expected[0]['id'], $actual['data']['gfForm']['formFields']['nodes'][0]['databaseId'] );
203201
$this->assertEquals( $expected[0]['pageNumber'], $actual['data']['gfForm']['formFields']['nodes'][0]['pageNumber'] );
204202
$this->assertEquals( $expected[1]['id'], $actual['data']['gfForm']['formFields']['nodes'][1]['databaseId'] );
205203
$this->assertEquals( $expected[1]['pageNumber'], $actual['data']['gfForm']['formFields']['nodes'][1]['pageNumber'] );
206204
$this->assertEquals( GFHelpers::get_enum_for_value( FormFieldTypeEnum::$type, $expected[1]['type'] ), $actual['data']['gfForm']['formFields']['nodes'][1]['type'] );
207205
$this->assertEquals( $expected[1]['nextButton']['text'], $actual['data']['gfForm']['formFields']['nodes'][1]['nextButton']['text'] );
208-
$this->assertEquals(
209-
$expected[1]['previousButton']['text'], $actual['data']['gfForm']['formFields']['nodes'][1]['previousButton']['text'] );
206+
$this->assertEquals(
207+
$expected[1]['previousButton']['text'],
208+
$actual['data']['gfForm']['formFields']['nodes'][1]['previousButton']['text']
209+
);
210210
}
211211
}

tests/wpunit/GFUtilsTest.php

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,80 @@ public function testGetForms(): void {
122122
* Tests GFUtils::get_last_form_page().
123123
*/
124124
public function testGetLastFormPage(): void {
125-
$this->markTestIncomplete(
126-
'This test has not been implemented yet. Requires PageField arguments.'
125+
// These will increment.
126+
$id = 1;
127+
$page_number = 1;
128+
129+
$form_id = $this->factory->form->create(
130+
array_merge(
131+
[
132+
'fields' => [
133+
$this->factory->field->create(
134+
array_merge(
135+
$this->tester->getPropertyHelper( 'NumberField' )->values,
136+
[
137+
'id' => $id++,
138+
'pageNumber' => $page_number,
139+
'isRequired' => true,
140+
]
141+
)
142+
),
143+
$this->factory->field->create(
144+
array_merge(
145+
$this->tester->getPropertyHelper( 'PageField' )->values,
146+
[
147+
'id' => $id++,
148+
'pageNumber' => ++$page_number,
149+
'isRequired' => false,
150+
'conditionalLogic' => [
151+
'actionType' => 'show',
152+
'logicType' => 'all',
153+
'rules' => [
154+
[
155+
'fieldId' => 1,
156+
'operator' => 'is',
157+
'value' => 2,
158+
],
159+
],
160+
],
161+
]
162+
)
163+
),
164+
$this->factory->field->create(
165+
array_merge(
166+
$this->tester->getPropertyHelper( 'NumberField' )->values,
167+
[
168+
'id' => $id++,
169+
'pageNumber' => $page_number,
170+
'isRequired' => true,
171+
]
172+
)
173+
),
174+
$this->factory->field->create(
175+
array_merge(
176+
$this->tester->getPropertyHelper( 'PageField' )->values,
177+
[
178+
'id' => $id++,
179+
'pageNumber' => ++$page_number,
180+
]
181+
)
182+
),
183+
],
184+
],
185+
$this->tester->getFormDefaultArgs()
186+
)
127187
);
188+
189+
$expected = 3;
190+
191+
$form = $this->factory->form->get_object_by_id( $form_id );
192+
193+
$actual = GFUtils::get_last_form_page( $form );
194+
195+
$this->assertEquals( $expected, $actual );
196+
197+
// Cleanup.
198+
$this->factory->form->delete( $form_id );
128199
}
129200

130201
/**

tests/wpunit/RadioFieldOtherChoiceTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ public function field_helper() {
5858
* Generates the form fields from factory. Must be wrappend in an array.
5959
*/
6060
public function generate_fields(): array {
61-
return [ $this->factory->field->create(
62-
array_merge(
63-
$this->property_helper->values,
64-
[
65-
'enableOtherChoice' => true,
66-
]
67-
)
68-
) ];
61+
return [
62+
$this->factory->field->create(
63+
array_merge(
64+
$this->property_helper->values,
65+
[
66+
'enableOtherChoice' => true,
67+
]
68+
)
69+
),
70+
];
6971
}
7072

7173
/**

tests/wpunit/SubmitFormMultipageTest.php

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function setUp(): void {
2222

2323
wp_set_current_user( $this->admin->ID );
2424

25-
$this->fields = $this->generate_form_fields();
25+
$this->fields = $this->generate_form_fields();
2626
$this->form_id = $this->factory->form->create(
2727
array_merge(
2828
[ 'fields' => $this->fields ],
@@ -33,7 +33,6 @@ public function setUp(): void {
3333
$this->clearSchema();
3434
}
3535

36-
3736
/**
3837
* {@inheritDoc}
3938
*/
@@ -47,15 +46,15 @@ public function tearDown(): void {
4746

4847
private function generate_form_fields(): array {
4948
// This will increment as we use them.
50-
$id = 1;
49+
$id = 1;
5150
$page_number = 1;
5251

5352
return [
5453
$this->factory->field->create(
5554
array_merge(
5655
$this->tester->getPropertyHelper( 'NumberField' )->values,
5756
[
58-
'id' => $id++,
57+
'id' => $id++,
5958
'pageNumber' => $page_number,
6059
'isRequired' => true,
6160
]
@@ -65,28 +64,28 @@ private function generate_form_fields(): array {
6564
array_merge(
6665
$this->tester->getPropertyHelper( 'PageField' )->values,
6766
[
68-
'id' => $id++,
69-
'pageNumber' => ++$page_number,
70-
'isRequired' => false,
67+
'id' => $id++,
68+
'pageNumber' => ++$page_number,
69+
'isRequired' => false,
7170
'conditionalLogic' => [
7271
'actionType' => 'show',
73-
'logicType' => 'all',
74-
'rules' => [
72+
'logicType' => 'all',
73+
'rules' => [
7574
[
76-
'fieldId' => 1,
75+
'fieldId' => 1,
7776
'operator' => 'is',
78-
'value' => 2
79-
]
80-
]
81-
]
77+
'value' => 2,
78+
],
79+
],
80+
],
8281
]
8382
)
8483
),
8584
$this->factory->field->create(
8685
array_merge(
8786
$this->tester->getPropertyHelper( 'NumberField' )->values,
8887
[
89-
'id' => $id++,
88+
'id' => $id++,
9089
'pageNumber' => $page_number,
9190
'isRequired' => true,
9291
]
@@ -105,13 +104,13 @@ private function generate_form_fields(): array {
105104
array_merge(
106105
$this->tester->getPropertyHelper( 'NumberField' )->values,
107106
[
108-
'id' => $id++,
109-
'pageNumber' => $page_number,
110-
'isRequired' => true,
107+
'id' => $id++,
108+
'pageNumber' => $page_number,
109+
'isRequired' => true,
111110
'defaultValue' => 'default value',
112111
]
113112
)
114-
)
113+
),
115114
];
116115
}
117116

@@ -158,12 +157,12 @@ public function testSubmit(): void {
158157
'input' => [
159158
'id' => $this->form_id,
160159
'saveAsDraft' => false,
161-
]
160+
],
162161
];
163162

164163
// Submit the first page with invalid value.
165-
$variables['input']['sourcePage'] = 1;
166-
$variables['input']['targetPage'] = 2;
164+
$variables['input']['sourcePage'] = 1;
165+
$variables['input']['targetPage'] = 2;
167166
$variables['input']['fieldValues'] = [];
168167

169168
$actual = $this->graphql( compact( 'query', 'variables' ) );
@@ -173,12 +172,12 @@ public function testSubmit(): void {
173172
$this->assertNotEmpty( $actual['data']['submitGfForm']['errors'] );
174173
$this->assertEquals( 1, $actual['data']['submitGfForm']['targetPageNumber'], 'The target page number should be the invalid page' );
175174

176-
$this->clear_form_field_state();
175+
$this->clear_form_field_state();
177176

178177
// On a value that isnt 2, the 3rd page should be the target page.
179178
$variables['input']['fieldValues'] = [
180179
[
181-
'id' => 1,
180+
'id' => 1,
182181
'value' => '0',
183182
],
184183
];
@@ -200,7 +199,7 @@ public function testSubmit(): void {
200199

201200
$variables['input']['fieldValues'] = [
202201
[
203-
'id' => 1,
202+
'id' => 1,
204203
'value' => '2',
205204
],
206205
];
@@ -244,7 +243,7 @@ public function testSubmit(): void {
244243
$variables['input']['fieldValues'],
245244
[
246245
[
247-
'id' => 3,
246+
'id' => 3,
248247
'value' => '2',
249248
],
250249
]
@@ -284,7 +283,7 @@ public function testSubmit(): void {
284283
$variables['input']['fieldValues'],
285284
[
286285
[
287-
'id' => 5,
286+
'id' => 5,
288287
'value' => '1',
289288
],
290289
]
@@ -298,14 +297,13 @@ public function testSubmit(): void {
298297
$this->assertNull( $actual['data']['submitGfForm']['targetPageNumber'] );
299298
$this->assertEmpty( $actual['data']['submitGfForm']['targetPageFormFields'] );
300299

301-
302300
// Test as Draft.
303301
$this->clear_form_field_state();
304302

305303
$variables['input']['saveAsDraft'] = true;
306304
$variables['input']['fieldValues'] = [];
307-
$variables['input']['sourcePage'] = 1;
308-
$variables['input']['targetPage'] = 3;
305+
$variables['input']['sourcePage'] = 1;
306+
$variables['input']['targetPage'] = 3;
309307

310308
$actual = $this->graphql( compact( 'query', 'variables' ) );
311309

@@ -324,7 +322,7 @@ public function testSubmit(): void {
324322
private function clear_form_field_state(): void {
325323
$form = GFAPI::get_form( $this->form_id );
326324

327-
foreach( $form['fields'] as $field ) {
325+
foreach ( $form['fields'] as $field ) {
328326
unset( $field->failed_validation );
329327
unset( $field->validation_message );
330328
}

vendor/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'harness-software/wp-graphql-gravity-forms',
44
'pretty_version' => 'dev-develop',
55
'version' => 'dev-develop',
6-
'reference' => 'e68b7c0b1d9aaf702384eae00af7d3c94e6c0f29',
6+
'reference' => 'd5b1ea8aba7e845b05970af4f6bbbf9c0c4683b3',
77
'type' => 'wordpress-plugin',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -13,7 +13,7 @@
1313
'harness-software/wp-graphql-gravity-forms' => array(
1414
'pretty_version' => 'dev-develop',
1515
'version' => 'dev-develop',
16-
'reference' => 'e68b7c0b1d9aaf702384eae00af7d3c94e6c0f29',
16+
'reference' => 'd5b1ea8aba7e845b05970af4f6bbbf9c0c4683b3',
1717
'type' => 'wordpress-plugin',
1818
'install_path' => __DIR__ . '/../../',
1919
'aliases' => array(),

0 commit comments

Comments
 (0)