Skip to content

Commit

Permalink
test: make CoreTableTest compatible with WP6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DDEV User committed Sep 25, 2024
1 parent d518e07 commit 8531653
Showing 1 changed file with 50 additions and 27 deletions.
77 changes: 50 additions & 27 deletions tests/unit/CoreTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ private function query(): string {
body {
cells {
align
colspan
content
rowspan
scope
tag
}
Expand All @@ -51,9 +49,7 @@ className
foot {
cells {
align
colspan
content
rowspan
scope
tag
}
Expand All @@ -63,9 +59,7 @@ className
head {
cells {
align
colspan
content
rowspan
scope
tag
}
Expand Down Expand Up @@ -188,9 +182,7 @@ public function test_retrieve_core_table_attribute_fields() {
$this->assertEquals(
[
'align' => null,
'colspan' => null,
'content' => 'Cell 1',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand All @@ -200,9 +192,7 @@ public function test_retrieve_core_table_attribute_fields() {
$this->assertEquals(
[ // @todo These should be filled in
'align' => null,
'colspan' => null,
'content' => 'Cell 2',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand All @@ -215,9 +205,7 @@ public function test_retrieve_core_table_attribute_fields() {
$this->assertEquals(
[
'align' => null,
'colspan' => null,
'content' => 'Cell 3',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand All @@ -227,9 +215,7 @@ public function test_retrieve_core_table_attribute_fields() {
$this->assertEquals(
[
'align' => null,
'colspan' => null,
'content' => 'Cell 4',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand Down Expand Up @@ -328,9 +314,7 @@ public function test_retrieve_core_table_attribute_fields_header_footer() {
$this->assertEquals( // Previously untested
[
'align' => 'left',
'colspan' => null,
'content' => 'Header label',
'rowspan' => null,
'scope' => null,
'tag' => 'th',
],
Expand All @@ -340,9 +324,7 @@ public function test_retrieve_core_table_attribute_fields_header_footer() {
$this->assertEquals(
[
'align' => 'right',
'colspan' => null,
'content' => 'Header label',
'rowspan' => null,
'scope' => null,
'tag' => 'th',
],
Expand All @@ -358,9 +340,7 @@ public function test_retrieve_core_table_attribute_fields_header_footer() {
$this->assertEquals(
[
'align' => 'left', // Previously untested
'colspan' => null,
'content' => 'This column has "align column left"',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand All @@ -372,9 +352,7 @@ public function test_retrieve_core_table_attribute_fields_header_footer() {
$this->assertEquals(
[
'align' => 'right',
'colspan' => null,
'content' => 'This column has "align column center"',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand All @@ -390,9 +368,7 @@ public function test_retrieve_core_table_attribute_fields_header_footer() {
$this->assertEquals( // Previously untested
[
'align' => 'left',
'colspan' => null,
'content' => 'Footer label',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand All @@ -403,9 +379,7 @@ public function test_retrieve_core_table_attribute_fields_header_footer() {
$this->assertEquals(
[
'align' => 'right',
'colspan' => null,
'content' => 'Footer label',
'rowspan' => null,
'scope' => null,
'tag' => 'td',
],
Expand Down Expand Up @@ -578,6 +552,11 @@ public function test_retrieve_core_table_attribute_lock_gradient(): void {
* - scope
*/
public function test_retrieve_core_table_custom_cell_markup(): void {
// colspan and rowspan are only supported in WP 6.2+.
if ( ! is_wp_version_compatible( '6.2' ) ) {
$this->markTestSkipped( 'This test requires WP 6.2 or higher.' );
}

$block_markup = '
<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th scope="col" colspan="2">Header label</th><th>Header label</th></tr></thead><tbody><tr><td rowspan="2">Cell 1</td><td colspan="2">Cell 2</td></tr><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody><tfoot><tr><td colspan="3">Footer label</td></tr></tfoot></table><figcaption class="wp-element-caption">Caption</figcaption></figure>
Expand All @@ -591,7 +570,51 @@ public function test_retrieve_core_table_custom_cell_markup(): void {
]
);

$query = $this->query();
$query = '
fragment CoreTableBlockFragment on CoreTable {
attributes {
body {
cells {
align
colspan
content
rowspan
scope
tag
}
}
foot {
cells {
align
colspan
content
rowspan
scope
tag
}
}
head {
cells {
align
colspan
content
rowspan
scope
tag
}
}
}
}
query Post( $id: ID! ) {
post(id: $id, idType: DATABASE_ID) {
databaseId
editorBlocks {
...CoreTableBlockFragment
}
}
}
';

$variables = [
'id' => $this->post_id,
];
Expand Down

0 comments on commit 8531653

Please sign in to comment.