Skip to content

Commit

Permalink
temp : fix version based testing of attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ta5r committed Oct 1, 2024
1 parent c0aadf9 commit b9d8e30
Showing 1 changed file with 72 additions and 29 deletions.
101 changes: 72 additions & 29 deletions tests/unit/CoreImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand All @@ -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 ) );
Expand Down

0 comments on commit b9d8e30

Please sign in to comment.