From b9d8e3017a92ea2d58aa810cd48ab3c876ac7fe7 Mon Sep 17 00:00:00 2001 From: Ta5r Date: Tue, 1 Oct 2024 15:05:24 +0530 Subject: [PATCH] temp : fix version based testing of attributes. --- tests/unit/CoreImageTest.php | 101 +++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 29 deletions(-) diff --git a/tests/unit/CoreImageTest.php b/tests/unit/CoreImageTest.php index a10927b1..e874a6d8 100644 --- a/tests/unit/CoreImageTest.php +++ b/tests/unit/CoreImageTest.php @@ -399,42 +399,70 @@ public function test_retrieve_core_untested_attributes(): void{ // `scale` is only supported in WP 6.2+. - if ( ! is_wp_version_compatible( '6.2' ) ) { - error_log( 'inside version 6.2 check for scale' ); + // if ( is_wp_version_compatible( '6.2' ) ) { + // error_log( 'inside version 6.2 check for scale' ); - $query = $this->query( ' - scale - ' ); + // $query = ' + // fragment CoreImageBlockFragment on CoreImage { + // attributes { + // scale + // } + // } + // query Post( $id: ID! ) { + // post(id: $id, idType: DATABASE_ID) { + // databaseId + // editorBlocks { + // name + // ...CoreImageBlockFragment + // } + // } + // }'; - $actual = graphql( compact( 'query', 'variables' ) ); - error_log( print_r( $actual, true ) ); - $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); - $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); - $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); + // $actual = graphql( compact( 'query', 'variables' ) ); + // error_log( print_r( $actual, true ) ); - $block = $actual['data']['post']['editorBlocks'][0]; + // $this->assertArrayNotHasKey( 'errors', $actual, 'There should not be any errors' ); + // $this->assertArrayHasKey( 'data', $actual, 'The data key should be present' ); + // $this->assertArrayHasKey( 'post', $actual['data'], 'The post key should be present' ); - $this->assertEquals( - [ - 'scale' => 'cover', // Previously untested. - ], - $block['attributes'] - ); - } - else { - error_log('WP not compatible with 6.2'); - } + // $block = $actual['data']['post']['editorBlocks'][0]; + + // $this->assertEquals( + // [ + // 'scale' => 'cover', // Previously untested. + // ], + // $block['attributes'] + // ); + // } + // else { + // error_log('WP not compatible with 6.2'); + // } // `aspectRatio` is only supported in WP 6.3+. - if ( ! is_wp_version_compatible( '6.3' ) ) { // should have been 6.3 theoritically. + if ( is_wp_version_compatible( '6.3' ) ) { // should have been 6.3 theoritically. error_log( 'inside version 6.3 check for aspectRatio' ); - $query = $this->query( ' - aspectRatio - ' ); + + $query = ' + fragment CoreImageBlockFragment on CoreImage { + attributes { + aspectRatio + scale + } + } + + query Post( $id: ID! ) { + post(id: $id, idType: DATABASE_ID) { + databaseId + editorBlocks { + name + ...CoreImageBlockFragment + } + } + }'; $actual = graphql( compact( 'query', 'variables' ) ); @@ -461,12 +489,27 @@ public function test_retrieve_core_untested_attributes(): void{ // `lightbox` is only supported in WP 6.4+. - if ( ! is_wp_version_compatible( '6.4' ) ) { + if ( is_wp_version_compatible( '6.4' ) ) { error_log( 'inside version 6.4 check for lightbox' ); - $query = $this->query( ' - lightbox - ' ); + + + $query = ' + fragment CoreImageBlockFragment on CoreImage { + attributes { + lightbox + } + } + + query Post( $id: ID! ) { + post(id: $id, idType: DATABASE_ID) { + databaseId + editorBlocks { + name + ...CoreImageBlockFragment + } + } + }'; $actual = graphql( compact( 'query', 'variables' ) ); error_log( print_r( $actual, true ) );