Skip to content

Commit d2c28f2

Browse files
committed
- update tests to accurately reflect that the description field will contain a string but might not equal it exactly
1 parent e2ec61e commit d2c28f2

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/FieldType/DatePicker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function register_field_type(): void {
1818
'graphql_description_after' => function( FieldConfig $field_config ) {
1919
$field_type = $field_config->get_acf_field()['type'] ?? null;
2020

21-
return '(' . sprintf( __( 'ACF Fields of the %s type return a date string in the format `YYYYMMDD` according to the RFC3339 spec: https://datatracker.ietf.org/doc/html/rfc3339.', 'wp-graphql-acf' ), $field_type ) . ')';
21+
return '(' . sprintf( __( 'ACF Fields of the %s type return a date string according to the RFC3339 spec: https://datatracker.ietf.org/doc/html/rfc3339.', 'wp-graphql-acf' ), $field_type ) . ')';
2222
},
2323
'resolve' => static function ( $root, $args, $context, $info, $field_type, FieldConfig $field_config ) {
2424
$value = $field_config->resolve_field( $root, $args, $context, $info );

src/FieldType/DateTimePicker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function register_field_type(): void {
1919
'graphql_description_after' => function( FieldConfig $field_config ) {
2020
$field_type = $field_config->get_acf_field()['type'] ?? null;
2121

22-
return '(' . sprintf( __( 'ACF Fields of the %s type return a date string in the format `YYYYMMDD` according to the RFC3339 spec: https://datatracker.ietf.org/doc/html/rfc3339.', 'wp-graphql-acf' ), $field_type ) . ')';
22+
return '(' . sprintf( __( 'ACF Fields of the %s type return a date string according to the RFC3339 spec: https://datatracker.ietf.org/doc/html/rfc3339.', 'wp-graphql-acf' ), $field_type ) . ')';
2323
},
2424
'resolve' => static function ( $root, $args, $context, $info, $field_type, FieldConfig $field_config ) {
2525
$value = $field_config->resolve_field( $root, $args, $context, $info );

tests/_support/WPUnit/AcfFieldTestCase.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,14 @@ public function testFieldDescriptionUsesInstructionsIfGraphqlDescriptionNotProvi
672672
// the instructions should be used for the description
673673
// if "graphql_description" is not provided
674674
$this->expectedNode( '__type.fields', [
675-
'name' => $this->get_formatted_field_name(),
676-
'description' => $instructions
675+
$this->expectedField( 'name', $this->get_formatted_field_name() ),
676+
$this->expectedField( 'description', self::NOT_NULL ),
677677
]),
678+
678679
] );
679680

681+
$this->assertStringContainsString( $instructions, $actual['data']['__type']['fields'][0]['description'] );
682+
680683
// remove the local field
681684
acf_remove_local_field( $field_key );
682685

@@ -720,11 +723,14 @@ public function testFieldDescriptionUsesGraphqlDescriptionIfProvided(): void {
720723
// the instructions should be used for the description
721724
// if "graphql_description" is not provided
722725
$this->expectedNode( '__type.fields', [
723-
'name' => $this->get_formatted_field_name(),
724-
'description' => $graphql_description
726+
$this->expectedField( 'name', $this->get_formatted_field_name() ),
727+
$this->expectedField( 'description', self::NOT_NULL ),
725728
]),
726729
] );
727730

731+
$this->assertStringContainsString( $graphql_description, $actual['data']['__type']['fields'][0]['description'] );
732+
733+
728734
// remove the local field
729735
acf_remove_local_field( $field_key );
730736

0 commit comments

Comments
 (0)