Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Update test to remove theme options
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswburke committed May 10, 2021
1 parent a2303d7 commit 333789c
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 139 deletions.
92 changes: 31 additions & 61 deletions tests/components/test-class-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' );
Expand Down Expand Up @@ -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().
*
Expand Down Expand Up @@ -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' => [],
],
Expand All @@ -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' => [],
],
Expand All @@ -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' => [],
],
Expand All @@ -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' => [],
],
Expand All @@ -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' => [],
],
Expand All @@ -710,7 +690,6 @@ public function get_components_to_serialize() {
'className' => '',
'style' => [],
'themeName' => 'default',
'themeOptions' => [ 'default' ],
],
'children' => [],
],
Expand All @@ -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' => [],
],
Expand All @@ -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' => [],
],
Expand Down Expand Up @@ -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',
Expand Down
98 changes: 36 additions & 62 deletions tests/components/test-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -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: <span>Uncategorized</span>' : 'Category: Uncategorized',
'html' => true,
'className' => '',
'style' => [],
'themeName' => 'default',
'themeOptions' => [ 'default' ],
'content' => version_compare( get_bloginfo( 'version' ), '5.4.99', '>' ) ? 'Category: <span>Uncategorized</span>' : 'Category: Uncategorized',
'html' => true,
'className' => '',
'style' => [],
'themeName' => 'default',
],
'children' => [],
];
Expand Down Expand Up @@ -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' => [],
],
Expand All @@ -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' => [],
];
Expand All @@ -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' => [],
];
Expand Down Expand Up @@ -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' ),
Expand Down Expand Up @@ -590,7 +571,6 @@ public function test_component_post_featured_media() {
'className' => '',
'style' => [],
'themeName' => 'default',
'themeOptions' => [ 'default' ],
],
'children' => [
[
Expand All @@ -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' ),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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',
]
);

Expand Down
Loading

0 comments on commit 333789c

Please sign in to comment.