@@ -36,15 +36,7 @@ public function testAcfOptionsPageIsQueryableInSchema() {
3636
3737 $ this ->registerOptionsPage ();
3838
39- $ expected_value = uniqid ( 'test ' , true );
40-
41- // Save a value to the ACF Option Field
42- // see: https://www.advancedcustomfields.com/resources/update_field/#update-a-value-from-different-objects
43- if ( function_exists ( 'update_field ' ) ) {
44- update_field ( 'text ' , $ expected_value , 'options ' );
45- }
46-
47- $ this ->register_acf_field ( [], [
39+ $ field_key = $ this ->register_acf_field ( [], [
4840 'graphql_field_name ' => 'OptionsFields ' ,
4941 'location ' => [
5042 [
@@ -57,6 +49,16 @@ public function testAcfOptionsPageIsQueryableInSchema() {
5749 ],
5850 ]);
5951
52+ $ expected_value = uniqid ( 'test ' , true );
53+
54+ // Save a value to the ACF Option Field
55+ // see: https://www.advancedcustomfields.com/resources/update_field/#update-a-value-from-different-objects
56+ if ( function_exists ( 'update_field ' ) ) {
57+ update_field ( $ field_key , $ expected_value , 'options ' );
58+ }
59+
60+
61+
6062 $ query = '
6163 {
6264 myOptionsPage {
@@ -189,7 +191,7 @@ public function testOptionsPageRespectsGraphqlFieldName() {
189191 ]
190192 );
191193
192- $ this ->register_acf_field ( [], [
194+ $ acf_field = $ this ->register_acf_field ( [], [
193195 'graphql_field_name ' => 'OptionsFields ' ,
194196 'location ' => [
195197 [
@@ -206,9 +208,12 @@ public function testOptionsPageRespectsGraphqlFieldName() {
206208
207209 // Save a value to the ACF Option Field
208210 // see: https://www.advancedcustomfields.com/resources/update_field/#update-a-value-from-different-objects
209- update_field ( 'text ' , $ expected_value , 'custom-graphql-name ' );
210- $ get_field = get_field ( 'text ' , 'custom-graphql-name ' );
211+ if ( ! function_exists ( 'update_field ' ) ) {
212+ $ this ->markTestSkipped ( 'update_field not available... ' );
213+ }
211214
215+ // update the field using the field key of the registered field
216+ update_field ( $ acf_field , $ expected_value , 'custom-graphql-name ' );
212217
213218 $ query = '
214219 {
@@ -225,7 +230,9 @@ public function testOptionsPageRespectsGraphqlFieldName() {
225230 ]);
226231
227232 codecept_debug ( [
228- '$get_field ' => $ get_field ,
233+ '$get_field ' => get_field ( 'text ' , 'custom-graphql-name ' ),
234+ 'options_pages ' => acf_get_options_pages (),
235+ '$acf_field ' => $ acf_field ,
229236 ]);
230237
231238 self ::assertQuerySuccessful ( $ actual , [
0 commit comments