From 333789ced11a302f20f2c5e08740925ec418b14d Mon Sep 17 00:00:00 2001 From: James Burke Date: Mon, 10 May 2021 14:16:21 -0500 Subject: [PATCH] Update test to remove theme options --- tests/components/test-class-component.php | 92 +++++++-------------- tests/components/test-components.php | 98 +++++++++-------------- tests/templates/test-templates.php | 26 +++--- 3 files changed, 77 insertions(+), 139 deletions(-) diff --git a/tests/components/test-class-component.php b/tests/components/test-class-component.php index aa68b67e..070c4c48 100644 --- a/tests/components/test-class-component.php +++ b/tests/components/test-class-component.php @@ -90,7 +90,6 @@ public function test_component_defaults() { $this->assertSame( [ 'theme' => 'default' ], $component->get_config(), 'Default config not empty.' ); $this->assertSame( [], $component->get_children(), 'Default children not empty.' ); $this->assertSame( 'default', $component->get_theme(), 'Default theme not set.' ); - $this->assertSame( [ 'default' ], $component->get_theme_options(), 'Default theme options not set.' ); $this->assertSame( [], $component->get_context(), 'Default context values not set.' ); $this->assertNull( $component->get_callback( 'config' ), 'Default config callback not null.' ); $this->assertNull( $component->get_callback( 'children' ), 'Default children callback not null.' ); @@ -261,20 +260,6 @@ public function test_get_config_by_key() { ); } - /** - * Test get_theme_options(). - */ - public function test_get_theme_options() { - // 'test/theme-options' is a registered component type. - $component = new Component( 'test/theme-options' ); - - $this->assertSame( - [ 'primary', 'secondary' ], - $component->get_theme_options(), - 'Did not get expected theme options.' - ); - } - /** * Test get_theme(). * @@ -608,10 +593,9 @@ public function get_components_to_serialize() { 'name' => 'test/basic', '_alias' => '', 'config' => (object) [ - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -631,11 +615,10 @@ public function get_components_to_serialize() { 'name' => 'test/basic', '_alias' => '', 'config' => (object) [ - 'foo' => 'bar', - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'foo' => 'bar', + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -648,10 +631,9 @@ public function get_components_to_serialize() { 'name' => 'test/alias', '_alias' => 'test/component', 'config' => (object) [ - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -664,11 +646,10 @@ public function get_components_to_serialize() { 'name' => 'test/schema', '_alias' => '', 'config' => (object) [ - 'testDefault' => 'default', - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'testDefault' => 'default', + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -681,10 +662,9 @@ public function get_components_to_serialize() { 'name' => 'test/theme-options', '_alias' => '', 'config' => (object) [ - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'primary', 'secondary' ], + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -710,7 +690,6 @@ public function get_components_to_serialize() { 'className' => '', 'style' => [], 'themeName' => 'default', - 'themeOptions' => [ 'default' ], ], 'children' => [], ], @@ -732,13 +711,10 @@ public function test_json_serialize_component_array_filter() { 'name' => 'test/basic', '_alias' => '', 'config' => (object) [ - 'className' => '', - 'style' => [], - 'test' => true, - 'themeName' => 'default', - 'themeOptions' => [ - 'default', - ], + 'className' => '', + 'style' => [], + 'test' => true, + 'themeName' => 'default', ], 'children' => [], ], @@ -756,12 +732,9 @@ public function test_json_serialize_component_array_filter() { 'name' => 'test/basic', '_alias' => '', 'config' => (object) [ - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ - 'default', - ], + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -798,16 +771,13 @@ public function test_disabling_camel_casing() { 'name' => 'example/no-camels', '_alias' => '', 'config' => (object) [ - 'className' => '', - 'style' => [], - 'themeName' => 'no_camels', - 'themeOptions' => [ - 'default', - ], - 'under_score' => 'under_score', - 'camelCase' => 'camelCase', - 'cabob-case' => 'cabob-case', - 'nested_case' => [ + 'className' => '', + 'style' => [], + 'themeName' => 'no_camels', + 'under_score' => 'under_score', + 'camelCase' => 'camelCase', + 'cabob-case' => 'cabob-case', + 'nested_case' => [ 'under_score' => 'under_score', 'camelCase' => 'camelCase', 'cabob-case' => 'cabob-case', diff --git a/tests/components/test-components.php b/tests/components/test-components.php index b86cbc15..2f8ff51a 100644 --- a/tests/components/test-components.php +++ b/tests/components/test-components.php @@ -297,12 +297,11 @@ public function test_component_archive_title() { '_alias' => 'irving/text', 'config' => (object) [ // The format of the archive title changed in WP version 5.5. - 'content' => version_compare( get_bloginfo( 'version' ), '5.4.99', '>' ) ? 'Category: Uncategorized' : 'Category: Uncategorized', - 'html' => true, - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'content' => version_compare( get_bloginfo( 'version' ), '5.4.99', '>' ) ? 'Category: Uncategorized' : 'Category: Uncategorized', + 'html' => true, + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ]; @@ -412,47 +411,32 @@ public function test_component_post_byline() { 'className' => '', 'style' => [], 'themeName' => 'default', - 'themeOptions' => [ 'default' ], ], 'children' => [ [ 'name' => 'irving/link', '_alias' => '', 'config' => (object) [ - 'href' => get_author_posts_url( $this->get_author_id() ), - 'fragment' => '', - 'rel' => '', - 'className' => '', - 'style' => [], - 'target' => '', - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'href' => get_author_posts_url( $this->get_author_id() ), + 'fragment' => '', + 'rel' => '', + 'className' => '', + 'style' => [], + 'target' => '', + 'themeName' => 'default', ], 'children' => [ [ 'name' => 'irving/text', '_alias' => '', 'config' => (object) [ - 'content' => get_the_author_meta( 'display_name', $this->get_author_id() ), - 'tag' => 'span', - 'html' => false, - 'oembed' => false, - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ - 'default', - 'unstyled', - 'responsiveEmbed', - 'html', - 'caption', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - ], + 'content' => get_the_author_meta( 'display_name', $this->get_author_id() ), + 'tag' => 'span', + 'html' => false, + 'oembed' => false, + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ], @@ -479,15 +463,14 @@ public function test_component_post_content() { '_alias' => 'irving/text', 'config' => (object) [ // The format of the archive title changed in WP version 5.5. - 'content' => $this->get_post_content(), - 'html' => true, - 'oembed' => true, - 'postId' => $this->get_post_id(), - 'className' => '', - 'style' => [], - 'tag' => 'div', - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'content' => $this->get_post_content(), + 'html' => true, + 'oembed' => true, + 'postId' => $this->get_post_id(), + 'className' => '', + 'style' => [], + 'tag' => 'div', + 'themeName' => 'default', ], 'children' => [], ]; @@ -510,13 +493,12 @@ public function test_component_post_excerpt() { '_alias' => 'irving/text', 'config' => (object) [ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals - 'content' => $this->get_post_excerpt(), - 'html' => true, - 'postId' => $this->get_post_id(), - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'content' => $this->get_post_excerpt(), + 'html' => true, + 'postId' => $this->get_post_id(), + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ]; @@ -552,7 +534,6 @@ public function test_component_post_featured_image() { 'objectFit' => 'cover', 'postId' => $this->get_post_id(), 'themeName' => 'default', - 'themeOptions' => [ 'default' ], 'width' => $image_attr[1], 'srcset' => wp_get_attachment_image_srcset( $this->get_attachment_id(), 'full' ), 'sizes' => wp_get_attachment_image_sizes( $this->get_attachment_id(), 'full' ), @@ -590,7 +571,6 @@ public function test_component_post_featured_media() { 'className' => '', 'style' => [], 'themeName' => 'default', - 'themeOptions' => [ 'default' ], ], 'children' => [ [ @@ -608,7 +588,6 @@ public function test_component_post_featured_media() { 'objectFit' => 'cover', 'postId' => $this->get_post_id(), 'themeName' => 'default', - 'themeOptions' => [ 'default' ], 'width' => $image_attr[1], 'srcset' => wp_get_attachment_image_srcset( $this->get_attachment_id(), 'full' ), 'sizes' => wp_get_attachment_image_sizes( $this->get_attachment_id(), 'full' ), @@ -1294,10 +1273,6 @@ public function test_component_site_menu() { 'location' => 'test-location', 'menuId' => $menu_id, 'menuName' => 'test-menu', - 'themeOptions' => [ - 'default', - 'defaultVertical', - ], ], 'children' => [ $this->get_expected_component( @@ -1807,10 +1782,9 @@ public function get_expected_component( string $name, array $args = [] ): array $component['config'] = (object) wp_parse_args( $args['config'] ?? null, [ - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'className' => '', + 'style' => [], + 'themeName' => 'default', ] ); diff --git a/tests/templates/test-templates.php b/tests/templates/test-templates.php index 2ccd1511..94b3f348 100644 --- a/tests/templates/test-templates.php +++ b/tests/templates/test-templates.php @@ -300,7 +300,6 @@ public function test_components_use_context() { 'className' => '', 'style' => [], 'themeName' => 'default', - 'themeOptions' => [ 'default' ], ], 'children' => [ [ @@ -313,7 +312,6 @@ public function test_components_use_context() { 'className' => '', 'style' => [], 'themeName' => 'default', - 'themeOptions' => [ 'default' ], ], 'children' => [], ], @@ -363,16 +361,14 @@ public function test_templates_context_without_registration() { 'config' => [ 'testProvided' => 20, 'themeName' => 'default', - 'themeOptions' => [ 'default' ], ], 'children' => [ [ 'name' => 'consumer', '_alias' => '', 'config' => [ - 'testUsed' => 20, - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'testUsed' => 20, + 'themeName' => 'default', ], 'children' => [], ], @@ -441,22 +437,20 @@ public function test_template_use_context() { 'name' => 'test/context-provider', '_alias' => '', 'config' => [ - 'value' => 'foo', - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'value' => 'foo', + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [ [ 'name' => 'test/use-context-template', '_alias' => '', 'config' => [ - 'bar' => 'foo', - 'className' => '', - 'style' => [], - 'themeName' => 'default', - 'themeOptions' => [ 'default' ], + 'bar' => 'foo', + 'className' => '', + 'style' => [], + 'themeName' => 'default', ], 'children' => [], ],