Skip to content

Commit

Permalink
chore: mode debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
theodesp committed Aug 14, 2024
1 parent 96cf870 commit 6ecf7e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
43 changes: 18 additions & 25 deletions tests/unit/CoreImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
namespace WPGraphQL\ContentBlocks\Unit;

final class CoreImageTest extends PluginTestCase {
public $instance;
public $instance;
public $post_id;
public $attachment_id;
public function setUp(): void {

public function setUp(): void {
parent::setUp();
global $wpdb;
$this->attachment_id = $this->factory->attachment->create_upload_object( WP_TEST_DATA_DIR . '/images/test-image.jpg' );

$this->post_id = wp_insert_post(
array(
'post_title' => 'Post Title',
'post_title' => 'Post Title',
'post_content' => preg_replace(
'/\s+/',
' ',
Expand All @@ -26,19 +26,19 @@ public function setUp(): void {
'
)
),
'post_status' => 'publish',
'post_status' => 'publish',
)
);
}

public function tearDown(): void {
public function tearDown(): void {
// your tear down methods here
parent::tearDown();
wp_delete_post( $this->post_id, true );
}

public function test_retrieve_core_image_media_details() {
$query = '
$query = '
fragment CoreImageBlockFragment on CoreImage {
attributes {
id
Expand All @@ -60,23 +60,17 @@ public function test_retrieve_core_image_media_details() {
}
';
$actual = graphql( array( 'query' => $query ) );
$node = $actual['data']['posts']['nodes'][0];
$node = $actual['data']['posts']['nodes'][0];

$this->assertEquals( $node['editorBlocks'][0]['mediaDetails'], [
$this->assertEquals( $node['editorBlocks'][0]['mediaDetails'], [
"width" => 50,
"height" => 50,
]);
] );
}


public function test_retrieve_core_image_attributes() {
$query = '
fragment CoreColumnBlockFragment on CoreColumn {
attributes {
width
}
}
public function test_retrieve_core_image_attributes() {
$query = '
fragment CoreImageBlockFragment on CoreImage {
attributes {
id
Expand All @@ -102,23 +96,22 @@ public function test_retrieve_core_image_attributes() {
editorBlocks {
name
...CoreImageBlockFragment
...CoreColumnBlockFragment
}
}
}
}
';
$actual = graphql( array( 'query' => $query ) );
print_r($actual);
$node = $actual['data']['posts']['nodes'][0];
print_r( $actual );
$node = $actual['data']['posts']['nodes'][0];

// Verify that the ID of the first post matches the one we just created.
$this->assertEquals( $this->post_id, $node['databaseId'] );
// There should be only one block using that query when not using flat: true
$this->assertEquals( count( $node['editorBlocks'] ), 1 );
$this->assertEquals( $node['editorBlocks'][0]['name'], 'core/image' );

$this->assertEquals( $node['editorBlocks'][0]['attributes'], [
$this->assertEquals( $node['editorBlocks'][0]['attributes'], [
"width" => "500",
"height" => 500.0,
"alt" => "",
Expand All @@ -131,7 +124,7 @@ public function test_retrieve_core_image_attributes() {
"linkDestination" => "none",
"align" => NULL,
"caption" => "",
"cssClassName" => "wp-block-image size-full is-resized"
]);
"cssClassName" => "wp-block-image size-full is-resized"
] );
}
}
1 change: 1 addition & 0 deletions tests/unit/CoreTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function test_retrieve_core_table_attribute_fields() {
}
';
$actual = graphql( array( 'query' => $query ) );
print_r( $actual );
$node = $actual['data']['posts']['nodes'][0];
$this->assertEquals( $node['editorBlocks'][0]['name'], 'core/table' );
// There should be only one block using that query when not using flat: true
Expand Down
1 change: 1 addition & 0 deletions tests/unit/CoreVideoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function test_retrieve_core_video_attributes() {
}
';
$actual = graphql( array( 'query' => $query ) );
print_r( $actual );
$node = $actual['data']['posts']['nodes'][0];

// Verify that the ID of the first post matches the one we just created.
Expand Down

0 comments on commit 6ecf7e0

Please sign in to comment.