diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index 7cd1fba0..a7196b96 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -16,10 +16,16 @@ * @return void */ function beans_do_enqueue_wp_customize_assets() { - wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( - 'jquery', - 'customize-preview', - ), BEANS_VERSION, true ); + wp_enqueue_script( + 'beans-wp-customize-preview', + BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', + array( + 'jquery', + 'customize-preview', + ), + BEANS_VERSION, + true + ); } beans_add_smart_action( 'customize_register', 'beans_do_register_wp_customize_options' ); diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 50d47c5a..d99c263f 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -164,7 +164,7 @@ private function is_wp_filesystem_direct() { */ private function maybe_make_dir() { - if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- This is a valid use case. + if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- This is a valid use case. wp_mkdir_p( $this->dir ); } @@ -224,7 +224,7 @@ public function set_filename() { * @return string */ public function hash( array $given_array ) { - return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. + return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. } /** @@ -432,7 +432,7 @@ public function get_internal_content() { $fragment = beans_url_to_path( $fragment ); // Stop here if it isn't a valid file. - if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. return false; } } @@ -686,7 +686,7 @@ private function get_fragments_filemtime() { } if ( file_exists( $fragment ) ) { - $fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + $fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } @@ -742,7 +742,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { foreach ( $items as $item ) { // Skip this one if it's a directory. - if ( @is_dir( $item ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + if ( @is_dir( $item ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. continue; } @@ -769,7 +769,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { } // Clean up other modified files. - @unlink( $this->dir . '/' . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + @unlink( $this->dir . '/' . $item ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } @@ -844,26 +844,38 @@ private function kill() { $this->report(); } - $html = beans_output( 'beans_compiler_error_title_text', sprintf( - '

%s

', - __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) - ) ); + $html = beans_output( + 'beans_compiler_error_title_text', + sprintf( + '

%s

', + __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) + ) + ); - $html .= beans_output( 'beans_compiler_error_message_text', sprintf( - '

%s

', - __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support. We will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) - ) ); + $html .= beans_output( + 'beans_compiler_error_message_text', + sprintf( + '

%s

', + __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support. We will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) + ) + ); - $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( - '%s', - __( 'Contact Beans Support', 'tm-beans' ) - ) ); + $html .= beans_output( + 'beans_compiler_error_contact_text', + sprintf( + '%s', + __( 'Contact Beans Support', 'tm-beans' ) + ) + ); - $html .= beans_output( 'beans_compiler_error_report_text', sprintf( - '

%1$s. %2$s

', - __( 'Send us an automatic report', 'tm-beans' ), - __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) - ) ); + $html .= beans_output( + 'beans_compiler_error_report_text', + sprintf( + '

%1$s. %2$s

', + __( 'Send us an automatic report', 'tm-beans' ), + __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) + ) + ); wp_die( wp_kses_post( $html ) ); } diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 2ee3150b..a8f18e98 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -108,10 +108,14 @@ public function compile_page_scripts() { $this->dequeued_scripts = $scripts; add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); - beans_compile_js_fragments( 'beans', $scripts, array( - 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), - 'version' => null, - ) ); + beans_compile_js_fragments( + 'beans', + $scripts, + array( + 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), + 'version' => null, + ) + ); } /** diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 9c3ffb27..9e6c5b3a 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -217,7 +217,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { foreach ( beans_scandir( $dir ) as $item ) { if ( beans_str_ends_with( $item, ".{$file_format}" ) ) { - @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } } diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index cedb6e17..99a71603 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -129,14 +129,17 @@ private function add() { * @return array */ private function standardize_field( array $field ) { - $field = array_merge( array( - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => $this->context, - 'attributes' => array(), - 'db_group' => false, - ), $field ); + $field = array_merge( + array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => $this->context, + 'attributes' => array(), + 'db_group' => false, + ), + $field + ); // Set the field's name. $field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 1e23e5d3..31bda0a5 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -98,9 +98,14 @@ function beans_field( array $field ) { $group_field_type = 'group' === $field['type']; - beans_open_markup_e( 'beans_field_wrap', 'div', array( - 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], - ), $field ); + beans_open_markup_e( + 'beans_field_wrap', + 'div', + array( + 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], + ), + $field + ); // Set fields loop to cater for groups. if ( $group_field_type ) { @@ -109,26 +114,46 @@ function beans_field( array $field ) { $fields = array( $field ); } - beans_open_markup_e( 'beans_field_inside', 'div', array( - 'class' => 'bs-field-inside', - ), $fields ); + beans_open_markup_e( + 'beans_field_inside', + 'div', + array( + 'class' => 'bs-field-inside', + ), + $fields + ); if ( $group_field_type ) { - beans_open_markup_e( 'beans_field_group_fieldset', 'fieldset', array( - 'class' => 'bs-field-fieldset', - ), $field ); - beans_open_markup_e( 'beans_field_group_legend', 'legend', array( - 'class' => 'bs-field-legend', - ), $field ); + beans_open_markup_e( + 'beans_field_group_fieldset', + 'fieldset', + array( + 'class' => 'bs-field-fieldset', + ), + $field + ); + beans_open_markup_e( + 'beans_field_group_legend', + 'legend', + array( + 'class' => 'bs-field-legend', + ), + $field + ); echo esc_html( $field['label'] ); beans_close_markup_e( 'beans_field_group_legend', 'legend', $field ); } // Loop through fields. foreach ( $fields as $single_field ) { - beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( - 'class' => 'bs-field bs-' . $single_field['type'], - ), $single_field ); + beans_open_markup_e( + 'beans_field[_' . $single_field['id'] . ']', + 'div', + array( + 'class' => 'bs-field bs-' . $single_field['type'], + ), + $single_field + ); if ( $group_field_type ) { /** diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 6866aa52..6c3dfe9c 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -63,12 +63,15 @@ function beans_field_image( array $field ) { * @return array */ function _beans_get_image_id_attributes( $id, array $field, $is_multiple ) { - $attributes = array_merge( array( - 'class' => 'image-id', - 'type' => 'hidden', - 'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. - 'value' => $id, - ), $field['attributes'] ); + $attributes = array_merge( + array( + 'class' => 'image-id', + 'type' => 'hidden', + 'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. + 'value' => $id, + ), + $field['attributes'] + ); if ( 'placeholder' === $id ) { $attributes = array_merge( diff --git a/lib/api/fields/types/radio.php b/lib/api/fields/types/radio.php index d9e936fa..554f7785 100644 --- a/lib/api/fields/types/radio.php +++ b/lib/api/fields/types/radio.php @@ -84,11 +84,14 @@ function _beans_standardize_radio_image( $value, $radio ) { ); } - $radio = array_merge( array( - 'src' => '', - 'alt' => '', - 'screen_reader_text' => '', - ), $radio ); + $radio = array_merge( + array( + 'src' => '', + 'alt' => '', + 'screen_reader_text' => '', + ), + $radio + ); if ( $radio['screen_reader_text'] && $radio['alt'] ) { return $radio; diff --git a/lib/api/fields/types/text.php b/lib/api/fields/types/text.php index ebad377a..15325b8a 100644 --- a/lib/api/fields/types/text.php +++ b/lib/api/fields/types/text.php @@ -22,7 +22,8 @@ * } */ function beans_field_text( array $field ) { - printf( '', + printf( + '', esc_attr( $field['id'] ), esc_attr( $field['name'] ), esc_attr( $field['value'] ), diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index 543495f8..c6bd640a 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -22,10 +22,12 @@ * } */ function beans_field_textarea( array $field ) { - printf( '', + printf( + '', esc_attr( $field['id'] ), esc_attr( $field['name'] ), - beans_esc_attributes( $field['attributes'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. + beans_esc_attributes( $field['attributes'] ), esc_textarea( $field['value'] ) ); } diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php index b80eeb96..2e1088b9 100644 --- a/lib/api/image/class-beans-image-editor.php +++ b/lib/api/image/class-beans-image-editor.php @@ -1,4 +1,4 @@ -grebuilt_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $this->rebuilt_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } else { $width = null; $height = null; @@ -165,7 +165,7 @@ private function get_image_info( $src, $edited_image_exists = false ) { private function rebuild_image_path() { $upload_dir = beans_get_images_dir(); $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); - $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. + $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. $extension = $info['extension']; $filename = str_replace( '.' . $extension, '', $info['basename'] ); diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index ca2e97b4..d93e671c 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -44,7 +44,8 @@ public function register() { return beans_register_options( $this->get_fields_to_register(), 'beans_settings', - 'images_options', array( + 'images_options', + array( 'title' => __( 'Images options', 'tm-beans' ), 'context' => $this->has_metaboxes() ? 'column' : 'normal', ) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index d1028f16..baa36da7 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -103,12 +103,15 @@ function beans_get_layout_class( $id ) { * @type string $breakpoint The UIkit grid breakpoint which may be set to 'small', 'medium' or 'large'. Default 'medium'. * } */ - $args = apply_filters( 'beans_layout_grid_settings', array( - 'grid' => 4, - 'sidebar_primary' => 1, - 'sidebar_secondary' => 1, - 'breakpoint' => 'medium', - ) ); + $args = apply_filters( + 'beans_layout_grid_settings', + array( + 'grid' => 4, + 'sidebar_primary' => 1, + 'sidebar_secondary' => 1, + 'breakpoint' => 'medium', + ) + ); /** * Filter the layout class. @@ -276,13 +279,16 @@ function beans_get_layouts_for_options( $add_default = false ) { return $layouts; } - $layouts = array_merge( array( - 'default_fallback' => sprintf( - // translators: The (%s) placeholder is for the "Modify" hyperlink. - __( 'Use Default Layout (%s)', 'tm-beans' ), - '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' + $layouts = array_merge( + array( + 'default_fallback' => sprintf( + // translators: The (%s) placeholder is for the "Modify" hyperlink. + __( 'Use Default Layout (%s)', 'tm-beans' ), + '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' + ), ), - ), $layouts ); + $layouts + ); return $layouts; } diff --git a/lib/api/template/functions.php b/lib/api/template/functions.php index 77f871d5..9dd04a89 100644 --- a/lib/api/template/functions.php +++ b/lib/api/template/functions.php @@ -137,7 +137,8 @@ function beans_comment_callback( $comment, array $args, $depth ) { // Render the opening
  • tag. $comment_class = empty( $args['has_children'] ) ? '' : 'parent'; - printf( '
  • ', + printf( + '
  • ', (int) get_comment_ID(), comment_class( $comment_class, $comment, null, false ) ); diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 6abfcf3c..3d566910 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -83,11 +83,11 @@ function beans_remove_dir( $dir_path ) { if ( is_dir( $path ) ) { beans_remove_dir( $path ); } else { - @unlink( $path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + @unlink( $path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } - return @rmdir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + return @rmdir( $dir_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } /** @@ -100,7 +100,7 @@ function beans_remove_dir( $dir_path ) { * @return array|bool Returns false upon error. */ function beans_scandir( $dir_path ) { - $items = @scandir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + $items = @scandir( $dir_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. if ( ! $items ) { return false; @@ -567,12 +567,15 @@ function beans_esc_attributes( $attributes ) { * * @param array $method Associative array of selectors as keys and escaping method as values. */ - $methods = apply_filters( 'beans_escape_attributes_methods', array( - 'href' => 'esc_url', - 'src' => 'esc_url', - 'itemtype' => 'esc_url', - 'onclick' => 'esc_js', - ) ); + $methods = apply_filters( + 'beans_escape_attributes_methods', + array( + 'href' => 'esc_url', + 'src' => 'esc_url', + 'itemtype' => 'esc_url', + 'onclick' => 'esc_js', + ) + ); $string = ''; diff --git a/lib/api/widget/functions.php b/lib/api/widget/functions.php index 7d9b7413..a2a5c634 100644 --- a/lib/api/widget/functions.php +++ b/lib/api/widget/functions.php @@ -55,12 +55,15 @@ function beans_register_widget_area( $args = array() ) { * * @since 1.0.0 */ - $defaults = apply_filters( 'beans_widgets_area_default_args', array( - 'beans_type' => 'stack', - 'beans_show_widget_title' => true, - 'beans_show_widget_badge' => false, - 'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ), - ) ); + $defaults = apply_filters( + 'beans_widgets_area_default_args', + array( + 'beans_type' => 'stack', + 'beans_show_widget_title' => true, + 'beans_show_widget_badge' => false, + 'beans_widget_badge_content' => __( 'Hello', 'tm-beans' ), + ) + ); /** * Filter the arguments used by the widget area. @@ -471,11 +474,14 @@ function _beans_setup_widgets( $widget_area_content ) { $widget['content'] = $content; // Add widget control arguments and register widget. - $_beans_widgets[ $widget['id'] ] = array_merge( $widget, array( - 'show_title' => $_beans_widget_area['beans_show_widget_title'], - 'badge' => $_beans_widget_area['beans_show_widget_badge'], - 'badge_content' => $_beans_widget_area['beans_widget_badge_content'], - ) ); + $_beans_widgets[ $widget['id'] ] = array_merge( + $widget, + array( + 'show_title' => $_beans_widget_area['beans_show_widget_title'], + 'badge' => $_beans_widget_area['beans_show_widget_badge'], + 'badge_content' => $_beans_widget_area['beans_widget_badge_content'], + ) + ); } return $_beans_widgets; diff --git a/lib/init.php b/lib/init.php index 8fae51f1..0d0d382d 100644 --- a/lib/init.php +++ b/lib/init.php @@ -68,19 +68,21 @@ function beans_load_dependencies() { require_once BEANS_API_PATH . 'init.php'; // Load the necessary Beans components. - beans_load_api_components( array( - 'actions', - 'html', - 'term-meta', - 'post-meta', - 'image', - 'wp-customize', - 'compiler', - 'uikit', - 'template', - 'layout', - 'widget', - ) ); + beans_load_api_components( + array( + 'actions', + 'html', + 'term-meta', + 'post-meta', + 'image', + 'wp-customize', + 'compiler', + 'uikit', + 'template', + 'layout', + 'widget', + ) + ); // Add third party styles and scripts compiler support. beans_add_api_component_support( 'wp_styles_compiler' ); @@ -110,13 +112,16 @@ function beans_add_theme_support() { add_theme_support( 'post-thumbnails' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) ); - add_theme_support( 'custom-header', array( - 'width' => 2000, - 'height' => 500, - 'flex-height' => true, - 'flex-width' => true, - 'header-text' => false, - ) ); + add_theme_support( + 'custom-header', + array( + 'width' => 2000, + 'height' => 500, + 'flex-height' => true, + 'flex-width' => true, + 'header-text' => false, + ) + ); // Beans specific. add_theme_support( 'offcanvas-menu' ); diff --git a/lib/render/menu.php b/lib/render/menu.php index d013212c..4d0bb694 100644 --- a/lib/render/menu.php +++ b/lib/render/menu.php @@ -48,9 +48,11 @@ function beans_do_register_default_menu() { * @return void */ function beans_do_register_nav_menus() { - register_nav_menus( array( - 'primary' => __( 'Primary Menu', 'tm-beans' ), - ) ); + register_nav_menus( + array( + 'primary' => __( 'Primary Menu', 'tm-beans' ), + ) + ); } // Filter. diff --git a/lib/render/widget-area.php b/lib/render/widget-area.php index 27f44536..4eb93521 100644 --- a/lib/render/widget-area.php +++ b/lib/render/widget-area.php @@ -17,22 +17,28 @@ */ function beans_do_register_widget_areas() { // Keep primary sidebar first for default widget asignment. - beans_register_widget_area( array( - 'name' => __( 'Sidebar Primary', 'tm-beans' ), - 'id' => 'sidebar_primary', - ) ); + beans_register_widget_area( + array( + 'name' => __( 'Sidebar Primary', 'tm-beans' ), + 'id' => 'sidebar_primary', + ) + ); - beans_register_widget_area( array( - 'name' => __( 'Sidebar Secondary', 'tm-beans' ), - 'id' => 'sidebar_secondary', - ) ); + beans_register_widget_area( + array( + 'name' => __( 'Sidebar Secondary', 'tm-beans' ), + 'id' => 'sidebar_secondary', + ) + ); if ( current_theme_supports( 'offcanvas-menu' ) ) { - beans_register_widget_area( array( - 'name' => __( 'Off-Canvas Menu', 'tm-beans' ), - 'id' => 'offcanvas_menu', - 'beans_type' => 'offcanvas', - ) ); + beans_register_widget_area( + array( + 'name' => __( 'Off-Canvas Menu', 'tm-beans' ), + 'id' => 'offcanvas_menu', + 'beans_type' => 'offcanvas', + ) + ); } } diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 84e6576d..d80f1e1e 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -20,7 +20,8 @@ function beans_comments_title() { beans_open_markup_e( 'beans_comments_title', 'h2' ); beans_output_e( - 'beans_comments_title_text', sprintf( + 'beans_comments_title_text', + sprintf( // translators: Number of comments, one or many. _n( '%s Comment', '%s Comments', get_comments_number(), 'tm-beans' ), number_format_i18n( get_comments_number() ) @@ -149,7 +150,8 @@ function beans_comment_metadata() { ); beans_output_e( - 'beans_comment_time_text', sprintf( + 'beans_comment_time_text', + sprintf( // translators: Date of the comment, time of the comment. _x( '%1$s at %2$s', '1: date, 2: time', 'tm-beans' ), get_comment_date(), @@ -190,7 +192,8 @@ function beans_comment_links() { // Reply. echo get_comment_reply_link( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Echoes HTML output. array_merge( - $comment->args, array( + $comment->args, + array( 'add_below' => 'div-comment', 'depth' => $comment->depth, 'max_depth' => $comment->args['max_depth'], @@ -461,7 +464,9 @@ function beans_comment_form_comment() { } $output .= beans_open_markup( - 'beans_comment_form_field[_comment]', 'textarea', array( + 'beans_comment_form_field[_comment]', + 'textarea', + array( 'id' => 'comment', 'class' => 'uk-width-1-1', 'name' => 'comment', @@ -492,7 +497,9 @@ function beans_comment_before_fields() { beans_open_markup_e( 'beans_comment_fields_wrap', 'div', array( 'class' => 'uk-width-medium-1-1' ) ); beans_open_markup_e( - 'beans_comment_fields_inner_wrap', 'div', array( + 'beans_comment_fields_inner_wrap', + 'div', + array( 'class' => 'uk-grid uk-grid-small', 'data-uk-grid-margin' => '', ) @@ -536,7 +543,9 @@ function beans_comment_form_fields( $fields ) { } $author .= beans_selfclose_markup( - 'beans_comment_form_field[_name]', 'input', array( + 'beans_comment_form_field[_name]', + 'input', + array( 'id' => 'author', 'class' => 'uk-width-1-1', 'type' => 'text', @@ -563,7 +572,8 @@ function beans_comment_form_fields( $fields ) { if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); - $email .= beans_output( 'beans_comment_form_legend_text[_email]', + $email .= beans_output( + 'beans_comment_form_legend_text[_email]', // translators: Whether or not submitting an email address is required. sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) ); @@ -572,7 +582,9 @@ function beans_comment_form_fields( $fields ) { } $email .= beans_selfclose_markup( - 'beans_comment_form_field[_email]', 'input', array( + 'beans_comment_form_field[_email]', + 'input', + array( 'id' => 'email', 'class' => 'uk-width-1-1', 'type' => 'text', @@ -605,7 +617,9 @@ function beans_comment_form_fields( $fields ) { } $url .= beans_selfclose_markup( - 'beans_comment_form_field[_url]', 'input', array( + 'beans_comment_form_field[_url]', + 'input', + array( 'id' => 'url', 'class' => 'uk-width-1-1', 'type' => 'text', diff --git a/lib/templates/fragments/deprecated.php b/lib/templates/fragments/deprecated.php index e9a5e3f1..cec6bae5 100644 --- a/lib/templates/fragments/deprecated.php +++ b/lib/templates/fragments/deprecated.php @@ -76,7 +76,8 @@ function beans_wp_title( $title, $sep ) { global $shortcode_tags; $shortcode_tags = array_merge( // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited -- Deprecated function. - $shortcode_tags, array( + $shortcode_tags, + array( 'beans_post_meta_date' => 'beans_post_meta_date_shortcode', 'beans_post_meta_author' => 'beans_post_meta_author_shortcode', 'beans_post_meta_comments' => 'beans_post_meta_comments_shortcode', diff --git a/tests/phpunit/class-beans-resetter.php b/tests/phpunit/class-beans-resetter.php index 3f189cbb..763ecaf1 100644 --- a/tests/phpunit/class-beans-resetter.php +++ b/tests/phpunit/class-beans-resetter.php @@ -93,12 +93,15 @@ protected function reset_fields_api() { // Reset the "registered" container. $registered = $this->get_reflective_property( 'registered', '_Beans_Fields' ); - $registered->setValue( new _Beans_Fields(), [ - 'option' => [], - 'post_meta' => [], - 'term_meta' => [], - 'wp_customize' => [], - ] ); + $registered->setValue( + new _Beans_Fields(), + [ + 'option' => [], + 'post_meta' => [], + 'term_meta' => [], + 'wp_customize' => [], + ] + ); // Reset the other static properties. foreach ( [ 'field_types_loaded', 'field_assets_hook_loaded' ] as $property_name ) { diff --git a/tests/phpunit/integration/api/actions/beansReplaceAction.php b/tests/phpunit/integration/api/actions/beansReplaceAction.php index 9c15f413..a4a4fe21 100644 --- a/tests/phpunit/integration/api/actions/beansReplaceAction.php +++ b/tests/phpunit/integration/api/actions/beansReplaceAction.php @@ -242,13 +242,15 @@ public function test_should_replace_the_action() { $this->assertSame( $original_action, _beans_get_action( $beans_id, 'added' ) ); // Run the replace. - $this->assertTrue( beans_replace_action( - $beans_id, - $replaced_action['hook'], - $replaced_action['callback'], - $replaced_action['priority'], - $replaced_action['args'] - ) ); + $this->assertTrue( + beans_replace_action( + $beans_id, + $replaced_action['hook'], + $replaced_action['callback'], + $replaced_action['priority'], + $replaced_action['args'] + ) + ); // Check that the "replaced" action has been stored in Beans. $this->assertSame( $replaced_action, _beans_get_action( $beans_id, 'added' ) ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php b/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php index 1a6dbf8f..b4dff742 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler-options/register.php @@ -69,10 +69,13 @@ public function test_should_only_register_only_flush_button_when_styles_scripts_ $registered_fields = beans_get_fields( 'option', 'compiler_options' ); $this->assertNotEmpty( $registered_fields ); $this->assertCount( 1, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); + $this->assertArraySubset( + [ + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + ], + current( $registered_fields ) + ); // Check that the metabox did get registered. global $wp_meta_boxes; @@ -98,15 +101,21 @@ public function test_should_not_register_styles_options_when_not_supported() { // Check that the right fields did get registered. $registered_fields = beans_get_fields( 'option', 'compiler_options' ); $this->assertCount( 2, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_scripts_group', - 'label' => 'Compile all WordPress scripts', - 'type' => 'group', - ], next( $registered_fields ) ); + $this->assertArraySubset( + [ + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + ], + current( $registered_fields ) + ); + $this->assertArraySubset( + [ + 'id' => 'beans_compile_all_scripts_group', + 'label' => 'Compile all WordPress scripts', + 'type' => 'group', + ], + next( $registered_fields ) + ); // Check that the metabox did get registered. global $wp_meta_boxes; @@ -132,17 +141,23 @@ public function test_should_not_register_scripts_options_when_not_supported() { // Check that the right fields did get registered. $registered_fields = beans_get_fields( 'option', 'compiler_options' ); $this->assertCount( 2, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_styles', - 'label' => 'Compile all WordPress styles', - 'checkbox_label' => 'Select to compile styles.', - 'type' => 'checkbox', - 'default' => false, - ], next( $registered_fields ) ); + $this->assertArraySubset( + [ + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + ], + current( $registered_fields ) + ); + $this->assertArraySubset( + [ + 'id' => 'beans_compile_all_styles', + 'label' => 'Compile all WordPress styles', + 'checkbox_label' => 'Select to compile styles.', + 'type' => 'checkbox', + 'default' => false, + ], + next( $registered_fields ) + ); // Check that the metabox did get registered. global $wp_meta_boxes; @@ -168,22 +183,31 @@ public function test_should_register_all_options_when_styles_scripts_supported() // Check that the right fields did get registered. $registered_fields = beans_get_fields( 'option', 'compiler_options' ); $this->assertCount( 3, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_compiler_items', - 'type' => 'flush_cache', - ], current( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_styles', - 'label' => 'Compile all WordPress styles', - 'checkbox_label' => 'Select to compile styles.', - 'type' => 'checkbox', - 'default' => false, - ], next( $registered_fields ) ); - $this->assertArraySubset( [ - 'id' => 'beans_compile_all_scripts_group', - 'label' => 'Compile all WordPress scripts', - 'type' => 'group', - ], next( $registered_fields ) ); + $this->assertArraySubset( + [ + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + ], + current( $registered_fields ) + ); + $this->assertArraySubset( + [ + 'id' => 'beans_compile_all_styles', + 'label' => 'Compile all WordPress styles', + 'checkbox_label' => 'Select to compile styles.', + 'type' => 'checkbox', + 'default' => false, + ], + next( $registered_fields ) + ); + $this->assertArraySubset( + [ + 'id' => 'beans_compile_all_scripts_group', + 'label' => 'Compile all WordPress scripts', + 'type' => 'group', + ], + next( $registered_fields ) + ); // Check that the metabox did get registered. global $wp_meta_boxes; diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php index 462bdcf0..06965a51 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/combineFragments.php @@ -93,15 +93,17 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { * Test _Beans_Compiler::combine_fragments() should compile the Less fragments and return the compiled CSS. */ public function test_should_compile_less_and_return_css() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -124,15 +126,17 @@ public function test_should_compile_less_and_return_css() { * Test _Beans_Compiler::combine_fragments() should return minified, compiled Less from the Less combined fragments. */ public function test_should_return_minified_compiled_less() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -148,15 +152,17 @@ public function test_should_return_minified_compiled_less() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ], + 'dependencies' => [ 'jquery' ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -172,15 +178,17 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ], + 'dependencies' => [ 'jquery' ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -195,15 +203,17 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ], + 'dependencies' => [ 'jquery' ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -219,14 +229,16 @@ public function test_should_return_minified_jquery() { * mode, but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -246,14 +258,16 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); @@ -271,14 +285,16 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { - $compiler = new _Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ], + ] + ); // Set up the test. $this->set_up_wp_filesystem( $compiler ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php index 774d2a24..aaf21776 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/fileystem.php @@ -43,9 +43,11 @@ public function test_should_render_report_and_die_when_no_filesystem_selected() ->once() ->andReturn( __NAMESPACE__ . '\mock_wp_die_handler' ); Functions\when( __NAMESPACE__ . '\mock_wp_die_handler' ) - ->alias( function( $message ) { - $this->assertContains( 'Beans cannot work its magic', $message ); - } ); + ->alias( + function( $message ) { + $this->assertContains( 'Beans cannot work its magic', $message ); + } + ); add_filter( 'wp_die_handler', __NAMESPACE__ . '\set_wp_die_handler' ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php index 9b3d083c..ec607ad1 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/formatContent.php @@ -60,9 +60,11 @@ public function setUp() { * a style or script (per the configuration). */ public function test_should_return_original_content_when_type_not_style_or_script() { - $compiler = new \_Beans_Compiler( [ - 'type' => 'foo', - ] ); + $compiler = new \_Beans_Compiler( + [ + 'type' => 'foo', + ] + ); // Run the tests. $this->assertSame( $this->less, $compiler->format_content( $this->less ) ); @@ -75,11 +77,13 @@ public function test_should_return_original_content_when_type_not_style_or_scrip * fragments. */ public function test_should_return_compiled_css() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ] + ); // Turn on development mode. update_option( 'beans_dev_mode', true ); @@ -101,11 +105,13 @@ public function test_should_return_compiled_css() { * Test _Beans_Compiler::format_content() should return minified, compiled CSS from the Less combined fragments. */ public function test_should_return_minified_compiled_css() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ] + ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -123,11 +129,13 @@ public function test_should_return_minified_compiled_css() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ] + ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -141,11 +149,13 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); // Turn on development mode. update_option( 'beans_dev_mode', true ); @@ -159,11 +169,13 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -182,11 +194,13 @@ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_mini * mode, but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ] + ); // Turn off development mode. update_option( 'beans_dev_mode', false ); @@ -200,11 +214,13 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); // Turn on development mode. update_option( 'beans_dev_mode', true ); @@ -218,11 +234,13 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = new \_Beans_Compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = new \_Beans_Compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); // Turn off development mode. update_option( 'beans_dev_mode', false ); diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php index 5f7d5cec..69ea7ab1 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getInternalContent.php @@ -40,9 +40,11 @@ public function test_should_return_false_when_fragment_is_empty() { public function test_should_return_false_when_file_does_not_exist() { // Set up the compiler. $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'fragments' => [ $fragment ], + ] + ); $this->set_current_fragment( $compiler, $fragment ); // Run the test. @@ -55,9 +57,11 @@ public function test_should_return_false_when_file_does_not_exist() { public function test_should_return_fragment_contents() { // Set up the compiler. $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'fragments' => [ $fragment ], + ] + ); $this->set_current_fragment( $compiler, $fragment ); // Set the WP Filesystem. diff --git a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php index b36962f9..87ec0603 100644 --- a/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/integration/api/compiler/beans-compiler/getRemoteContent.php @@ -39,9 +39,11 @@ public function test_should_return_false_when_fragment_is_empty() { */ public function test_should_return_empty_string_when_remote_does_not_exist() { $fragment = 'http://beans.local/invalid-file.js'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'fragments' => [ $fragment ], + ] + ); $this->set_current_fragment( $compiler, $fragment ); // Run the test. @@ -53,9 +55,11 @@ public function test_should_return_empty_string_when_remote_does_not_exist() { */ public function test_should_return_content_when_fragment_is_relative_url() { $fragment = '//fonts.googleapis.com/css?family=Lato'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'fragments' => [ $fragment ], + ] + ); $this->set_current_fragment( $compiler, $fragment ); $content = $compiler->get_remote_content( $fragment ); @@ -72,9 +76,11 @@ public function test_should_return_content_when_fragment_is_relative_url() { */ public function test_should_return_content_when_fragment_is_http() { $fragment = 'http://fonts.googleapis.com/css?family=Roboto'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'fragments' => [ $fragment ], + ] + ); $this->set_current_fragment( $compiler, $fragment ); $content = $compiler->get_remote_content( $fragment ); @@ -90,10 +96,14 @@ public function test_should_return_content_when_fragment_is_http() { * Test _Beans_Compiler::get_remote_content() should return the content when fragment is an https URL. */ public function test_should_return_content_when_fragment_is_https() { + $this->markTestSkipped( 'wp_remote_get returns cURL error 60. Test must be revisited.' ); + $fragment = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'; - $compiler = new _Beans_Compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = new _Beans_Compiler( + [ + 'fragments' => [ $fragment ], + ] + ); $this->set_current_fragment( $compiler, $fragment ); $content = $compiler->get_remote_content( $fragment ); diff --git a/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php b/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php index ad53250f..b8ba412b 100644 --- a/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php +++ b/tests/phpunit/integration/api/compiler/beans-page-compiler/dequeueScripts.php @@ -61,10 +61,13 @@ public function test_should_not_dequeue_when_no_scripts_registered() { public function test_should_dequeue_scripts() { $compiler = new _Beans_Page_Compiler(); $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ] ); + $dequeued_scripts->setValue( + $compiler, + [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ] + ); // Set up the scripts. wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); @@ -82,10 +85,13 @@ public function test_should_dequeue_scripts() { public function test_should_not_print_inline_when_no_scripts_have_localized_data() { $compiler = new _Beans_Page_Compiler(); $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ] ); + $dequeued_scripts->setValue( + $compiler, + [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ] + ); // Set up the scripts. wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); @@ -103,10 +109,13 @@ public function test_should_not_print_inline_when_no_scripts_have_localized_data public function test_should_print_inline_localization_content() { $compiler = new _Beans_Page_Compiler(); $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'test-compiler-js' => '/foo/tests/compiler.js', - 'test-uikit-js' => '/foo/tests/uikit.js', - ] ); + $dequeued_scripts->setValue( + $compiler, + [ + 'test-compiler-js' => '/foo/tests/compiler.js', + 'test-uikit-js' => '/foo/tests/uikit.js', + ] + ); // Set up the scripts. wp_enqueue_script( 'test-compiler-js', '/foo/tests/compiler.js' ); diff --git a/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php b/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php index ea83f029..ae21e845 100644 --- a/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php +++ b/tests/phpunit/integration/api/compiler/beansCompileJsFragments.php @@ -35,11 +35,15 @@ public function test_should_compile_save_and_enqueue_jquery() { // Run the tests. $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_js_fragments( $id, $fragment, [ - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); + beans_compile_js_fragments( + $id, + $fragment, + [ + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ] + ); $filename = $this->get_compiled_filename( $path ); $this->assertFileExists( $path . $filename ); $this->assertStringEndsWith( '.js', $filename ); @@ -58,10 +62,14 @@ public function test_should_compile_save_and_enqueue_js() { // Run the tests. $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_js_fragments( $id, $fragment, [ - 'in_footer' => true, - 'minify_js' => true, - ] ); + beans_compile_js_fragments( + $id, + $fragment, + [ + 'in_footer' => true, + 'minify_js' => true, + ] + ); $filename = $this->get_compiled_filename( $path ); $this->assertFileExists( $path . $filename ); $this->assertStringEndsWith( '.js', $filename ); @@ -83,11 +91,15 @@ public function test_should_compile_save_and_enqueue_combined_js() { // Run the tests. $this->assertEmpty( $this->get_compiled_filename( $path ) ); - beans_compile_js_fragments( $id, $fragments, [ - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); + beans_compile_js_fragments( + $id, + $fragments, + [ + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ] + ); $filename = $this->get_compiled_filename( $path ); $this->assertFileExists( $path . $filename ); $this->assertStringEndsWith( '.js', $filename ); diff --git a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php index 818d815b..b6198d32 100644 --- a/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php +++ b/tests/phpunit/integration/api/compiler/includes/class-base-test-case.php @@ -44,14 +44,17 @@ public function setUp() { $this->compiled_dir = vfsStream::url( 'compiled' ); // Set the Uploads directory to our virtual filesystem. - add_filter( 'upload_dir', function( array $uploads_dir ) { - $uploads_dir['path'] = $this->compiled_dir . $uploads_dir['subdir']; - $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); - $uploads_dir['basedir'] = $this->compiled_dir; - $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); + add_filter( + 'upload_dir', + function( array $uploads_dir ) { + $uploads_dir['path'] = $this->compiled_dir . $uploads_dir['subdir']; + $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); + $uploads_dir['basedir'] = $this->compiled_dir; + $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); - return $uploads_dir; - } ); + return $uploads_dir; + } + ); } /** diff --git a/tests/phpunit/integration/api/fields/beansField.php b/tests/phpunit/integration/api/fields/beansField.php index 102d05a7..55a353bf 100644 --- a/tests/phpunit/integration/api/fields/beansField.php +++ b/tests/phpunit/integration/api/fields/beansField.php @@ -50,13 +50,15 @@ public function test_should_render_checkbox_field() { // Set up the test. require_once BEANS_THEME_DIR . '/lib/api/fields/types/checkbox.php'; beans_add_smart_action( 'beans_field_checkbox', 'beans_field_checkbox' ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -90,17 +92,19 @@ public function test_should_render_radio_field() { // Set up the test. require_once BEANS_THEME_DIR . '/lib/api/fields/types/radio.php'; beans_add_smart_action( 'beans_field_radio', 'beans_field_radio' ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_radio_test', - 'label' => 'Having fun?', - 'description' => 'Radio buttons', - 'type' => 'radio', - 'default' => 'no', - 'options' => [ - 'no' => 'No', - 'yes' => 'Yes', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_radio_test', + 'label' => 'Having fun?', + 'description' => 'Radio buttons', + 'type' => 'radio', + 'default' => 'no', + 'options' => [ + 'no' => 'No', + 'yes' => 'Yes', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -145,32 +149,34 @@ public function test_should_render_group_of_fields() { beans_add_smart_action( 'beans_field_select', 'beans_field_select' ); // Prepare the group of fields. - $group = $this->merge_field_with_default( [ - 'id' => 'beans_group_test', - 'label' => 'Group of fields', - 'description' => 'This is a group of fields.', - 'type' => 'group', - 'context' => 'beans_group_tests', - 'fields' => [ - [ - 'id' => 'beans_group_activation_test', - 'label' => 'Activate Foo', - 'type' => 'activation', - 'default' => false, - ], - [ - 'id' => 'beans_group_select_test', - 'label' => 'Select Foo', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', + $group = $this->merge_field_with_default( + [ + 'id' => 'beans_group_test', + 'label' => 'Group of fields', + 'description' => 'This is a group of fields.', + 'type' => 'group', + 'context' => 'beans_group_tests', + 'fields' => [ + [ + 'id' => 'beans_group_activation_test', + 'label' => 'Activate Foo', + 'type' => 'activation', + 'default' => false, + ], + [ + 'id' => 'beans_group_select_test', + 'label' => 'Select Foo', + 'type' => 'select', + 'default' => 'aggressive', + 'attributes' => [ 'style' => 'margin: -3px 0 0 -8px;' ], + 'options' => [ + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ], ], ], - ], - ] ); + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php index da4c0285..def272b5 100644 --- a/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/integration/api/fields/includes/class-fields-test-case.php @@ -69,14 +69,17 @@ public function tearDown() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $field = array_merge( [ - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => 'beans_tests', - 'attributes' => [], - 'db_group' => false, - ], $field ); + $field = array_merge( + [ + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'beans_tests', + 'attributes' => [], + 'db_group' => false, + ], + $field + ); $field['name'] = 'beans_fields[' . $field['id'] . ']'; if ( 'group' === $field['type'] ) { diff --git a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php index ca2052d1..245a2c61 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldActivation.php @@ -36,11 +36,13 @@ public function setUp() { * Test beans_field_activation() should render the activation field. */ public function test_should_render_activation_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -60,14 +62,16 @@ public function test_should_render_activation_field() { * Test beans_field_activation() should render the activation field with attributes when given. */ public function test_should_render_activation_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php index 10d86c97..58518cbe 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldCheckbox.php @@ -36,13 +36,15 @@ public function setUp() { * Test beans_field_checkbox() should render the checkbox with the label when given. */ public function test_should_render_checkbox_with_label_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -62,11 +64,13 @@ public function test_should_render_checkbox_with_label_when_given() { * Test beans_field_checkbox() should render the checkbox with the default label when none is given. */ public function test_should_render_checkbox_with_default_label_when_none_is_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'type' => 'checkbox', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'type' => 'checkbox', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,15 +90,17 @@ public function test_should_render_checkbox_with_default_label_when_none_is_give * Test beans_field_checkbox() should render the checkbox with attributes when given. */ public function test_should_render_checkbox_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php index eee8a65a..ae75eed9 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldDescription.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldDescription.php @@ -36,11 +36,13 @@ public function setUp() { * Test beans_field_description() should not render the field's description when none is given. */ public function test_should_not_render_field_description_when_none_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ] + ); $this->assertNull( beans_field_description( $field ) ); @@ -52,12 +54,14 @@ public function test_should_not_render_field_description_when_none_given() { * Test beans_field_description() should render the field's description. */ public function test_should_render_field_description() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'description' => 'Testing the text field.', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'description' => 'Testing the text field.', + 'default' => '', + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -76,12 +80,14 @@ public function test_should_render_field_description() { * Test beans_field_description() should render the field's extended description. */ public function test_should_render_extended_description() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'description' => 'Testing the text field.This is the extended part of the description.', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'description' => 'Testing the text field.This is the extended part of the description.', + 'default' => '', + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldImage.php b/tests/phpunit/integration/api/fields/types/beansFieldImage.php index fc50420a..6049f735 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldImage.php @@ -37,18 +37,25 @@ public function setUp() { */ public function test_should_render_single_image_field_and_hide_upload_button_when_image_exists() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); + $image_id = self::factory()->attachment->create_object( + 'image.png', + $post_id, + [ + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ] + ); update_post_meta( $image_id, '_wp_attachment_image_alt', 'This is the alt value.', true ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => $image_id, - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => $image_id, + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -89,24 +96,35 @@ public function test_should_render_single_image_field_and_hide_upload_button_whe public function test_should_render_multiple_images_field_and_show_upload_button_when_images_exist() { $images = []; $post_id = self::factory()->post->create(); - $images[] = self::factory()->attachment->create_object( 'image-1.png', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); + $images[] = self::factory()->attachment->create_object( + 'image-1.png', + $post_id, + [ + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ] + ); update_post_meta( $images[0], '_wp_attachment_image_alt', 'Image 1 alt.', true ); - $images[] = self::factory()->attachment->create_object( 'image-2.png', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); + $images[] = self::factory()->attachment->create_object( + 'image-2.png', + $post_id, + [ + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ] + ); update_post_meta( $images[1], '_wp_attachment_image_alt', 'Image 2 alt.', true ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => $images, - 'multiple' => true, - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => $images, + 'multiple' => true, + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -158,17 +176,24 @@ public function test_should_render_multiple_images_field_and_show_upload_button_ */ public function test_should_render_single_image_field_with_default_alt_when_none_exists() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); + $image_id = self::factory()->attachment->create_object( + 'image.png', + $post_id, + [ + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ] + ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => $image_id, - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => $image_id, + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -211,12 +236,15 @@ public function test_should_render_single_image_field_with_default_alt_when_none */ public function test_should_show_upload_button_for_single_image_field_without_image() { $post_id = self::factory()->post->create(); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => null, // Attachment ID. - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => null, // Attachment ID. + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -249,13 +277,16 @@ public function test_should_show_upload_button_for_single_image_field_without_im */ public function test_should_show_upload_button_for_multiple_image_field_without_image() { $post_id = self::factory()->post->create(); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'multiple' => true, - 'value' => null, // Attachment ID. - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'multiple' => true, + 'value' => null, // Attachment ID. + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php index 0794ba9a..99e97c13 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldLabel.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldLabel.php @@ -36,11 +36,13 @@ public function setUp() { * Test beans_field_label() should not render the field's label when none is given. */ public function test_should_not_render_field_label_when_none_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ] + ); $this->assertNull( beans_field_label( $field ) ); @@ -52,12 +54,14 @@ public function test_should_not_render_field_label_when_none_given() { * Test beans_field_label() should render the field's label. */ public function test_should_render_field_label() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'label' => 'Testing the text field.', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'label' => 'Testing the text field.', + 'default' => '', + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -75,29 +79,31 @@ public function test_should_render_field_label() { * Test beans_field_label() should not render the radio field's group label. */ public function test_should_not_render_radio_group_label() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option for the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/sp_c.png', - 'alt' => 'Sidebar Primary + Content Layout', + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_layout', + 'label' => 'Layout', + 'description' => 'The layout settings.', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => [ + 'default_fallback' => 'Use Default Layout', + 'c' => [ + 'src' => 'http://example.com/images/layouts/c.png', + 'alt' => 'Content Only Layout', + 'screen_reader_text' => 'Option for the Content Only Layout', + ], + 'c_sp' => [ + 'src' => 'http://example.com/images/layouts/c_sp.png', + 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', + ], + 'sp_c' => [ + 'src' => 'http://example.com/images/layouts/sp_c.png', + 'alt' => 'Sidebar Primary + Content Layout', + ], ], - ], - ] ); + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php index 6270880a..091b280d 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldRadio.php @@ -36,19 +36,21 @@ public function setUp() { * Test beans_field_radio() should render the radio field with image options. */ public function test_should_render_radio_field_with_image_options() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => 'http://example.com/images/layouts/c.png', - 'c_sp' => 'http://example.com/images/layouts/c_sp.png', - 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_layout', + 'label' => 'Layout', + 'description' => 'The layout settings.', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => [ + 'default_fallback' => 'Use Default Layout', + 'c' => 'http://example.com/images/layouts/c.png', + 'c_sp' => 'http://example.com/images/layouts/c_sp.png', + 'sp_c' => 'http://example.com/images/layouts/sp_c.png', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,29 +88,31 @@ public function test_should_render_radio_field_with_image_options() { * Test beans_field_radio() should render accessible images when accessibility parameters are given. */ public function test_should_render_accessible_images_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option for the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/sp_c.png', - 'alt' => 'Sidebar Primary + Content Layout', + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_layout', + 'label' => 'Layout', + 'description' => 'The layout settings.', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => [ + 'default_fallback' => 'Use Default Layout', + 'c' => [ + 'src' => 'http://example.com/images/layouts/c.png', + 'alt' => 'Content Only Layout', + 'screen_reader_text' => 'Option for the Content Only Layout', + ], + 'c_sp' => [ + 'src' => 'http://example.com/images/layouts/c_sp.png', + 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', + ], + 'sp_c' => [ + 'src' => 'http://example.com/images/layouts/sp_c.png', + 'alt' => 'Sidebar Primary + Content Layout', + ], ], - ], - ] ); + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php index 283096c1..cdf931d7 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSelect.php @@ -36,15 +36,17 @@ public function setUp() { * Test beans_field_select() should render the select field. */ public function test_should_render_select_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'options' => [ + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -65,18 +67,20 @@ public function test_should_render_select_field() { * Test beans_field_select() should render the select field with attributes when given. */ public function test_should_render_select_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'standard', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - 'attributes' => [ - 'style' => 'margin: -3px 0 0 -8px;', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'standard', + 'options' => [ + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ], + 'attributes' => [ + 'style' => 'margin: -3px 0 0 -8px;', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php index a816c6f2..c5770cd3 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldSlider.php @@ -36,16 +36,18 @@ public function setUp() { * Test beans_field_slider() should render the slider field. */ public function test_should_render_slider_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 0, - 'max' => 100, - 'interval' => 1, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 0, + 'max' => 100, + 'interval' => 1, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -66,17 +68,19 @@ public function test_should_render_slider_field() { * Test beans_field_slider() should render the slider field with unit when given. */ public function test_should_render_slider_field_with_unit_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - 'unit' => 'Number of beans', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + 'unit' => 'Number of beans', + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -98,16 +102,18 @@ public function test_should_render_slider_field_with_unit_when_given() { * Test beans_field_slider() should render the slider with the current value. */ public function test_should_render_slider_with_current_value() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + ] + ); $field['value'] = 15; // Run the function and grab the HTML out of the buffer. @@ -129,20 +135,22 @@ public function test_should_render_slider_with_current_value() { * Test beans_field_slider() should render the slider field with attributes when given. */ public function test_should_render_slider_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 1, - 'min' => 1, - 'max' => 20, - 'interval' => 1, - 'unit' => 'Number of beans', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 1, + 'min' => 1, + 'max' => 20, + 'interval' => 1, + 'unit' => 'Number of beans', + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/integration/api/fields/types/beansFieldText.php b/tests/phpunit/integration/api/fields/types/beansFieldText.php index b093d7a3..944cf672 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldText.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldText.php @@ -36,11 +36,13 @@ public function setUp() { * Test beans_field_text() should render the text field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ] + ); $field['value'] = 'Testing the text field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +61,16 @@ public function test_should_render_text_field() { * Test beans_field_text() should render the text field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); $field['value'] = 'Testing the text field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php index ea00fe18..072956cf 100644 --- a/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/integration/api/fields/types/beansFieldTextarea.php @@ -36,11 +36,13 @@ public function setUp() { * Test beans_field_textarea() should render the textarea field. */ public function test_should_render_textarea_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + ] + ); $field['value'] = 'Testing the textarea field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +61,16 @@ public function test_should_render_textarea_field() { * Test beans_field_textarea() should render the textarea field with attributes when given. */ public function test_should_render_textarea_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); $field['value'] = 'Testing the textarea field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php b/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php index 204daaf2..a23f8c02 100644 --- a/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php +++ b/tests/phpunit/integration/api/fields/types/beansGetImageAlt.php @@ -47,10 +47,14 @@ public function test_should_return_null_when_invalid_image_id_given() { */ public function test_should_return_default_alt_when_image_alt_not_defined() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.png', $post_id, [ - 'post_mime_type' => 'image/png', - 'post_type' => 'attachment', - ] ); + $image_id = self::factory()->attachment->create_object( + 'image.png', + $post_id, + [ + 'post_mime_type' => 'image/png', + 'post_type' => 'attachment', + ] + ); // Run the test. $this->assertSame( 'Sorry, no description was given for this image.', _beans_get_image_alt( $image_id ) ); @@ -61,10 +65,14 @@ public function test_should_return_default_alt_when_image_alt_not_defined() { */ public function test_should_return_image_alt() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); + $image_id = self::factory()->attachment->create_object( + 'image.jpeg', + $post_id, + [ + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ] + ); $alt = 'This is the alt value.'; update_post_meta( $image_id, '_wp_attachment_image_alt', $alt, true ); diff --git a/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php b/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php index 53ea86de..b989f646 100644 --- a/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php +++ b/tests/phpunit/integration/api/fields/types/beansGetImageUrl.php @@ -54,10 +54,14 @@ public function test_should_return_null_when_image_does_not_exist() { */ public function test_should_return_image_url() { $post_id = self::factory()->post->create(); - $image_id = self::factory()->attachment->create_object( 'image.jpeg', $post_id, [ - 'post_mime_type' => 'image/jpeg', - 'post_type' => 'attachment', - ] ); + $image_id = self::factory()->attachment->create_object( + 'image.jpeg', + $post_id, + [ + 'post_mime_type' => 'image/jpeg', + 'post_type' => 'attachment', + ] + ); // Run the test. $this->assertSame( 'http://example.org/wp-content/uploads/image.jpeg', _beans_get_image_url( $image_id ) ); diff --git a/tests/phpunit/integration/api/filters/beansApplyFilters.php b/tests/phpunit/integration/api/filters/beansApplyFilters.php index e1d112b0..a31969b3 100644 --- a/tests/phpunit/integration/api/filters/beansApplyFilters.php +++ b/tests/phpunit/integration/api/filters/beansApplyFilters.php @@ -52,14 +52,20 @@ public function test_should_return_value_after_calling_one_level_of_sub_hooks() public function test_should_return_value_after_calling_two_levels_of_sub_hooks() { add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - add_filter( 'beans_test_query_args[_second]', function( $args ) { - $args[] = '_second'; - return $args; - } ); - add_filter( 'beans_test_query_args[_main][_second]', function( $args ) { - $args[] = '[_main][_second]'; - return $args; - } ); + add_filter( + 'beans_test_query_args[_second]', + function( $args ) { + $args[] = '_second'; + return $args; + } + ); + add_filter( + 'beans_test_query_args[_main][_second]', + function( $args ) { + $args[] = '[_main][_second]'; + return $args; + } + ); $this->assertSame( [ 'base', '_main', '_second', '[_main][_second]' ], @@ -73,22 +79,34 @@ public function test_should_return_value_after_calling_two_levels_of_sub_hooks() public function test_should_return_value_after_calling_three_levels_of_sub_hooks() { add_filter( 'beans_test_query_args', 'beans_test_query_args_base' ); add_filter( 'beans_test_query_args[_main]', 'beans_test_query_args_main' ); - add_filter( 'beans_test_query_args[_second]', function( $args ) { - $args[] = '_second'; - return $args; - } ); - add_filter( 'beans_test_query_args[_main][_second]', function( $args ) { - $args[] = '[_main][_second]'; - return $args; - } ); - add_filter( 'beans_test_query_args[_third]', function( $args ) { - $args[] = '_third'; - return $args; - } ); - add_filter( 'beans_test_query_args[_main][_second][_third]', function( $args ) { - $args[] = '[_main][_second][_third]'; - return $args; - } ); + add_filter( + 'beans_test_query_args[_second]', + function( $args ) { + $args[] = '_second'; + return $args; + } + ); + add_filter( + 'beans_test_query_args[_main][_second]', + function( $args ) { + $args[] = '[_main][_second]'; + return $args; + } + ); + add_filter( + 'beans_test_query_args[_third]', + function( $args ) { + $args[] = '_third'; + return $args; + } + ); + add_filter( + 'beans_test_query_args[_main][_second][_third]', + function( $args ) { + $args[] = '[_main][_second][_third]'; + return $args; + } + ); $this->assertSame( [ 'base', '_main', '_second', '[_main][_second]', '_third', '[_main][_second][_third]' ], diff --git a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php index c8508603..b1da502a 100644 --- a/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/integration/api/filters/includes/class-filters-test-case.php @@ -98,14 +98,18 @@ protected function go_to_post() { * Define the mocks for the filter callbacks. */ protected function mock_filter_callbacks() { - Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { - return $post_title . '_' . $post_id; - } ); + Monkey\Functions\when( 'beans_test_the_content' )->alias( + function ( $post_title, $post_id ) { + return $post_title . '_' . $post_id; + } + ); Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( [ 'base' ] ); - Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { - $args[] = '_main'; - return $args; - } ); + Monkey\Functions\when( 'beans_test_query_args_main' )->alias( + function ( $args ) { + $args[] = '_main'; + return $args; + } + ); } } diff --git a/tests/phpunit/integration/api/html/beansAddAttributes.php b/tests/phpunit/integration/api/html/beansAddAttributes.php index 7f3b30f0..168469f6 100644 --- a/tests/phpunit/integration/api/html/beansAddAttributes.php +++ b/tests/phpunit/integration/api/html/beansAddAttributes.php @@ -63,9 +63,11 @@ public function test_should_return_filtered_attributes_when_registered_callback( Monkey\Functions\expect( 'foo_attributes_callback' ) ->with( $attributes ) ->once() - ->andReturnUsing( function ( $attributes ) { - return [ 'class' => 'changed-me' ]; - } ); + ->andReturnUsing( + function ( $attributes ) { + return [ 'class' => 'changed-me' ]; + } + ); add_action( 'foo_attributes', 'foo_attributes_callback' ); // Run the test. diff --git a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php index 792bea8d..816e67f7 100644 --- a/tests/phpunit/integration/api/html/beansBuildSkipLinks.php +++ b/tests/phpunit/integration/api/html/beansBuildSkipLinks.php @@ -27,9 +27,12 @@ class Tests_BeansBuildSkipLinks extends HTML_Test_Case { * Test beans_build_skip_links() should not output sidebar skip links when the full-width layout ('c') is selected. */ public function test_should_not_output_sidebar_skip_links_when_layout_c_selected() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c'; + } + ); $this->assertEquals( beans_get_layout(), 'c' ); @@ -58,9 +61,12 @@ public function test_should_output_content_primary_sidebar_skip_links() { ->with( 'c_sp' ) ->andReturn( false ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp' ); @@ -90,9 +96,12 @@ public function test_should_output_content_secondary_sidebar_skip_links() { ->with( 'c_ss' ) ->andReturn( true ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_ss' ); @@ -123,9 +132,12 @@ public function test_should_output_content_both_sidebar_skip_links() { ->with( 'c_sp_ss' ) ->andReturn( true ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); @@ -156,9 +168,12 @@ public function test_should_output_content_only_primary_sidebar_skip_links_when_ ->with( 'c_sp_ss' ) ->andReturn( false ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); @@ -188,9 +203,12 @@ public function test_should_output_content_only_secondary_sidebar_skip_links_whe ->with( 'c_sp_ss' ) ->andReturn( true ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); @@ -224,9 +242,12 @@ public function test_should_output_primary_navigation_content_and_both_sidebar_s ->with( 'c_sp_ss' ) ->andReturn( true ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp_ss' ); diff --git a/tests/phpunit/integration/api/html/beansCloseMarkup.php b/tests/phpunit/integration/api/html/beansCloseMarkup.php index 60d5fcc3..4782ed6e 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkup.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkup.php @@ -37,9 +37,11 @@ public function test_should_fire_append_markup_hooks_and_include_content_in_retu Monkey\Functions\expect( '__beans_render_title_append_markup' ) ->once() ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); + ->andReturnUsing( + function() { + echo ''; + } + ); add_action( 'beans_archive_title_append_markup', '__beans_render_title_append_markup' ); // Run the tests. @@ -55,9 +57,11 @@ public function test_should_fire_after_markup_hooks_and_include_content_in_retur Monkey\Functions\expect( '__beans_render_title_after_markup' ) ->once() ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); + ->andReturnUsing( + function() { + echo ''; + } + ); add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); // Run the tests. @@ -82,12 +86,18 @@ public function test_should_return_closing_tag_when_callback_not_registered_to_e * to the "_append_markup" and "_after_markup" hooks. */ public function test_should_return_built_html_when_callback_registered_to_hooks() { - add_action( 'beans_archive_title_append_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_append_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_after_markup', + function() { + echo ''; + } + ); // Run the tests. $actual = beans_close_markup( 'beans_archive_title', 'h1' ); @@ -113,12 +123,18 @@ public function test_should_return_empty_string_when_empty_tag_and_callback_not_ * the tag is empty. */ public function test_should_return_hooked_callbacks_output_and_not_closing_tag_when_tag_is_empty() { - add_action( 'beans_archive_title_append_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_append_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_after_markup', + function() { + echo ''; + } + ); // Check with an empty string. $actual = beans_close_markup( 'beans_archive_title', '' ); @@ -144,9 +160,12 @@ public function test_should_escape_closing_tag() { $this->assertSame( $expected, beans_close_markup( 'beans_post_title', '' ) ); // Check when tag is filtered. - add_filter( 'beans_post_title_markup', function() { - return ''; - }); + add_filter( + 'beans_post_title_markup', + function() { + return ''; + } + ); $this->assertSame( $expected, beans_close_markup( 'beans_post_title', 'h1' ) ); } } diff --git a/tests/phpunit/integration/api/html/beansCloseMarkupE.php b/tests/phpunit/integration/api/html/beansCloseMarkupE.php index 4469ea90..07f1487a 100644 --- a/tests/phpunit/integration/api/html/beansCloseMarkupE.php +++ b/tests/phpunit/integration/api/html/beansCloseMarkupE.php @@ -51,12 +51,18 @@ public function test_should_echo_closing_tag_when_callback_not_registered_to_eit * to the "_append_markup" and "_after_markup" hooks. */ public function test_should_echo_built_html_when_append_or_after_hooks() { - add_action( 'beans_archive_title_append_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_after_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_append_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_after_markup', + function() { + echo ''; + } + ); ob_start(); beans_close_markup_e( 'beans_archive_title', 'h1' ); diff --git a/tests/phpunit/integration/api/html/beansModifyMarkup.php b/tests/phpunit/integration/api/html/beansModifyMarkup.php index 885e529d..2b8c2f49 100644 --- a/tests/phpunit/integration/api/html/beansModifyMarkup.php +++ b/tests/phpunit/integration/api/html/beansModifyMarkup.php @@ -36,10 +36,16 @@ public function test_should_return_anonymous_filter_instance() { public function test_should_register_callback_to_id_markup_filter() { $anonymous_filter = beans_modify_markup( 'beans_archive_title', 'h2' ); - $this->assertSame( 10, has_filter( 'beans_archive_title_markup', [ - $anonymous_filter, - 'callback', - ] ) ); + $this->assertSame( + 10, + has_filter( + 'beans_archive_title_markup', + [ + $anonymous_filter, + 'callback', + ] + ) + ); } /** @@ -52,12 +58,18 @@ public function test_should_modify_html_markup_tag() { EOB; // Let's test it out by running the markup for this ID. - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_before_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_prepend_markup', + function() { + echo ''; + } + ); // Check the opening markup. $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); @@ -75,13 +87,17 @@ public function test_should_modify_html_markup_self_closing_tag() { $expected = << EOB; - $actual = beans_selfclose_markup( 'beans_post_image_item', 'img', [ - 'width' => 800, - 'height' => 500, - 'src' => 'http://example.com/image.png', - 'alt' => 'Some image', - 'itemprop' => 'image', - ] ); + $actual = beans_selfclose_markup( + 'beans_post_image_item', + 'img', + [ + 'width' => 800, + 'height' => 500, + 'src' => 'http://example.com/image.png', + 'alt' => 'Some image', + 'itemprop' => 'image', + ] + ); $this->assertSame( $expected, $actual ); } } diff --git a/tests/phpunit/integration/api/html/beansOpenMarkup.php b/tests/phpunit/integration/api/html/beansOpenMarkup.php index 04600d3e..197d4b03 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkup.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkup.php @@ -37,9 +37,11 @@ public function test_should_fire_before_markup_hooks_and_include_content_in_retu Monkey\Functions\expect( '__beans_render_title_before_markup' ) ->once() ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); + ->andReturnUsing( + function() { + echo ''; + } + ); add_action( 'beans_archive_title_before_markup', '__beans_render_title_before_markup' ); // Run the tests. @@ -55,9 +57,11 @@ public function test_should_fire_prepend_markup_hooks_and_include_content_in_ret Monkey\Functions\expect( '__beans_render_title_prepend_markup' ) ->once() ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); + ->andReturnUsing( + function() { + echo ''; + } + ); add_action( 'beans_archive_title_prepend_markup', '__beans_render_title_prepend_markup' ); // Run the tests. @@ -74,9 +78,11 @@ public function test_should_fire_after_markup_hooks_when_selfclose_is_true() { Monkey\Functions\expect( '__beans_render_title_after_markup' ) ->once() ->with( '' ) - ->andReturnUsing( function() { - echo ''; - } ); + ->andReturnUsing( + function() { + echo ''; + } + ); add_action( 'beans_archive_title_after_markup', '__beans_render_title_after_markup' ); global $_beans_is_selfclose_markup; @@ -116,12 +122,18 @@ public function test_should_return_built_html_with_data_markup_id_when_in_dev_mo * Test beans_open_markup() should return the built HTML when before and prepend hooks are registered. */ public function test_should_return_built_html_when_before_or_prepend_hooks() { - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_before_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_prepend_markup', + function() { + echo ''; + } + ); // Run the tests. $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); @@ -178,12 +190,18 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup * the tag is empty. */ public function test_should_return_only_hooked_callbacks_output_and_no_html_element_when_tag_is_empty() { - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_before_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_prepend_markup', + function() { + echo ''; + } + ); // Check with an empty string. $actual = beans_open_markup( 'beans_archive_title', '', [ 'class' => 'uk-article-title' ] ); @@ -207,30 +225,48 @@ public function test_should_escape_built_html_tag() { <<script>alert("Should escape me.")</script> class="uk-article-title" itemprop="headline"> EOB; // Check when given as the tag. - $actual = beans_open_markup( 'beans_post_title', '', [ - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ] ); + $actual = beans_open_markup( + 'beans_post_title', + '', + [ + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ] + ); $this->assertSame( $expected, $actual ); // Check when tag is filtered. - add_filter( 'beans_post_title_markup', function() { - return ''; - } ); - $actual = beans_open_markup( 'beans_post_title', 'h1', [ - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ] ); + add_filter( + 'beans_post_title_markup', + function() { + return ''; + } + ); + $actual = beans_open_markup( + 'beans_post_title', + 'h1', + [ + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ] + ); $this->assertSame( $expected, $actual ); // Check the attributes too. $expected = << EOB; - $this->assertSame( $expected, beans_open_markup( 'beans_post_title_link', 'a', [ - 'href' => 'http://example.com/testing-ensure-safe?val=', - 'title' => 'Testing to ensure safe.', - 'rel' => 'bookmark', - ] ) ); + $this->assertSame( + $expected, + beans_open_markup( + 'beans_post_title_link', + 'a', + [ + 'href' => 'http://example.com/testing-ensure-safe?val=', + 'title' => 'Testing to ensure safe.', + 'rel' => 'bookmark', + ] + ) + ); } } diff --git a/tests/phpunit/integration/api/html/beansOpenMarkupE.php b/tests/phpunit/integration/api/html/beansOpenMarkupE.php index 11572b57..2d2de04f 100644 --- a/tests/phpunit/integration/api/html/beansOpenMarkupE.php +++ b/tests/phpunit/integration/api/html/beansOpenMarkupE.php @@ -62,12 +62,18 @@ public function test_should_echo_html_element_with_data_markup_id_when_in_dev_mo * the "_before_markup" and "_prepend_markup" hooks. */ public function test_should_echo_before_element_prepend_html_when_before_or_prepend_hooks() { - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_before_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_prepend_markup', + function() { + echo ''; + } + ); ob_start(); beans_open_markup_e( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); diff --git a/tests/phpunit/integration/api/html/beansOutputE.php b/tests/phpunit/integration/api/html/beansOutputE.php index 800832e4..94095838 100644 --- a/tests/phpunit/integration/api/html/beansOutputE.php +++ b/tests/phpunit/integration/api/html/beansOutputE.php @@ -91,9 +91,11 @@ public function test_should_pass_additional_arguments() { Monkey\Functions\expect( 'return_fired_output' ) ->twice() ->with( 'Beans rocks!', 47, 'Hello' ) - ->andReturnUsing( function( $output, $arg1, $arg2 ) { - return $arg2; - } ); + ->andReturnUsing( + function( $output, $arg1, $arg2 ) { + return $arg2; + } + ); // Check with HTML dev mode disabled. add_option( 'beans_dev_mode', 0 ); diff --git a/tests/phpunit/integration/api/html/beansRemoveMarkup.php b/tests/phpunit/integration/api/html/beansRemoveMarkup.php index 7605ea25..d16b54a8 100644 --- a/tests/phpunit/integration/api/html/beansRemoveMarkup.php +++ b/tests/phpunit/integration/api/html/beansRemoveMarkup.php @@ -36,10 +36,16 @@ public function test_should_return_anonymous_filter_instance() { public function test_should_register_callback_to_id_markup_filter() { $anonymous_filter = beans_remove_markup( 'beans_archive_title' ); - $this->assertSame( 10, has_filter( 'beans_archive_title_markup', [ - $anonymous_filter, - 'callback', - ] ) ); + $this->assertSame( + 10, + has_filter( + 'beans_archive_title_markup', + [ + $anonymous_filter, + 'callback', + ] + ) + ); } /** @@ -49,12 +55,18 @@ public function test_should_remove_only_element_when_remove_actions_is_false() { beans_remove_markup( 'beans_archive_title' ); // Let's test it out by running the markup for this ID. - add_action( 'beans_archive_title_before_markup', function() { - echo ''; - } ); - add_action( 'beans_archive_title_prepend_markup', function() { - echo ''; - } ); + add_action( + 'beans_archive_title_before_markup', + function() { + echo ''; + } + ); + add_action( + 'beans_archive_title_prepend_markup', + function() { + echo ''; + } + ); $actual = beans_open_markup( 'beans_archive_title', 'h1', [ 'class' => 'uk-article-title' ] ); $this->assertSame( '', $actual ); $this->assertSame( '', beans_close_markup( 'beans_archive_title', 'h1' ) ); diff --git a/tests/phpunit/integration/api/html/beansRemoveOutput.php b/tests/phpunit/integration/api/html/beansRemoveOutput.php index 50f45169..a15feb51 100644 --- a/tests/phpunit/integration/api/html/beansRemoveOutput.php +++ b/tests/phpunit/integration/api/html/beansRemoveOutput.php @@ -36,10 +36,16 @@ public function test_should_return_anonymous_filter_instance() { public function test_should_return_register_callback_to_id_output_filter() { $anonymous_filter = beans_remove_output( 'beans_post_meta_item_date' ); - $this->assertSame( 99999999, has_filter( 'beans_post_meta_item_date_output', [ - $anonymous_filter, - 'callback', - ] ) ); + $this->assertSame( + 99999999, + has_filter( + 'beans_post_meta_item_date_output', + [ + $anonymous_filter, + 'callback', + ] + ) + ); } /** diff --git a/tests/phpunit/integration/api/html/includes/class-html-test-case.php b/tests/phpunit/integration/api/html/includes/class-html-test-case.php index 78c0b88f..19236dbf 100644 --- a/tests/phpunit/integration/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/integration/api/html/includes/class-html-test-case.php @@ -46,9 +46,12 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; - static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { - return isset( $markup['attributes'] ); - } ); + static::$test_attributes = array_filter( + static::$test_markup, + function( $markup ) { + return isset( $markup['attributes'] ); + } + ); static::$test_attachments = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-attachment.php'; } diff --git a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php index f9495d3c..8e21fc00 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/createEditedImage.php @@ -62,7 +62,7 @@ public function test_should_edit_create_and_store_image() { $this->assertTrue( $created_edited_image->invoke( $editor ) ); $this->assertFileExists( $edited_image_src ); - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 800, $width ); $this->assertEquals( 420, $height ); } diff --git a/tests/phpunit/integration/api/image/beans-image-editor/run.php b/tests/phpunit/integration/api/image/beans-image-editor/run.php index 2848aa08..4baa91a8 100644 --- a/tests/phpunit/integration/api/image/beans-image-editor/run.php +++ b/tests/phpunit/integration/api/image/beans-image-editor/run.php @@ -62,7 +62,7 @@ public function test_should_edit_store_image_and_return_its_url() { $this->assertSame( beans_path_to_url( $edited_image_src ), $image_info ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 800, $width ); $this->assertEquals( 420, $height ); } @@ -128,7 +128,7 @@ public function test_should_edit_store_image_and_return_indexed_array() { $this->assertSame( [ beans_path_to_url( $edited_image_src ), 800, 420 ], $image_info ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 800, $width ); $this->assertEquals( 420, $height ); } @@ -197,7 +197,7 @@ public function test_should_edit_store_image_and_return_object() { $this->assertSame( 210, $image_info->height ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 400, $width ); $this->assertEquals( 210, $height ); } @@ -279,7 +279,7 @@ public function test_should_edit_store_image_and_return_associative_array() { ); // Check the edited image's dimensions. - list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $edited_image_src ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. $this->assertEquals( 600, $width ); $this->assertEquals( 315, $height ); } diff --git a/tests/phpunit/integration/api/image/beans-image-options/register.php b/tests/phpunit/integration/api/image/beans-image-options/register.php index 75c3637a..d88de1ee 100644 --- a/tests/phpunit/integration/api/image/beans-image-options/register.php +++ b/tests/phpunit/integration/api/image/beans-image-options/register.php @@ -62,10 +62,13 @@ public function test_should_register_options_with_column_context_when_other_meta // Check that the right fields did get registered. $registered_fields = beans_get_fields( 'option', 'images_options' ); $this->assertCount( 1, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - ], current( $registered_fields ) ); + $this->assertArraySubset( + [ + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + ], + current( $registered_fields ) + ); // Check that the metabox did get registered. global $wp_meta_boxes; @@ -88,10 +91,13 @@ public function test_should_register_options_with_normal_context_when_no_metabox // Check that the right fields did get registered. $registered_fields = beans_get_fields( 'option', 'images_options' ); $this->assertCount( 1, $registered_fields ); - $this->assertArraySubset( [ - 'id' => 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - ], current( $registered_fields ) ); + $this->assertArraySubset( + [ + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + ], + current( $registered_fields ) + ); // Check that the metabox did get registered. global $wp_meta_boxes; diff --git a/tests/phpunit/integration/api/image/includes/class-base-test-case.php b/tests/phpunit/integration/api/image/includes/class-base-test-case.php index f569686c..c6a303e4 100644 --- a/tests/phpunit/integration/api/image/includes/class-base-test-case.php +++ b/tests/phpunit/integration/api/image/includes/class-base-test-case.php @@ -43,13 +43,16 @@ public function setUp() { $this->set_up_virtual_filesystem(); // Set the Uploads directory to our virtual filesystem. - add_filter( 'upload_dir', function( array $uploads_dir ) { - $virtual_dir = vfsStream::url( 'uploads' ); - $uploads_dir['path'] = $virtual_dir . $uploads_dir['subdir']; - $uploads_dir['basedir'] = $virtual_dir; + add_filter( + 'upload_dir', + function( array $uploads_dir ) { + $virtual_dir = vfsStream::url( 'uploads' ); + $uploads_dir['path'] = $virtual_dir . $uploads_dir['subdir']; + $uploads_dir['basedir'] = $virtual_dir; - return $uploads_dir; - } ); + return $uploads_dir; + } + ); } /** diff --git a/tests/phpunit/integration/api/layout/beansGetLayout.php b/tests/phpunit/integration/api/layout/beansGetLayout.php index b2c2445b..122882ac 100644 --- a/tests/phpunit/integration/api/layout/beansGetLayout.php +++ b/tests/phpunit/integration/api/layout/beansGetLayout.php @@ -49,9 +49,11 @@ public function test_should_return_layout_for_singular() { */ public function test_should_return_layout_for_static_posts_page() { // Configure the Posts Page for our static page. - $posts_page_id = self::factory()->post->create( [ - 'post_type' => 'page', - ] ); + $posts_page_id = self::factory()->post->create( + [ + 'post_type' => 'page', + ] + ); update_option( 'show_on_front', 'page' ); update_option( 'page_for_posts', $posts_page_id ); @@ -148,10 +150,12 @@ public function test_should_return_layout_for_tag() { public function test_should_return_layout_for_custom_tax() { register_taxonomy( 'test_tax', 'post', [ 'public' => true ] ); $post_id = self::factory()->post->create(); - $term_id = self::factory()->term->create( [ - 'taxonomy' => 'test_tax', - 'slug' => 'custom-term', - ] ); + $term_id = self::factory()->term->create( + [ + 'taxonomy' => 'test_tax', + 'slug' => 'custom-term', + ] + ); wp_set_object_terms( $post_id, $term_id, 'test_tax' ); $meta_key = "beans_term_{$term_id}_beans_layout"; diff --git a/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php b/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php index c09b8180..7477298c 100644 --- a/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php +++ b/tests/phpunit/integration/api/layout/beansHasPrimarySidebar.php @@ -25,9 +25,12 @@ class Tests_BeansHasPrimarySidebar extends Test_Case { * Test beans_has_primary_sidebar() should return false when the layout is full-width. */ public function test_should_return_false_when_full_width_layout() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c'; + } + ); $this->assertEquals( beans_get_layout(), 'c' ); @@ -38,9 +41,12 @@ public function test_should_return_false_when_full_width_layout() { * Test beans_has_primary_sidebar() should return false when the layout is content-secondary sidebar. */ public function test_should_return_false_when_content_sidebar_secondary_layout() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_ss' ); @@ -53,9 +59,12 @@ public function test_should_return_false_when_content_sidebar_secondary_layout() public function test_should_return_false_when_content_primary_sidebar_layout_without_active_widget() { Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp' ); @@ -68,9 +77,12 @@ public function test_should_return_false_when_content_primary_sidebar_layout_wit public function test_should_return_true_when_content_primary_sidebar_layout_with_active_widget() { Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp' ); diff --git a/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php index 53573b55..3e147278 100644 --- a/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php +++ b/tests/phpunit/integration/api/layout/beansHasSecondarySidebar.php @@ -24,9 +24,12 @@ class Tests_BeansHasSecondarySidebar extends Test_Case { * Test beans_has_secondary_sidebar() should return false when the layout is full-width. */ public function test_should_return_false_when_full_width_layout() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c'; + } + ); $this->assertEquals( beans_get_layout(), 'c' ); @@ -37,9 +40,12 @@ public function test_should_return_false_when_full_width_layout() { * Test beans_has_secondary_sidebar() should return false when the layout is content-primary sidebar. */ public function test_should_return_false_when_content_primary_sidebar_layout() { - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_sp'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_sp'; + } + ); $this->assertEquals( beans_get_layout(), 'c_sp' ); @@ -52,9 +58,12 @@ public function test_should_return_false_when_content_primary_sidebar_layout() { public function test_should_return_false_when_content_secondary_sidebar_layout_without_active_widget() { Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( false ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_ss' ); @@ -67,9 +76,12 @@ public function test_should_return_false_when_content_secondary_sidebar_layout_w public function test_should_return_true_when_content_secondary_sidebar_layout_with_active_widget() { Monkey\Functions\when( 'beans_is_active_widget_area' )->justReturn( true ); - add_filter( 'beans_default_layout', function( $default_layout ) { - return 'c_ss'; - }); + add_filter( + 'beans_default_layout', + function( $default_layout ) { + return 'c_ss'; + } + ); $this->assertEquals( beans_get_layout(), 'c_ss' ); diff --git a/tests/phpunit/integration/api/options/beans-options/register.php b/tests/phpunit/integration/api/options/beans-options/register.php index c4750de1..01361b56 100644 --- a/tests/phpunit/integration/api/options/beans-options/register.php +++ b/tests/phpunit/integration/api/options/beans-options/register.php @@ -58,12 +58,15 @@ public function test_should_register_metabox_with_wp() { $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['themesphppagebeans_settings'] ); $this->assertArrayHasKey( 'default', $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ] ); $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'] ); - $this->assertSame( [ - 'id' => $option['section'], - 'title' => $option['args']['title'], - 'callback' => [ $instance, 'render_metabox' ], - 'args' => null, - ], $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); + $this->assertSame( + [ + 'id' => $option['section'], + 'title' => $option['args']['title'], + 'callback' => [ $instance, 'render_metabox' ], + 'args' => null, + ], + $wp_meta_boxes['themesphppagebeans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] + ); // Clean up. remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); diff --git a/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php b/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php index 162f1e4d..0eba52e5 100644 --- a/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php +++ b/tests/phpunit/integration/api/post-meta/beansRegisterPostMeta.php @@ -28,13 +28,19 @@ class Tests_BeansRegisterPostMeta extends Post_Meta_Test_Case { */ public function test_should_return_false_when_not_is_admin() { - $this->assertFalse( beans_register_post_meta( [ - [ - 'id' => 'field_id', - 'type' => 'radio', - 'label' => 'Field Label', - ], - ], true, 'tm-beans' ) ); + $this->assertFalse( + beans_register_post_meta( + [ + [ + 'id' => 'field_id', + 'type' => 'radio', + 'label' => 'Field Label', + ], + ], + true, + 'tm-beans' + ) + ); } /** @@ -43,13 +49,19 @@ public function test_should_return_false_when_not_is_admin() { public function test_should_return_false_when_conditions_are_false() { set_current_screen( 'edit' ); - $this->assertFalse( beans_register_post_meta( [ - [ - 'id' => 'field_id', - 'type' => 'radio', - 'label' => 'Field Label', - ], - ], false, 'tm-beans' ) ); + $this->assertFalse( + beans_register_post_meta( + [ + [ + 'id' => 'field_id', + 'type' => 'radio', + 'label' => 'Field Label', + ], + ], + false, + 'tm-beans' + ) + ); } /** @@ -67,12 +79,18 @@ public function test_should_return_false_when_fields_cannot_be_registered() { public function test_should_return_true_when_post_meta_is_registered() { set_current_screen( 'edit' ); - $this->assertTrue( beans_register_post_meta( [ - [ - 'id' => 'field_id', - 'type' => 'radio', - 'label' => 'Field Label', - ], - ], true, 'tm-beans' ) ); + $this->assertTrue( + beans_register_post_meta( + [ + [ + 'id' => 'field_id', + 'type' => 'radio', + 'label' => 'Field Label', + ], + ], + true, + 'tm-beans' + ) + ); } } diff --git a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php index 8abfaf7d..2f9cf185 100644 --- a/tests/phpunit/integration/api/uikit/beans-uikit/compile.php +++ b/tests/phpunit/integration/api/uikit/beans-uikit/compile.php @@ -74,23 +74,34 @@ public function test_should_not_compile_when_no_assets_to_compile() { * Test _Beans_Uikit::compile() should compile the styles. */ public function test_should_compile_styles() { - beans_uikit_enqueue_components( [ - 'alert', - 'button', - 'overlay', - ], 'core', false ); - - add_filter( 'beans_uikit_euqueued_styles', function( $styles ) { - $this->assertSame( [ - BEANS_API_PATH . 'uikit/src/less/core/variables.less', - BEANS_API_PATH . 'uikit/src/less/core/alert.less', - BEANS_API_PATH . 'uikit/src/less/core/button.less', - BEANS_API_PATH . 'uikit/src/less/core/overlay.less', - BEANS_API_PATH . 'uikit/src/fixes.less', - ], $styles ); - - return $styles; - }, 9999 ); + beans_uikit_enqueue_components( + [ + 'alert', + 'button', + 'overlay', + ], + 'core', + false + ); + + add_filter( + 'beans_uikit_euqueued_styles', + function( $styles ) { + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + BEANS_API_PATH . 'uikit/src/less/core/button.less', + BEANS_API_PATH . 'uikit/src/less/core/overlay.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + $styles + ); + + return $styles; + }, + 9999 + ); add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); @@ -145,17 +156,24 @@ public function test_should_compile_styles_with_default_theme() { beans_uikit_enqueue_theme( 'default', $theme_path ); beans_uikit_enqueue_components( 'alert', 'core', false ); - add_filter( 'beans_uikit_euqueued_styles', function( $styles ) use ( $theme_path ) { - $this->assertSame( [ - BEANS_API_PATH . 'uikit/src/less/core/variables.less', - $theme_path . 'variables.less', - BEANS_API_PATH . 'uikit/src/less/core/alert.less', - $theme_path . 'alert.less', - BEANS_API_PATH . 'uikit/src/fixes.less', - ], $styles ); - - return $styles; - }, 9999 ); + add_filter( + 'beans_uikit_euqueued_styles', + function( $styles ) use ( $theme_path ) { + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + $theme_path . 'variables.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + $theme_path . 'alert.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + $styles + ); + + return $styles; + }, + 9999 + ); add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); @@ -184,21 +202,28 @@ public function test_should_compile_styles_with_child_theme() { beans_uikit_enqueue_theme( 'beans-child', $theme_path ); beans_uikit_enqueue_components( [ 'alert', 'close', 'panel' ], 'core', false ); - add_filter( 'beans_uikit_euqueued_styles', function( $styles ) use ( $theme_path ) { - $this->assertSame( [ - BEANS_API_PATH . 'uikit/src/less/core/variables.less', - $theme_path . 'variables.less', - BEANS_API_PATH . 'uikit/src/less/core/alert.less', - $theme_path . 'alert.less', - BEANS_API_PATH . 'uikit/src/less/core/close.less', - $theme_path . 'close.less', - BEANS_API_PATH . 'uikit/src/less/core/panel.less', - $theme_path . 'panel.less', - BEANS_API_PATH . 'uikit/src/fixes.less', - ], $styles ); - - return $styles; - }, 9999 ); + add_filter( + 'beans_uikit_euqueued_styles', + function( $styles ) use ( $theme_path ) { + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/less/core/variables.less', + $theme_path . 'variables.less', + BEANS_API_PATH . 'uikit/src/less/core/alert.less', + $theme_path . 'alert.less', + BEANS_API_PATH . 'uikit/src/less/core/close.less', + $theme_path . 'close.less', + BEANS_API_PATH . 'uikit/src/less/core/panel.less', + $theme_path . 'panel.less', + BEANS_API_PATH . 'uikit/src/fixes.less', + ], + $styles + ); + + return $styles; + }, + 9999 + ); add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); Monkey\Functions\expect( 'beans_compile_js_fragments' )->never(); @@ -246,24 +271,35 @@ public function test_should_compile_styles_with_child_theme() { * Test _Beans_Uikit::compile() should compile the scripts. */ public function test_should_compile_scripts() { - beans_uikit_enqueue_components( [ - 'alert', - 'button', - ], 'core', false ); + beans_uikit_enqueue_components( + [ + 'alert', + 'button', + ], + 'core', + false + ); add_filter( 'beans_uikit_euqueued_styles', '__return_empty_array' ); Monkey\Functions\expect( 'beans_compile_less_fragments' )->never(); - add_filter( 'beans_uikit_euqueued_scripts', function( $scripts ) { - $this->assertSame( [ - BEANS_API_PATH . 'uikit/src/js/core/core.min.js', - BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', - BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', - BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', - BEANS_API_PATH . 'uikit/src/js/core/button.min.js', - ], $scripts ); - - return $scripts; - }, 9999 ); + add_filter( + 'beans_uikit_euqueued_scripts', + function( $scripts ) { + $this->assertSame( + [ + BEANS_API_PATH . 'uikit/src/js/core/core.min.js', + BEANS_API_PATH . 'uikit/src/js/core/utility.min.js', + BEANS_API_PATH . 'uikit/src/js/core/touch.min.js', + BEANS_API_PATH . 'uikit/src/js/core/alert.min.js', + BEANS_API_PATH . 'uikit/src/js/core/button.min.js', + ], + $scripts + ); + + return $scripts; + }, + 9999 + ); $this->assertEmpty( $this->get_compiled_filename( $this->compiled_uikit_path ) ); ( new _Beans_Uikit() )->compile(); diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php index f346a8ac..e1e51001 100644 --- a/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueAssets.php @@ -73,11 +73,15 @@ public function test_should_compile_styles() { add_action( 'beans_uikit_enqueue_scripts', '__return_false' ); // Register some components. - beans_uikit_enqueue_components( [ - 'alert', - 'button', - 'overlay', - ], 'core', false ); + beans_uikit_enqueue_components( + [ + 'alert', + 'button', + 'overlay', + ], + 'core', + false + ); // Disable the scripts from running. add_filter( 'beans_uikit_euqueued_scripts', '__return_empty_array' ); @@ -99,10 +103,14 @@ public function test_should_compile_scripts() { add_action( 'beans_uikit_enqueue_scripts', '__return_false' ); // Register some components. - beans_uikit_enqueue_components( [ - 'alert', - 'button', - ], 'core', false ); + beans_uikit_enqueue_components( + [ + 'alert', + 'button', + ], + 'core', + false + ); // Disable the styles from running. add_filter( 'beans_uikit_euqueued_styles', '__return_empty_array' ); diff --git a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php index 5dc36335..8e8e56d8 100644 --- a/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/integration/api/uikit/beansUikitEnqueueComponents.php @@ -81,12 +81,15 @@ public function test_should_add_given_addons_components_and_each_dependency_into $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); beans_uikit_enqueue_components( [ 'accordion', 'autocomplete', 'slideset' ], 'add-ons', true ); - $expected['add-ons'] = array_merge( $expected['add-ons'], [ - 'dotnav', - 'accordion', - 'autocomplete', - 'slideset', - ] ); + $expected['add-ons'] = array_merge( + $expected['add-ons'], + [ + 'dotnav', + 'accordion', + 'autocomplete', + 'slideset', + ] + ); $this->assertSame( $expected, $_beans_uikit_enqueued_items['components'] ); } diff --git a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php index 94bb4ea9..bcaf7e44 100644 --- a/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/integration/api/uikit/includes/class-uikit-test-case.php @@ -99,16 +99,19 @@ protected function set_up_mocks() { * Set up the Uploads directory to our virtual filesystem. */ protected function set_up_uploads_directory() { - add_filter( 'upload_dir', function( array $uploads_dir ) { - $compiled_dir = vfsStream::url( 'virtual-wp-content/uploads' ); - - $uploads_dir['path'] = $compiled_dir . $uploads_dir['subdir']; - $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); - $uploads_dir['basedir'] = $compiled_dir; - $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); - - return $uploads_dir; - } ); + add_filter( + 'upload_dir', + function( array $uploads_dir ) { + $compiled_dir = vfsStream::url( 'virtual-wp-content/uploads' ); + + $uploads_dir['path'] = $compiled_dir . $uploads_dir['subdir']; + $uploads_dir['url'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['url'] ); + $uploads_dir['basedir'] = $compiled_dir; + $uploads_dir['baseurl'] = str_replace( 'wp-content/uploads', 'compiled', $uploads_dir['baseurl'] ); + + return $uploads_dir; + } + ); } /** diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php index 751d6441..7b2adec0 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetArea.php @@ -26,10 +26,12 @@ class Tests_BeansGetWidgetArea extends Beans_Widget_Test_Case { * Test beans_get_widget_area() should return all widget area data when needle is not specified. */ public function test_should_return_all_data_when_needle_not_specified() { - register_sidebar( [ - 'id' => 'test_sidebar', - 'name' => 'Test Sidebar', - ] ); + register_sidebar( + [ + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ] + ); _beans_setup_widget_area( 'test_sidebar' ); $this->assertSame( $this->get_expected_sidebar_data(), beans_get_widget_area() ); @@ -39,10 +41,12 @@ public function test_should_return_all_data_when_needle_not_specified() { * Test beans_get_widget_area() should return specific widget data when a needle is specified. */ public function test_should_return_specific_widget_data_when_needle_specified() { - register_sidebar( [ - 'id' => 'test_sidebar', - 'name' => 'Test Sidebar', - ] ); + register_sidebar( + [ + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ] + ); _beans_setup_widget_area( 'test_sidebar' ); $this->assertEquals( 'test_sidebar', beans_get_widget_area( 'id' ) ); diff --git a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php index eb75e889..55514eb0 100644 --- a/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php +++ b/tests/phpunit/integration/api/widget/beansGetWidgetAreaOutput.php @@ -35,10 +35,12 @@ public function test_should_return_false_when_widget_area_not_registered() { public function test_should_return_widget_output_when_widget_area_is_registered() { global $wp_registered_sidebars; - beans_register_widget_area( [ - 'id' => 'test_sidebar', - 'name' => 'Test Sidebar', - ] ); + beans_register_widget_area( + [ + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ] + ); $this->add_test_widget_to_test_sidebar(); $this->assertSame( $this->format_the_html( $this->get_expected_output() ), diff --git a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php index 4ac75b41..39219db3 100644 --- a/tests/phpunit/integration/api/widget/beansHasWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansHasWidgetArea.php @@ -35,10 +35,12 @@ public function test_should_return_false_when_widget_area_not_registered() { public function test_should_return_true_when_widget_area_registered() { global $wp_registered_sidebars; - register_sidebar( [ - 'id' => 'test_sidebar', - 'name' => 'Test Sidebar', - ] ); + register_sidebar( + [ + 'id' => 'test_sidebar', + 'name' => 'Test Sidebar', + ] + ); // Confirm we have a test sidebar registered. $this->assertTrue( isset( $wp_registered_sidebars['test_sidebar'] ) ); diff --git a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php index 3eb67a9e..f804cb89 100644 --- a/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/integration/api/widget/beansRegisterWidgetArea.php @@ -40,10 +40,12 @@ public function test_should_register_sidebar_and_return_widget_area_ID_when_widg $this->assertEquals( 'new-widget-area', - beans_register_widget_area( [ - 'id' => 'new-widget-area', - 'beans_type' => 'grid', - ] ) + beans_register_widget_area( + [ + 'id' => 'new-widget-area', + 'beans_type' => 'grid', + ] + ) ); // Confirm that the sidebar is now in the WP global sidebar array. diff --git a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php index 010e81a9..47e4316a 100644 --- a/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/integration/api/wp-customize/includes/class-wp-customize-test-case.php @@ -78,16 +78,19 @@ public function tearDown() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $field = array_merge( [ - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => 'wp_customize', - 'attributes' => [ - 'data-customize-setting-link' => $field['id'], + $field = array_merge( + [ + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'wp_customize', + 'attributes' => [ + 'data-customize-setting-link' => $field['id'], + ], + 'db_group' => false, ], - 'db_group' => false, - ], $field ); + $field + ); $field['name'] = $field['id']; if ( 'group' === $field['type'] ) { diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php index ca50847c..80872434 100644 --- a/tests/phpunit/integration/bootstrap.php +++ b/tests/phpunit/integration/bootstrap.php @@ -64,10 +64,13 @@ function beans_get_wp_tests_dir() { * Register with "setup_theme" in the WP tests suite to set the themes directory * and load the Beans framework. */ -tests_add_filter( 'setup_theme', function() { - register_theme_directory( WP_CONTENT_DIR . 'themes' ); - switch_theme( basename( BEANS_THEME_DIR ) ); -} ); +tests_add_filter( + 'setup_theme', + function() { + register_theme_directory( WP_CONTENT_DIR . 'themes' ); + switch_theme( basename( BEANS_THEME_DIR ) ); + } +); // Start up the WP testing environment. require_once $beans_tests_dir . '/includes/bootstrap.php'; diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php index bc12e9cc..13bf2dc1 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/__construct.php @@ -36,10 +36,13 @@ protected function setUp() { * Test __construct() should set the callback and arguments. */ public function test_should_set_callback_and_arguments() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ - 'foo_test_callback', - [ 'foo', 'bar', 'baz' ], - ] ); + $anonymous_action = new _Beans_Anonymous_Action( + 'beans_test_do_foo', + [ + 'foo_test_callback', + [ 'foo', 'bar', 'baz' ], + ] + ); $this->assertSame( 'foo_test_callback', $anonymous_action->callback[0] ); $this->assertSame( [ 'foo', 'bar', 'baz' ], $anonymous_action->callback[1] ); @@ -49,10 +52,15 @@ public function test_should_set_callback_and_arguments() { * Test __construct() should add the action's hook. */ public function test_should_add_action_hook() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ - 'foo_test_callback', - [ 'foo' ], - ], 50, 3 ); + $anonymous_action = new _Beans_Anonymous_Action( + 'beans_test_do_foo', + [ + 'foo_test_callback', + [ 'foo' ], + ], + 50, + 3 + ); $this->assertTrue( has_action( 'beans_test_do_foo', [ $anonymous_action, 'callback' ] ) ); } diff --git a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php index 18bb601f..658811cd 100644 --- a/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php +++ b/tests/phpunit/unit/api/actions/beans-anonymous-action/callback.php @@ -37,10 +37,15 @@ protected function setUp() { * Test _Beans_Anonymous_Action::callback() should invoke the given callback, passing the arguments to it. */ public function test_should_invoke_callback() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ - 'foo_test_callback', - [ 'foo', 'bar' ], - ], 20, 2 ); + $anonymous_action = new _Beans_Anonymous_Action( + 'beans_test_do_foo', + [ + 'foo_test_callback', + [ 'foo', 'bar' ], + ], + 20, + 2 + ); // Check that the callback is invoked with each of its parameters. Monkey\Functions\expect( 'foo_test_callback' ) @@ -60,14 +65,19 @@ public function test_should_invoke_callback() { * Test _Beans_Anonymous_Action::callback() should echo the returned content. */ public function test_should_echo_returned_content() { - $anonymous_action = new _Beans_Anonymous_Action( 'beans_test_do_foo', [ - 'foo_test_callback', - [ 'Cool Beans!', 'It worked!' ], - ] ); + $anonymous_action = new _Beans_Anonymous_Action( + 'beans_test_do_foo', + [ + 'foo_test_callback', + [ 'Cool Beans!', 'It worked!' ], + ] + ); - Monkey\Functions\when( 'foo_test_callback' )->alias( function( $arg1, $arg2 ) { - return "{$arg1} {$arg2}"; - } ); + Monkey\Functions\when( 'foo_test_callback' )->alias( + function( $arg1, $arg2 ) { + return "{$arg1} {$arg2}"; + } + ); ob_start(); $anonymous_action->callback(); diff --git a/tests/phpunit/unit/api/actions/beansAddAction.php b/tests/phpunit/unit/api/actions/beansAddAction.php index 95de13bc..80335fb1 100644 --- a/tests/phpunit/unit/api/actions/beansAddAction.php +++ b/tests/phpunit/unit/api/actions/beansAddAction.php @@ -53,12 +53,14 @@ public function test_should_add_action_in_beans_and_wordpress() { Monkey\Functions\expect( '_beans_set_action' ) ->once() ->with( $beans_id, $action, 'added', true ) - ->andReturnUsing( function( $id, $action ) { - global $_beans_registered_actions; - $_beans_registered_actions['added'][ $id ] = $action; - - return $action; - } ); + ->andReturnUsing( + function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; + } + ); Monkey\Actions\expectAdded( $action['hook'] ) ->once() ->with( $action['callback'], $action['priority'], $action['args'] ); @@ -83,12 +85,14 @@ public function test_should_overwrite_add_action_in_beans_and_wordpress() { global $_beans_registered_actions; Monkey\Functions\when( '_beans_get_action' )->justReturn( false ); - Monkey\Functions\when( '_beans_set_action' )->alias( function( $id, $action ) { - global $_beans_registered_actions; - $_beans_registered_actions['added'][ $id ] = $action; + Monkey\Functions\when( '_beans_set_action' )->alias( + function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; - return $action; - } ); + return $action; + } + ); foreach ( static::$test_actions as $beans_id => $action ) { // Let's add it the first time. @@ -134,12 +138,14 @@ public function test_should_use_replaced_action_when_available() { Monkey\Functions\expect( '_beans_set_action' ) ->once() ->with( $beans_id, array_merge( $original_action, $replaced_action ), 'added', true ) - ->andReturnUsing( function( $id, $action ) { - global $_beans_registered_actions; - $_beans_registered_actions['added'][ $id ] = $action; - - return $action; - } ); + ->andReturnUsing( + function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; + } + ); Monkey\Actions\expectAdded( $original_action['hook'] ) ->once() ->with( $replaced_action['callback'], $replaced_action['priority'], $original_action['args'] ); @@ -189,12 +195,14 @@ public function test_should_return_false_when_removed() { Monkey\Functions\expect( '_beans_set_action' ) ->once() ->with( $beans_id, $action, 'added', true ) - ->andReturnUsing( function( $id, $action ) { - global $_beans_registered_actions; - $_beans_registered_actions['added'][ $id ] = $action; - - return $action; - } ); + ->andReturnUsing( + function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; + } + ); Monkey\Actions\expectAdded( $action['hook'] )->never(); // Next, add the action. @@ -239,12 +247,14 @@ public function test_should_merge_modified_action_parameters() { Monkey\Functions\expect( '_beans_set_action' ) ->once() ->with( $beans_id, $original_action, 'added', true ) - ->andReturnUsing( function( $id, $action ) { - global $_beans_registered_actions; - $_beans_registered_actions['added'][ $id ] = $action; - - return $action; - } ); + ->andReturnUsing( + function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['added'][ $id ] = $action; + + return $action; + } + ); Monkey\Actions\expectAdded( $original_action['hook'] ) ->once() ->with( $modified_action['callback'], $modified_action['priority'], $original_action['args'] ); diff --git a/tests/phpunit/unit/api/actions/beansModifyAction.php b/tests/phpunit/unit/api/actions/beansModifyAction.php index e05943a3..b4565479 100644 --- a/tests/phpunit/unit/api/actions/beansModifyAction.php +++ b/tests/phpunit/unit/api/actions/beansModifyAction.php @@ -57,12 +57,14 @@ public function test_should_register_as_modified_but_not_add_action() { Monkey\Functions\expect( '_beans_merge_action' ) ->once() ->with( $beans_id, $action, 'modified' ) - ->andReturnUsing( function( $id, $action ) { - global $_beans_registered_actions; - $_beans_registered_actions['modified'][ $id ] = $action; - - return $action; - } ); + ->andReturnUsing( + function( $id, $action ) { + global $_beans_registered_actions; + $_beans_registered_actions['modified'][ $id ] = $action; + + return $action; + } + ); Monkey\Actions\expectAdded( $action['hook'] )->never(); // Check that it returns false. diff --git a/tests/phpunit/unit/api/actions/beansResetAction.php b/tests/phpunit/unit/api/actions/beansResetAction.php index 0f4bf783..9b905c1d 100644 --- a/tests/phpunit/unit/api/actions/beansResetAction.php +++ b/tests/phpunit/unit/api/actions/beansResetAction.php @@ -98,9 +98,11 @@ public function test_should_reset_after_modifying_the_action() { Monkey\Functions\expect( '_beans_get_current_action' ) ->once() ->with( $beans_id ) - ->andReturnUsing( function() use ( $action, $modified_action ) { - return array_merge( $action, $modified_action ); - } ); + ->andReturnUsing( + function() use ( $action, $modified_action ) { + return array_merge( $action, $modified_action ); + } + ); // Expect the add_action. Monkey\Actions\expectAdded( $action['hook'] ) diff --git a/tests/phpunit/unit/api/actions/beansUniqueActionId.php b/tests/phpunit/unit/api/actions/beansUniqueActionId.php index e6c1c5dc..f3e29cae 100644 --- a/tests/phpunit/unit/api/actions/beansUniqueActionId.php +++ b/tests/phpunit/unit/api/actions/beansUniqueActionId.php @@ -109,8 +109,13 @@ public function test_should_convert_closure() { }; $this->assertEquals( spl_object_hash( $closure ), _beans_unique_action_id( $closure ) ); - $this->assertNotEquals( spl_object_hash( function() { - // Nothing here. - } ), _beans_unique_action_id( $closure ) ); + $this->assertNotEquals( + spl_object_hash( + function() { + // Nothing here. + } + ), + _beans_unique_action_id( $closure ) + ); } } diff --git a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php index 223d4d49..440816dd 100644 --- a/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php +++ b/tests/phpunit/unit/api/actions/includes/class-actions-test-case.php @@ -72,17 +72,21 @@ public static function tearDownAfterClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/actions/functions.php', - 'api/utilities/functions.php', - ] ); - - Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack ) { - - if ( isset( $haystack[ $needle ] ) ) { - return $haystack[ $needle ]; + $this->load_original_functions( + [ + 'api/actions/functions.php', + 'api/utilities/functions.php', + ] + ); + + Monkey\Functions\when( 'beans_get' )->alias( + function ( $needle, $haystack ) { + + if ( isset( $haystack[ $needle ] ) ) { + return $haystack[ $needle ]; + } } - } ); + ); } /** @@ -102,11 +106,13 @@ protected function go_to_post( $expect_added = false ) { if ( $expect_added ) { Monkey\Actions\expectAdded( $action['hook'] ) ->once() - ->whenHappen( function ( $callback, $priority, $args ) use ( $action ) { - $this->assertSame( $action['callback'], $callback ); - $this->assertSame( $action['priority'], $priority ); - $this->assertSame( $action['args'], $args ); - } ); + ->whenHappen( + function ( $callback, $priority, $args ) use ( $action ) { + $this->assertSame( $action['callback'], $callback ); + $this->assertSame( $action['priority'], $priority ); + $this->assertSame( $action['args'], $args ); + } + ); } beans_add_action( $beans_id, $action['hook'], $action['callback'], $action['priority'], $action['args'] ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php b/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php index 45de82de..81b3b683 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler-options/flush.php @@ -63,10 +63,12 @@ public function test_should_remove_cached_dir() { Monkey\Functions\expect( 'beans_remove_dir' ) ->once() ->with( vfsStream::url( 'compiled/beans/compiler/' ) ) - ->andReturnUsing( function() { - // Keep it simple. Remove by redefining. - vfsStream::setup( 'compiled', 0755, [ 'beans' => [] ] ); - } ); + ->andReturnUsing( + function() { + // Keep it simple. Remove by redefining. + vfsStream::setup( 'compiled', 0755, [ 'beans' => [] ] ); + } + ); $this->assertNull( ( new _Beans_Compiler_Options() )->flush() ); $this->assertDirectoryNotExists( vfsStream::url( 'compiled/beans/compiler/' ) ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php index a5b8841b..d62979d6 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/addContentMediaQuery.php @@ -112,11 +112,13 @@ public function test_should_wrap_content_in_media_query() { Monkey\Functions\expect( 'wp_parse_args' ) ->once() ->with( 'beans_compiler_media_query=' . $media_query ) - ->andReturnUsing( function( $query_args ) { - parse_str( $query_args, $args ); + ->andReturnUsing( + function( $query_args ) { + parse_str( $query_args, $args ); - return $args; - } ); + return $args; + } + ); Monkey\Functions\expect( 'beans_get' ) ->once() ->with( 'beans_compiler_media_query', [ 'beans_compiler_media_query' => $media_query ] ) diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php index 7e0bbb25..d8301e0f 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFile.php @@ -28,14 +28,16 @@ class Tests_BeansCompiler_CacheFile extends Compiler_Test_Case { * Test _Beans_Compiler::cache_file() should not create the file when the filename is empty. */ public function test_should_not_create_the_file_when_filename_empty() { - $compiler = $this->create_compiler( [ - 'id' => 'test-script', - 'type' => 'script', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ] + ); // Run the tests. $this->assertFalse( $compiler->cache_file() ); @@ -48,14 +50,16 @@ public function test_should_not_create_the_file_when_filename_empty() { * Test _Beans_Compiler::cache_file() should create the compiled jQuery file. */ public function test_should_create_compiled_jquery_file() { - $compiler = $this->create_compiler( [ - 'id' => 'test-jquery', - 'type' => 'script', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-jquery', + 'type' => 'script', + 'fragments' => [ vfsStream::url( 'compiled/fixtures/jquery.test.js' ) ], + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'minify_js' => true, + ] + ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_jquery(); @@ -77,13 +81,15 @@ public function test_should_create_compiled_jquery_file() { * Test _Beans_Compiler::cache_file() should create the compiled JavaScript file. */ public function test_should_create_compiled_javascript_file() { - $compiler = $this->create_compiler( [ - 'id' => 'test-js', - 'type' => 'script', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ], - 'in_footer' => true, - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-js', + 'type' => 'script', + 'fragments' => [ vfsStream::url( 'compiled/fixtures/my-game-clock.js' ) ], + 'in_footer' => true, + 'minify_js' => true, + ] + ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_jquery(); @@ -105,12 +111,14 @@ public function test_should_create_compiled_javascript_file() { * Test _Beans_Compiler::cache_file() should create the compiled CSS file. */ public function test_should_create_compiled_css_file() { - $compiler = $this->create_compiler( [ - 'id' => 'test-css', - 'type' => 'style', - 'format' => 'css', - 'fragments' => [ vfsStream::url( 'compiled/fixtures/style.css' ) ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-css', + 'type' => 'style', + 'format' => 'css', + 'fragments' => [ vfsStream::url( 'compiled/fixtures/style.css' ) ], + ] + ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_css(); @@ -132,15 +140,17 @@ public function test_should_create_compiled_css_file() { * Test _Beans_Compiler::cache_file() should create the compiled LESS file. */ public function test_should_create_compiled_less_file() { - $compiler = $this->create_compiler( [ - 'id' => 'test-less', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-less', + 'type' => 'style', + 'format' => 'less', + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ], + ] + ); // Mock the compiler's properties. $compiled_content = $this->get_compiled_less(); @@ -178,11 +188,13 @@ private function mock_creating_file( $folder_name, $filename, $cached_file, $com $mock->shouldReceive( 'put_contents' ) ->once() ->with( $cached_file, $compiled_content, FS_CHMOD_FILE ) - ->andReturnUsing( function( $cached_filename, $content ) use ( $folder_name, $filename ) { - $this->create_virtual_file( $folder_name, $filename, $content ); + ->andReturnUsing( + function( $cached_filename, $content ) use ( $folder_name, $filename ) { + $this->create_virtual_file( $folder_name, $filename, $content ); - return true; - } ); + return true; + } + ); $GLOBALS['wp_filesystem'] = $mock; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited -- Valid use case as we are mocking the filesystem. } } diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php index 94e80a35..49499e93 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/cacheFileExist.php @@ -28,11 +28,13 @@ class Tests_BeansCompiler_CacheFileExist extends Compiler_Test_Case { */ public function test_should_return_false_when_filename_not_generated() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'fragments' => [ $fragment ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'fragments' => [ $fragment ], + ] + ); // Run cache_file_exist(). $this->assertFalse( $compiler->cache_file_exist() ); @@ -43,11 +45,13 @@ public function test_should_return_false_when_filename_not_generated() { */ public function test_should_return_false_when_file_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = $this->create_compiler( [ - 'id' => 'test-script', - 'type' => 'script', - 'fragments' => [ $fragment ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => [ $fragment ], + ] + ); // Mock the compiler's property. $filename = '9a71ddb-b8d5d01.js'; @@ -63,11 +67,13 @@ public function test_should_return_false_when_file_does_not_exist() { */ public function test_should_return_true_when_file_exists() { $fragment = vfsStream::url( 'compiled/fixtures/my-game-clock.js' ); - $compiler = $this->create_compiler( [ - 'id' => 'test-script', - 'type' => 'script', - 'fragments' => [ $fragment ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => [ $fragment ], + ] + ); // Mock the compiler's property. $filename = '9a71ddb-b8d5d01.js'; diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php index edf2fde1..8164f734 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/combineFragments.php @@ -81,14 +81,16 @@ public function test_should_return_empty_string_when_no_fragments() { */ public function test_should_return_empty_string_when_fragment_does_not_exist() { $fragment = vfsStream::url( 'compiled/fixtures/' ) . 'invalid-file.js'; - $compiler = $this->create_compiler( [ - 'id' => 'test-script', - 'type' => 'script', - 'fragments' => [ $fragment ], - 'dependencies' => [ 'javascript' ], - 'in_footer' => true, - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test-script', + 'type' => 'script', + 'fragments' => [ $fragment ], + 'dependencies' => [ 'javascript' ], + 'in_footer' => true, + 'minify_js' => true, + ] + ); // Set up the mocks. Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); @@ -104,15 +106,17 @@ public function test_should_return_empty_string_when_fragment_does_not_exist() { * Test _Beans_Compiler::combine_fragments() should compile the LESS fragments and return the compiled CSS. */ public function test_should_compile_less_and_return_css() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -137,15 +141,17 @@ public function test_should_compile_less_and_return_css() { * Test _Beans_Compiler::combine_fragments() should return minified, compiled CSS from the Less combined fragments. */ public function test_should_return_minified_compiled_css() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/variables.less' ), - vfsStream::url( 'compiled/fixtures/test.less' ), - ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/variables.less' ), + vfsStream::url( 'compiled/fixtures/test.less' ), + ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -167,15 +173,17 @@ public function test_should_return_minified_compiled_css() { * but "minify_js" is disabled. */ public function test_should_return_original_jquery_when_minify_js_disabled() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ], + 'dependencies' => [ 'jquery' ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -193,15 +201,17 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ], + 'dependencies' => [ 'jquery' ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -218,15 +228,17 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified jQuery. */ public function test_should_return_minified_jquery() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/jquery.test.js' ), - ], - 'dependencies' => [ 'jquery' ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/jquery.test.js' ), + ], + 'dependencies' => [ 'jquery' ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -244,14 +256,16 @@ public function test_should_return_minified_jquery() { * mode, but "minify_js" is disabled. */ public function test_should_return_original_js_when_minify_js_disabled() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -269,14 +283,16 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); @@ -293,14 +309,16 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * Test _Beans_Compiler::combine_fragments() should return minified JavaScript. */ public function test_should_return_minified_javascript() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - 'fragments' => [ - vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), - ], - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + 'fragments' => [ + vfsStream::url( 'compiled/fixtures/my-game-clock.js' ), + ], + ] + ); // Set up the mocks. Monkey\Functions\expect( 'beans_url_to_path' )->never(); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php index df104f84..1fd805e0 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/formatContent.php @@ -61,9 +61,11 @@ protected function setUp() { * a style or script (per the configuration). */ public function test_should_return_original_content_when_type_not_style_or_script() { - $compiler = $this->create_compiler( [ - 'type' => 'foo', - ] ); + $compiler = $this->create_compiler( + [ + 'type' => 'foo', + ] + ); Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->never(); @@ -78,11 +80,13 @@ public function test_should_return_original_content_when_type_not_style_or_scrip * fragments. */ public function test_should_return_compiled_css() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ] + ); $compiled_css = <<create_compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ] + ); $compiled_css = <<create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ] + ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); @@ -155,11 +163,13 @@ public function test_should_return_original_jquery_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_jquery_when_in_dev_mode() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); @@ -174,11 +184,13 @@ public function test_should_always_return_original_jquery_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_jquery_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); $compiled_jquery = <<create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => false, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => false, + ] + ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( false ); @@ -220,11 +234,13 @@ public function test_should_return_original_js_when_minify_js_disabled() { * but the site is in development mode. */ public function test_should_always_return_original_js_when_in_dev_mode() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); // Set up the mocks. Monkey\Functions\expect( '_beans_is_compiler_dev_mode' )->once()->andReturn( true ); @@ -239,11 +255,13 @@ public function test_should_always_return_original_js_when_in_dev_mode() { * and the site is not in development mode. */ public function test_should_return_minified_js_when_not_in_dev_mode_and_minify_js_enabled() { - $compiler = $this->create_compiler( [ - 'id' => 'test', - 'type' => 'script', - 'minify_js' => true, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'script', + 'minify_js' => true, + ] + ); $compiled_js = <<create_compiler( [ - 'id' => 'test', - 'type' => 'style', - 'format' => 'less', - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test', + 'type' => 'style', + 'format' => 'less', + ] + ); $this->assertSame( [ 'id' => 'test', @@ -64,13 +66,15 @@ public function test_should_return_configuration() { $compiler->config ); - $compiler = $this->create_compiler( [ - 'id' => 'test_scripts', - 'type' => 'script', - 'dependencies' => [ 'jquery' ], - 'in_footer' => true, - 'version' => null, - ] ); + $compiler = $this->create_compiler( + [ + 'id' => 'test_scripts', + 'type' => 'script', + 'dependencies' => [ 'jquery' ], + 'in_footer' => true, + 'version' => null, + ] + ); $this->assertSame( [ 'id' => 'test_scripts', diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php index cde7b5c7..45c2b7cb 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getInternalContent.php @@ -59,9 +59,11 @@ public function test_should_return_false_when_file_does_not_exist() { */ public function test_should_return_fragment_contents() { $fragment = vfsStream::url( 'compiled/fixtures/test.less' ); - $compiler = $this->create_compiler( [ - 'fragments' => [ $fragment ], - ] ); + $compiler = $this->create_compiler( + [ + 'fragments' => [ $fragment ], + ] + ); // Set up the mocks. $this->set_reflective_property( $fragment, 'current_fragment', $compiler ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php index ed3ce5d1..ea596d21 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/getRemoteContent.php @@ -98,12 +98,14 @@ public function test_should_retry_and_return_false_when_remote_file_does_not_exi ->with( 'https://beans.local/invalid-file.js' ) ->once() ->ordered() - ->andReturn( [ - 'body' => '', - 'response' => [ - 'code' => 404, // HTTP code is 404 and not 200. - ], - ] ); + ->andReturn( + [ + 'body' => '', + 'response' => [ + 'code' => 404, // HTTP code is 404 and not 200. + ], + ] + ); // Run the test. $this->assertFalse( $compiler->get_remote_content() ); diff --git a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php index 2b48ed1d..40be2eaa 100644 --- a/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php +++ b/tests/phpunit/unit/api/compiler/beans-compiler/runCompiler.php @@ -333,7 +333,8 @@ protected function get_cache_filename( \_Beans_Compiler $compiler, array $config $this->add_virtual_directory( $config['id'] ); return vfsStream::url( - sprintf( 'compiled/beans/compiler/%s/%s', + sprintf( + 'compiled/beans/compiler/%s/%s', $config['id'], $this->get_filename( $compiler, $config, $fragment ? filemtime( $fragment ) : null ) ) @@ -398,16 +399,18 @@ private function prepare_mocks( $compiler, $config, $file, $content = '', $in_de $GLOBALS['wp_filesystem']->shouldReceive( 'put_contents' ) ->once() ->with( $file, $content, FS_CHMOD_FILE ) - ->andReturnUsing( function( $file, $content ) use ( $compiler, $config ) { - $pathinfo = pathinfo( $file ); + ->andReturnUsing( + function( $file, $content ) use ( $compiler, $config ) { + $pathinfo = pathinfo( $file ); - // Add the new file into the virtual filesystem. - vfsStream::newFile( $pathinfo['basename'] ) + // Add the new file into the virtual filesystem. + vfsStream::newFile( $pathinfo['basename'] ) ->at( $this->mock_filesystem->getChild( 'compiled/beans/compiler/' . $config['id'] ) ) ->setContent( $content ); - return true; - } ); + return true; + } + ); } /** diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php index 3d7176f0..4ba2fbe3 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageScripts.php @@ -344,40 +344,50 @@ protected function get_mock_assets( array $queue ) { $wp_scripts_mock = Mockery::mock( 'WP_Scripts' ); $wp_scripts_mock->queue = $queue; $registered = [ - 'jquery' => $this->get_deps_mock( [ - 'handle' => 'jquery', - 'src' => false, - 'deps' => [ 'jquery-core', 'jquery-migrate' ], - 'ver' => '1.12.4', - ] ), - 'jquery-core' => $this->get_deps_mock( [ - 'handle' => 'jquery-core', - 'src' => '/wp-includes/js/jquery/jquery.js', - 'ver' => '1.12.4', - ] ), - 'jquery-migrate' => $this->get_deps_mock( [ - 'handle' => 'jquery-migrate', - 'src' => '/wp-includes/js/jquery/jquery-migrate.js', - 'ver' => '1.4.1', - ] ), + 'jquery' => $this->get_deps_mock( + [ + 'handle' => 'jquery', + 'src' => false, + 'deps' => [ 'jquery-core', 'jquery-migrate' ], + 'ver' => '1.12.4', + ] + ), + 'jquery-core' => $this->get_deps_mock( + [ + 'handle' => 'jquery-core', + 'src' => '/wp-includes/js/jquery/jquery.js', + 'ver' => '1.12.4', + ] + ), + 'jquery-migrate' => $this->get_deps_mock( + [ + 'handle' => 'jquery-migrate', + 'src' => '/wp-includes/js/jquery/jquery-migrate.js', + 'ver' => '1.4.1', + ] + ), ]; if ( in_array( 'debug-bar', $queue, true ) ) { - $registered['debug-bar'] = $this->get_deps_mock( [ - 'handle' => 'debug-bar', - 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', - 'deps' => [ 'jquery' ], - 'ver' => '20170515', - 'extra' => [ 'group' => 1 ], - ] ); + $registered['debug-bar'] = $this->get_deps_mock( + [ + 'handle' => 'debug-bar', + 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', + 'deps' => [ 'jquery' ], + 'ver' => '20170515', + 'extra' => [ 'group' => 1 ], + ] + ); } if ( in_array( 'uikit', $queue, true ) ) { - $registered['uikit'] = $this->get_deps_mock( [ - 'handle' => 'uikit', - 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', - 'deps' => [ 'jquery' ], - ] ); + $registered['uikit'] = $this->get_deps_mock( + [ + 'handle' => 'uikit', + 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', + 'deps' => [ 'jquery' ], + ] + ); } $wp_scripts_mock->registered = $registered; diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php index 0469195e..ac6971c3 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/compilePageStyles.php @@ -296,13 +296,15 @@ public function test_should_compile_style_and_deps() { Monkey\Functions\expect( 'add_query_arg' )->never(); // Initialize the mocked assets. - $assets = $this->get_mock_assets( [ - 'admin-bar', - 'debug-bar', - 'uikit', - 'child-style', - 'debug-bar-actions-filters', - ] ); + $assets = $this->get_mock_assets( + [ + 'admin-bar', + 'debug-bar', + 'uikit', + 'child-style', + 'debug-bar-actions-filters', + ] + ); // Check the order of how beans_get() will be called. Monkey\Functions\expect( 'beans_get' ) @@ -369,34 +371,42 @@ protected function get_mock_assets( array $queue ) { $registered = []; if ( in_array( 'debug-bar', $queue, true ) ) { - $registered['debug-bar'] = $this->get_deps_mock( [ - 'handle' => 'debug-bar', - 'src' => 'http://beansdev.test/wp-content/plugins/debug-bar/css/debug-bar.dev.css', - 'ver' => '20170515', - ] ); + $registered['debug-bar'] = $this->get_deps_mock( + [ + 'handle' => 'debug-bar', + 'src' => 'http://beansdev.test/wp-content/plugins/debug-bar/css/debug-bar.dev.css', + 'ver' => '20170515', + ] + ); } if ( in_array( 'uikit', $queue, true ) ) { - $registered['uikit'] = $this->get_deps_mock( [ - 'handle' => 'uikit', - 'src' => 'http://beansdev.test/wp-content/uploads/beans/compiler/uikit/ac2cc0a-f36bb75.css', - ] ); + $registered['uikit'] = $this->get_deps_mock( + [ + 'handle' => 'uikit', + 'src' => 'http://beansdev.test/wp-content/uploads/beans/compiler/uikit/ac2cc0a-f36bb75.css', + ] + ); } if ( in_array( 'child-style', $queue, true ) ) { - $registered['child-style'] = $this->get_deps_mock( [ - 'handle' => 'child-style', - 'src' => 'http://beansdev.test/wp-content/themes/tm-beans-child/style.css', - ] ); + $registered['child-style'] = $this->get_deps_mock( + [ + 'handle' => 'child-style', + 'src' => 'http://beansdev.test/wp-content/themes/tm-beans-child/style.css', + ] + ); } if ( in_array( 'debug-bar-actions-filters', $queue, true ) ) { - $registered['debug-bar-actions-filters'] = $this->get_deps_mock( [ - 'handle' => 'debug-bar-actions-filters', - 'src' => 'http://beansdev.test/wp-content/plugins/debug-bar-actions-and-filters-addon/css/debug-bar-actions-filters.css', - 'deps' => [ 'debug-bar' ], - 'ver' => '1.5.1all', - ] ); + $registered['debug-bar-actions-filters'] = $this->get_deps_mock( + [ + 'handle' => 'debug-bar-actions-filters', + 'src' => 'http://beansdev.test/wp-content/plugins/debug-bar-actions-and-filters-addon/css/debug-bar-actions-filters.css', + 'deps' => [ 'debug-bar' ], + 'ver' => '1.5.1all', + ] + ); } $wp_styles_mock->registered = $registered; diff --git a/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php b/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php index 49408bcd..fcc9870d 100644 --- a/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php +++ b/tests/phpunit/unit/api/compiler/beans-page-compiler/dequeueScripts.php @@ -65,10 +65,13 @@ public function test_should_dequeue_scripts() { // Set the scripts to be dequeued. $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'debug-bar' => $assets->registered['debug-bar']->src, - 'uikit' => $assets->registered['uikit']->src, - ] ); + $dequeued_scripts->setValue( + $compiler, + [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ] + ); // Set up the asset mocks. Monkey\Functions\expect( 'beans_get' ) @@ -97,10 +100,13 @@ public function test_should_not_print_inline_when_no_scripts_have_localized_data // Set the scripts to be dequeued. $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'debug-bar' => $assets->registered['debug-bar']->src, - 'uikit' => $assets->registered['uikit']->src, - ] ); + $dequeued_scripts->setValue( + $compiler, + [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ] + ); // Set up the asset mocks. Monkey\Functions\expect( 'beans_get' ) @@ -127,10 +133,13 @@ public function test_should_print_inline_localization_content() { // Set the scripts to be dequeued. $dequeued_scripts = $this->get_reflective_property( 'dequeued_scripts', '_Beans_Page_Compiler' ); - $dequeued_scripts->setValue( $compiler, [ - 'debug-bar' => $assets->registered['debug-bar']->src, - 'uikit' => $assets->registered['uikit']->src, - ] ); + $dequeued_scripts->setValue( + $compiler, + [ + 'debug-bar' => $assets->registered['debug-bar']->src, + 'uikit' => $assets->registered['uikit']->src, + ] + ); // Set up the asset mocks. Monkey\Functions\expect( 'beans_get' ) @@ -170,40 +179,50 @@ protected function get_mock_assets( array $queue, $with_extras = false ) { $wp_scripts_mock = Mockery::mock( 'WP_Scripts' ); $wp_scripts_mock->queue = $queue; $registered = [ - 'jquery' => $this->get_deps_mock( [ - 'handle' => 'jquery', - 'src' => false, - 'deps' => [ 'jquery-core', 'jquery-migrate' ], - 'ver' => '1.12.4', - ] ), - 'jquery-core' => $this->get_deps_mock( [ - 'handle' => 'jquery-core', - 'src' => '/wp-includes/js/jquery/jquery.js', - 'ver' => '1.12.4', - ] ), - 'jquery-migrate' => $this->get_deps_mock( [ - 'handle' => 'jquery-migrate', - 'src' => '/wp-includes/js/jquery/jquery-migrate.js', - 'ver' => '1.4.1', - ] ), + 'jquery' => $this->get_deps_mock( + [ + 'handle' => 'jquery', + 'src' => false, + 'deps' => [ 'jquery-core', 'jquery-migrate' ], + 'ver' => '1.12.4', + ] + ), + 'jquery-core' => $this->get_deps_mock( + [ + 'handle' => 'jquery-core', + 'src' => '/wp-includes/js/jquery/jquery.js', + 'ver' => '1.12.4', + ] + ), + 'jquery-migrate' => $this->get_deps_mock( + [ + 'handle' => 'jquery-migrate', + 'src' => '/wp-includes/js/jquery/jquery-migrate.js', + 'ver' => '1.4.1', + ] + ), ]; if ( in_array( 'debug-bar', $queue, true ) ) { - $registered['debug-bar'] = $this->get_deps_mock( [ - 'handle' => 'debug-bar', - 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', - 'deps' => [ 'jquery' ], - 'ver' => '20170515', - 'extra' => $with_extras ? [ 'data' => 'var testParams = "hello-beans";' ] : [], - ] ); + $registered['debug-bar'] = $this->get_deps_mock( + [ + 'handle' => 'debug-bar', + 'src' => '/wp-content/plugins/debug-bar/js/debug-bar.dev.js', + 'deps' => [ 'jquery' ], + 'ver' => '20170515', + 'extra' => $with_extras ? [ 'data' => 'var testParams = "hello-beans";' ] : [], + ] + ); } if ( in_array( 'uikit', $queue, true ) ) { - $registered['uikit'] = $this->get_deps_mock( [ - 'handle' => 'uikit', - 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', - 'deps' => [ 'jquery' ], - ] ); + $registered['uikit'] = $this->get_deps_mock( + [ + 'handle' => 'uikit', + 'src' => 'wp-content/uploads/beans/compiler/uikit/3b2a958-921f3e0.js', + 'deps' => [ 'jquery' ], + ] + ); } $wp_scripts_mock->registered = $registered; diff --git a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php index 837332ff..3d686efa 100644 --- a/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php +++ b/tests/phpunit/unit/api/compiler/beansCompileJsFragments.php @@ -28,9 +28,15 @@ class Test_BeansCompileJsFragments extends Compiler_Test_Case { public function test_should_return_false_when_no_fragments_given() { $this->assertFalse( beans_compile_js_fragments( 'foo', '' ) ); $this->assertFalse( beans_compile_js_fragments( 'foo', [] ) ); - $this->assertFalse( beans_compile_js_fragments( 'foo', [], [ - 'dependencies' => [], - 'in_footer' => true, - ] ) ); + $this->assertFalse( + beans_compile_js_fragments( + 'foo', + [], + [ + 'dependencies' => [], + 'in_footer' => true, + ] + ) + ); } } diff --git a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php index 7ffcdfbb..e0cbced9 100644 --- a/tests/phpunit/unit/api/compiler/beansFlushCompiler.php +++ b/tests/phpunit/unit/api/compiler/beansFlushCompiler.php @@ -92,18 +92,20 @@ public function test_should_remove_all_cached_files() { Monkey\Functions\expect( 'beans_remove_dir' ) ->once() ->with( trailingslashit( $compiler_dir ) . 'beans' ) - ->andReturnUsing( function( $dir_path ) { - $items = scandir( $dir_path ); - unset( $items[0], $items[1] ); + ->andReturnUsing( + function( $dir_path ) { + $items = scandir( $dir_path ); + unset( $items[0], $items[1] ); - $dir_path = trailingslashit( $dir_path ); + $dir_path = trailingslashit( $dir_path ); - foreach ( $items as $needle => $item ) { - unlink( $dir_path . $item ); - } + foreach ( $items as $needle => $item ) { + unlink( $dir_path . $item ); + } - return rmdir( $dir_path ); - } ); + return rmdir( $dir_path ); + } + ); $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/1234567-9876543.css' ) ); $this->assertFileExists( vfsStream::url( 'compiled/beans/compiler/beans/abcd3fg-hijklmn.js' ) ); diff --git a/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php index ff32f3de..8aacccdd 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-base-test-case.php @@ -50,10 +50,12 @@ protected function setUp() { $this->compiled_dir = vfsStream::url( 'compiled' ); $this->compiled_url = 'http:://beans.test/compiled/'; - $this->load_original_functions( [ - 'api/utilities/functions.php', - 'api/compiler/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/utilities/functions.php', + 'api/compiler/functions.php', + ] + ); $this->setup_common_wp_stubs(); } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php index 4e19c981..5eb1634c 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-options-test-case.php @@ -24,10 +24,12 @@ abstract class Compiler_Options_Test_Case extends Base_Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/compiler/class-beans-compiler-options.php', - 'api/options/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/compiler/class-beans-compiler-options.php', + 'api/options/functions.php', + ] + ); $this->setup_common_wp_stubs(); } diff --git a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php index 6e2ce000..35fe2613 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-compiler-test-case.php @@ -81,9 +81,11 @@ protected function setUp() { parent::setUp(); $this->set_up_function_mocks(); - $this->load_original_functions( [ - 'api/compiler/class-beans-compiler.php', - ] ); + $this->load_original_functions( + [ + 'api/compiler/class-beans-compiler.php', + ] + ); } /** @@ -127,14 +129,16 @@ private function get_fixtures_content() { * Set up function mocks. */ protected function set_up_function_mocks() { - Functions\when( 'wp_upload_dir' )->justReturn( [ - 'path' => '', - 'url' => '', - 'subdir' => '', - 'basedir' => $this->compiled_dir, - 'baseurl' => $this->compiled_url, - 'error' => false, - ] ); + Functions\when( 'wp_upload_dir' )->justReturn( + [ + 'path' => '', + 'url' => '', + 'subdir' => '', + 'basedir' => $this->compiled_dir, + 'baseurl' => $this->compiled_url, + 'error' => false, + ] + ); Functions\when( 'is_admin' )->justReturn( $this->is_admin ); Functions\when( 'site_url' )->justReturn( 'http:://beans.local' ); } diff --git a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php index 2eee3353..f2001a7b 100644 --- a/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php +++ b/tests/phpunit/unit/api/compiler/includes/class-page-compiler-test-case.php @@ -25,10 +25,12 @@ abstract class Page_Compiler_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/compiler/class-beans-page-compiler.php', - 'api/options/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/compiler/class-beans-page-compiler.php', + 'api/options/functions.php', + ] + ); } /** diff --git a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php index 28859a6f..40255e40 100644 --- a/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php +++ b/tests/phpunit/unit/api/fields/includes/class-fields-test-case.php @@ -43,12 +43,14 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/actions/functions.php', - 'api/fields/functions.php', - 'api/fields/class-beans-fields.php', - 'api/utilities/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/actions/functions.php', + 'api/fields/functions.php', + 'api/fields/class-beans-fields.php', + 'api/utilities/functions.php', + ] + ); $this->setup_function_mocks(); $this->setup_common_wp_stubs(); @@ -65,14 +67,17 @@ protected function setUp() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $merged_field = array_merge( [ - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => 'beans_tests', - 'attributes' => [], - 'db_group' => false, - ], $field ); + $merged_field = array_merge( + [ + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'beans_tests', + 'attributes' => [], + 'db_group' => false, + ], + $field + ); $merged_field['name'] = 'beans_fields[' . $field['id'] . ']'; if ( $set_value ) { @@ -86,44 +91,54 @@ protected function merge_field_with_default( array $field, $set_value = true ) { * Set up function mocks. */ protected function setup_function_mocks() { - Monkey\Functions\when( 'checked' )->alias( function( $actual, $value ) { + Monkey\Functions\when( 'checked' )->alias( + function( $actual, $value ) { - if ( $actual === $value ) { - echo " checked='checked'"; + if ( $actual === $value ) { + echo " checked='checked'"; + } } - } ); + ); + + Monkey\Functions\when( 'selected' )->alias( + function( $actual, $value ) { - Monkey\Functions\when( 'selected' )->alias( function( $actual, $value ) { + if ( $actual === $value ) { + echo " selected='selected'"; + } + } + ); - if ( $actual === $value ) { - echo " selected='selected'"; + Monkey\Functions\when( '_n' )->alias( + function( $single, $plural, $number ) { + return $number > 1 ? $plural : $single; } - } ); + ); - Monkey\Functions\when( '_n' )->alias( function( $single, $plural, $number ) { - return $number > 1 ? $plural : $single; - } ); + Monkey\Functions\when( 'beans_get' )->alias( + function( $needle, $haystack = false, $default = null ) { + $haystack = (array) $haystack; - Monkey\Functions\when( 'beans_get' )->alias( function( $needle, $haystack = false, $default = null ) { - $haystack = (array) $haystack; + return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; + } + ); - return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; - } ); + Monkey\Functions\when( 'beans_esc_attributes' )->alias( + function( $attributes ) { + $string = ''; - Monkey\Functions\when( 'beans_esc_attributes' )->alias( function( $attributes ) { - $string = ''; + foreach ( (array) $attributes as $attribute => $value ) { - foreach ( (array) $attributes as $attribute => $value ) { + if ( null === $value ) { + continue; + } - if ( null === $value ) { - continue; + $string .= $attribute . '="' . $value . '" '; } - $string .= $attribute . '="' . $value . '" '; + return trim( $string ); } - - return trim( $string ); - } ); + ); Monkey\Functions\when( 'beans_add_smart_action' )->justReturn(); } diff --git a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php index 579b5d84..075a7931 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldActivation.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldActivation.php @@ -36,11 +36,13 @@ protected function setUp() { * Test beans_field_activation() should render the activation field. */ public function test_should_render_activation_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -60,14 +62,16 @@ public function test_should_render_activation_field() { * Test beans_field_activation() should render the activation field with attributes when given. */ public function test_should_render_activation_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'default' => false, + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php index 136aa915..fcc7db5d 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldCheckbox.php @@ -36,13 +36,15 @@ protected function setUp() { * Test beans_field_checkbox() should render the checkbox with the label when given. */ public function test_should_render_checkbox_with_label_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'label' => false, + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -62,11 +64,13 @@ public function test_should_render_checkbox_with_label_when_given() { * Test beans_field_checkbox() should render the checkbox with the default label when none is given. */ public function test_should_render_checkbox_with_default_label_when_none_is_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'type' => 'checkbox', - 'default' => false, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'type' => 'checkbox', + 'default' => false, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,15 +90,17 @@ public function test_should_render_checkbox_with_default_label_when_none_is_give * Test beans_field_checkbox() should render the checkbox with attributes when given. */ public function test_should_render_checkbox_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_styles', - 'checkbox_label' => 'Compile all WordPress styles', - 'type' => 'checkbox', - 'default' => false, - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_styles', + 'checkbox_label' => 'Compile all WordPress styles', + 'type' => 'checkbox', + 'default' => false, + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldImage.php b/tests/phpunit/unit/api/fields/types/beansFieldImage.php index 1ecf6d60..d5dad500 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldImage.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldImage.php @@ -45,12 +45,15 @@ public function test_should_render_single_image_field_and_hide_upload_button_whe ->once() ->andReturn( 'This is the image alt value.' ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => 1, // Attachment ID. - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => 1, // Attachment ID. + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -90,24 +93,30 @@ public function test_should_render_single_image_field_and_hide_upload_button_whe public function test_should_render_multiple_images_field_and_show_upload_button_when_images_exist() { Monkey\Functions\expect( 'wp_get_attachment_image_src' ) ->times( 2 ) - ->andReturnUsing( function ( $image_id ) { - if ( 'placeholder' === $image_id ) { - return ''; - } + ->andReturnUsing( + function ( $image_id ) { + + if ( 'placeholder' === $image_id ) { + return ''; + } - return "image-{$image_id}.png"; - } ); + return "image-{$image_id}.png"; + } + ); Monkey\Functions\expect( 'get_post_meta' ) ->times( 2 ) ->andReturn( 'This is the image alt value.' ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => [ 1, 2 ], // Attachment IDs. - 'multiple' => true, - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => [ 1, 2 ], // Attachment IDs. + 'multiple' => true, + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -163,12 +172,15 @@ public function test_should_render_single_image_field_with_default_alt_when_none ->once() ->andReturn( '' ); - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => 1, // Attachment ID. - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => 1, // Attachment ID. + ], + false + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -208,12 +220,15 @@ public function test_should_render_single_image_field_with_default_alt_when_none * @link https://github.com/Getbeans/Beans/issues/305 */ public function test_should_show_upload_button_for_single_image_field_without_image() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'value' => null, // Attachment ID. - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'value' => null, // Attachment ID. + ], + false + ); Monkey\Functions\expect( 'wp_get_attachment_image_src' )->never(); Monkey\Functions\expect( 'get_post_meta' )->never(); @@ -248,13 +263,16 @@ public function test_should_show_upload_button_for_single_image_field_without_im * @link https://github.com/Getbeans/Beans/issues/305 */ public function test_should_show_upload_button_for_multiple_image_field_without_image() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_image_test', - 'type' => 'image', - 'label' => 'Image Test', - 'multiple' => true, - 'value' => null, // Attachment ID. - ], false ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_image_test', + 'type' => 'image', + 'label' => 'Image Test', + 'multiple' => true, + 'value' => null, // Attachment ID. + ], + false + ); Monkey\Functions\expect( 'wp_get_attachment_image_src' )->never(); Monkey\Functions\expect( 'get_post_meta' )->never(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php index e6a197c1..ece7d66a 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldRadio.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldRadio.php @@ -36,19 +36,21 @@ protected function setUp() { * Test beans_field_radio() should render the radio field with image options. */ public function test_should_render_radio_field_with_image_options() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => 'http://example.com/images/layouts/c.png', - 'c_sp' => 'http://example.com/images/layouts/c_sp.png', - 'sp_c' => 'http://example.com/images/layouts/sp_c.png', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_layout', + 'label' => 'Layout', + 'description' => 'The layout settings.', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => [ + 'default_fallback' => 'Use Default Layout', + 'c' => 'http://example.com/images/layouts/c.png', + 'c_sp' => 'http://example.com/images/layouts/c_sp.png', + 'sp_c' => 'http://example.com/images/layouts/sp_c.png', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -86,29 +88,31 @@ public function test_should_render_radio_field_with_image_options() { * Test beans_field_radio() should render accessible images when accessibility parameters are given. */ public function test_should_render_accessible_images_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_layout', - 'label' => 'Layout', - 'description' => 'The layout settings.', - 'type' => 'radio', - 'default' => 'default_fallback', - 'options' => [ - 'default_fallback' => 'Use Default Layout', - 'c' => [ - 'src' => 'http://example.com/images/layouts/c.png', - 'alt' => 'Content Only Layout', - 'screen_reader_text' => 'Option for the Content Only Layout', - ], - 'c_sp' => [ - 'src' => 'http://example.com/images/layouts/c_sp.png', - 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', - ], - 'sp_c' => [ - 'src' => 'http://example.com/images/layouts/sp_c.png', - 'alt' => 'Sidebar Primary + Content Layout', + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_layout', + 'label' => 'Layout', + 'description' => 'The layout settings.', + 'type' => 'radio', + 'default' => 'default_fallback', + 'options' => [ + 'default_fallback' => 'Use Default Layout', + 'c' => [ + 'src' => 'http://example.com/images/layouts/c.png', + 'alt' => 'Content Only Layout', + 'screen_reader_text' => 'Option for the Content Only Layout', + ], + 'c_sp' => [ + 'src' => 'http://example.com/images/layouts/c_sp.png', + 'screen_reader_text' => 'Option for the Content + Sidebar Primary Layout', + ], + 'sp_c' => [ + 'src' => 'http://example.com/images/layouts/sp_c.png', + 'alt' => 'Sidebar Primary + Content Layout', + ], ], - ], - ] ); + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php index a7d50c18..b083c3ed 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSelect.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSelect.php @@ -36,15 +36,17 @@ protected function setUp() { * Test beans_field_checkbox() should render the select field. */ public function test_should_render_select_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'aggressive', + 'options' => [ + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -65,18 +67,20 @@ public function test_should_render_select_field() { * Test beans_field_select() should render the select field with attributes when given. */ public function test_should_render_select_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'standard', - 'options' => [ - 'aggressive' => 'Aggressive', - 'standard' => 'Standard', - ], - 'attributes' => [ - 'style' => 'margin: -3px 0 0 -8px;', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'default' => 'standard', + 'options' => [ + 'aggressive' => 'Aggressive', + 'standard' => 'Standard', + ], + 'attributes' => [ + 'style' => 'margin: -3px 0 0 -8px;', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php index 9fcf4acb..34aa8c75 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldSlider.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldSlider.php @@ -36,16 +36,18 @@ protected function setUp() { * Test beans_field_slider() should render the slider field. */ public function test_should_render_slider_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 0, - 'max' => 100, - 'interval' => 1, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 0, + 'max' => 100, + 'interval' => 1, + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -66,17 +68,19 @@ public function test_should_render_slider_field() { * Test beans_field_slider() should render the slider field with unit when given. */ public function test_should_render_slider_field_with_unit_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - 'unit' => 'Number of beans', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + 'unit' => 'Number of beans', + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); @@ -98,16 +102,18 @@ public function test_should_render_slider_field_with_unit_when_given() { * Test beans_field_slider() should render the slider with the current value. */ public function test_should_render_slider_with_current_value() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 0, - 'min' => 10, - 'max' => 100, - 'interval' => 5, - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 0, + 'min' => 10, + 'max' => 100, + 'interval' => 5, + ] + ); $field['value'] = 15; // Run the function and grab the HTML out of the buffer. @@ -129,20 +135,22 @@ public function test_should_render_slider_with_current_value() { * Test beans_field_slider() should render the slider field with attributes when given. */ public function test_should_render_slider_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_test_slider', - 'label' => 'Test Slider', - 'description' => 'Testing the slider', - 'type' => 'slider', - 'default' => 1, - 'min' => 1, - 'max' => 20, - 'interval' => 1, - 'unit' => 'Number of beans', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_test_slider', + 'label' => 'Test Slider', + 'description' => 'Testing the slider', + 'type' => 'slider', + 'default' => 1, + 'min' => 1, + 'max' => 20, + 'interval' => 1, + 'unit' => 'Number of beans', + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); // Run the function and grab the HTML out of the buffer. ob_start(); diff --git a/tests/phpunit/unit/api/fields/types/beansFieldText.php b/tests/phpunit/unit/api/fields/types/beansFieldText.php index 95860f44..3cc2c311 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldText.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldText.php @@ -36,11 +36,13 @@ protected function setUp() { * Test beans_field_text() should render the text field. */ public function test_should_render_text_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + ] + ); $field['value'] = 'Testing the text field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +61,16 @@ public function test_should_render_text_field() { * Test beans_field_text() should render the text field with attributes when given. */ public function test_should_render_text_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_text_test', - 'type' => 'text', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_text_test', + 'type' => 'text', + 'default' => '', + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); $field['value'] = 'Testing the text field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php index db7c0fd0..3ac6a1f6 100644 --- a/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php +++ b/tests/phpunit/unit/api/fields/types/beansFieldTextarea.php @@ -36,11 +36,13 @@ protected function setUp() { * Test beans_field_textarea() should render the textarea field. */ public function test_should_render_textarea_field() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + ] + ); $field['value'] = 'Testing the textarea field.'; // Run the function and grab the HTML out of the buffer. @@ -59,14 +61,16 @@ public function test_should_render_textarea_field() { * Test beans_field_textarea() should render the textarea field with attributes when given. */ public function test_should_render_textarea_field_with_attributes_when_given() { - $field = $this->merge_field_with_default( [ - 'id' => 'beans_textarea_test', - 'type' => 'textarea', - 'default' => '', - 'attributes' => [ - 'data-test' => 'foo', - ], - ] ); + $field = $this->merge_field_with_default( + [ + 'id' => 'beans_textarea_test', + 'type' => 'textarea', + 'default' => '', + 'attributes' => [ + 'data-test' => 'foo', + ], + ] + ); $field['value'] = 'Testing the textarea field with attributes.'; // Run the function and grab the HTML out of the buffer. diff --git a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php index f7350b2d..20dd5253 100644 --- a/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php +++ b/tests/phpunit/unit/api/filters/includes/class-filters-test-case.php @@ -43,9 +43,11 @@ protected function setUp() { $this->mock_filter_callbacks(); - $this->load_original_functions( [ - 'api/filters/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/filters/functions.php', + ] + ); } /** @@ -69,14 +71,18 @@ protected function tearDown() { * Define the mocks for the filter callbacks. */ protected function mock_filter_callbacks() { - Monkey\Functions\when( 'beans_test_the_content' )->alias( function ( $post_title, $post_id ) { - return $post_title . '_' . $post_id; - } ); + Monkey\Functions\when( 'beans_test_the_content' )->alias( + function ( $post_title, $post_id ) { + return $post_title . '_' . $post_id; + } + ); Monkey\Functions\when( 'beans_test_modify_widget_count' )->justReturn( 20 ); Monkey\Functions\when( 'beans_test_query_args_base' )->justReturn( [ 'base' ] ); - Monkey\Functions\when( 'beans_test_query_args_main' )->alias( function ( $args ) { - $args[] = '_main'; - return $args; - } ); + Monkey\Functions\when( 'beans_test_query_args_main' )->alias( + function ( $args ) { + $args[] = '_main'; + return $args; + } + ); } } diff --git a/tests/phpunit/unit/api/html/beansAddAttributes.php b/tests/phpunit/unit/api/html/beansAddAttributes.php index 4a22ae4f..54234dda 100644 --- a/tests/phpunit/unit/api/html/beansAddAttributes.php +++ b/tests/phpunit/unit/api/html/beansAddAttributes.php @@ -29,22 +29,24 @@ class Tests_BeansAddAttributes extends HTML_Test_Case { protected function setup() { parent::setUp(); - Monkey\Functions\when( 'wp_parse_args' )->alias( function( $args ) { + Monkey\Functions\when( 'wp_parse_args' )->alias( + function( $args ) { - if ( is_array( $args ) ) { - return $args; - } + if ( is_array( $args ) ) { + return $args; + } - if ( is_object( $args ) ) { - return get_object_vars( $args ); - } + if ( is_object( $args ) ) { + return get_object_vars( $args ); + } - if ( is_string( $args ) ) { - parse_str( $args, $result ); + if ( is_string( $args ) ) { + parse_str( $args, $result ); - return $result; + return $result; + } } - } ); + ); } /** diff --git a/tests/phpunit/unit/api/html/beansModifyMarkup.php b/tests/phpunit/unit/api/html/beansModifyMarkup.php index fdaeebc5..15d3f5be 100644 --- a/tests/phpunit/unit/api/html/beansModifyMarkup.php +++ b/tests/phpunit/unit/api/html/beansModifyMarkup.php @@ -37,9 +37,11 @@ protected function setUp() { * Test beans_modify_markup() should return an anonymous filter instance. */ public function test_should_return_anonymous_filter_instance() { - Monkey\Functions\when( 'beans_add_filter' )->alias( function( $hook, $value ) { - return new Anonymous_Filter_Stub( $hook, $value, 10 ); - } ); + Monkey\Functions\when( 'beans_add_filter' )->alias( + function( $hook, $value ) { + return new Anonymous_Filter_Stub( $hook, $value, 10 ); + } + ); $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_modify_markup( 'beans_archive_title', 'h2' ) ); } diff --git a/tests/phpunit/unit/api/html/beansOpenMarkup.php b/tests/phpunit/unit/api/html/beansOpenMarkup.php index 2fad6d00..877d3681 100644 --- a/tests/phpunit/unit/api/html/beansOpenMarkup.php +++ b/tests/phpunit/unit/api/html/beansOpenMarkup.php @@ -158,9 +158,11 @@ public function test_should_return_built_self_closing_html_when_selfclose_markup Monkey\Functions\expect( 'beans_add_attributes' ) ->twice() ->with( 'beans_post_image_item', $args, 'http://example.com/image.png' ) - ->andReturnUsing( function( $id, $attributes ) { - return $this->convert_attributes_into_html( $attributes ); - } ); + ->andReturnUsing( + function( $id, $attributes ) { + return $this->convert_attributes_into_html( $attributes ); + } + ); // Run it with development mode off. Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); diff --git a/tests/phpunit/unit/api/html/beansOutput.php b/tests/phpunit/unit/api/html/beansOutput.php index 62c28ebe..ad815620 100644 --- a/tests/phpunit/unit/api/html/beansOutput.php +++ b/tests/phpunit/unit/api/html/beansOutput.php @@ -27,9 +27,11 @@ class Tests_BeansOutput extends HTML_Test_Case { * Test beans_output() should return null when the output is empty. */ public function test_should_return_null_when_output_is_empty() { - Monkey\Functions\expect( 'beans_apply_filters' )->times( 3 )->andReturnUsing( function( $hook, $output ) { - return $output; - } ); + Monkey\Functions\expect( 'beans_apply_filters' )->times( 3 )->andReturnUsing( + function( $hook, $output ) { + return $output; + } + ); Monkey\Functions\expect( '_beans_is_html_dev_mode' )->never(); $this->assertNull( beans_output( 'beans_post_meta_item_date', null ) ); @@ -51,9 +53,11 @@ public function test_should_return_filtered_output_after_firing_output_filter_ho Monkey\Functions\expect( 'beans_apply_filters' ) ->once() ->with( 'beans_archive_title_text_output', 'Beans rocks!' ) - ->andReturnUsing( function( $hook, $output ) { - return apply_filters( $hook, $output ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Prefix is in the value represented by the variable. - } ); + ->andReturnUsing( + function( $hook, $output ) { + return apply_filters( $hook, $output ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Prefix is in the value represented by the variable. + } + ); // Check with HTML dev mode disabled. Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); @@ -94,9 +98,11 @@ public function test_should_pass_additional_args_when_firing_filter_hook() { Monkey\Functions\expect( 'beans_apply_filters' ) ->twice() ->with( 'beans_breadcrumb_item_text_output', 'Beans rocks!', 47, 'Hello' ) - ->andReturnUsing( function( $hook, $output ) { - return $output; - } ); + ->andReturnUsing( + function( $hook, $output ) { + return $output; + } + ); // Check with HTML dev mode disabled. Monkey\Functions\expect( '_beans_is_html_dev_mode' )->once()->andReturn( false ); diff --git a/tests/phpunit/unit/api/html/beansOutputE.php b/tests/phpunit/unit/api/html/beansOutputE.php index 230bf1e1..e5a1cd29 100644 --- a/tests/phpunit/unit/api/html/beansOutputE.php +++ b/tests/phpunit/unit/api/html/beansOutputE.php @@ -27,9 +27,11 @@ class Tests_BeansOutputE extends HTML_Test_Case { * Test beans_output_e() should echo an empty string when the output is empty. */ public function test_should_echo_empty_string_when_output_is_empty() { - Monkey\Functions\expect( 'beans_output' )->times( 3 )->andReturnUsing( function( $id, $output ) { - return $output; - } ); + Monkey\Functions\expect( 'beans_output' )->times( 3 )->andReturnUsing( + function( $id, $output ) { + return $output; + } + ); $ids = [ 'beans_post_meta_item_date' => null, @@ -66,9 +68,11 @@ public function test_should_echo_output_when_not_in_html_dev_mode() { Monkey\Functions\expect( 'beans_output' ) ->once() ->with( 'beans_archive_title_text', 'Beans rocks!' ) - ->andReturnUsing( function( $id, $output ) { - return $output; - } ); + ->andReturnUsing( + function( $id, $output ) { + return $output; + } + ); ob_start(); beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); @@ -82,9 +86,11 @@ public function test_should_echo_comment_wrapped_html_when_in_html_dev_mode() { Monkey\Functions\expect( 'beans_output' ) ->once() ->with( 'beans_archive_title_text', 'Beans rocks!' ) - ->andReturnUsing( function( $id, $output ) { - return "" . $output . ""; - } ); + ->andReturnUsing( + function( $id, $output ) { + return "" . $output . ""; + } + ); ob_start(); beans_output_e( 'beans_archive_title_text', 'Beans rocks!' ); @@ -103,9 +109,11 @@ public function test_should_pass_additional_args() { Monkey\Functions\expect( 'beans_output' ) ->once() ->with( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ) - ->andReturnUsing( function( $id, $output, $arg1, $arg2 ) { - return $arg2; - } ); + ->andReturnUsing( + function( $id, $output, $arg1, $arg2 ) { + return $arg2; + } + ); ob_start(); beans_output_e( 'beans_breadcrumb_item_text', 'Beans rocks!', 47, 'Hello' ); diff --git a/tests/phpunit/unit/api/html/beansRemoveMarkup.php b/tests/phpunit/unit/api/html/beansRemoveMarkup.php index 93b48ac3..e9ba9745 100644 --- a/tests/phpunit/unit/api/html/beansRemoveMarkup.php +++ b/tests/phpunit/unit/api/html/beansRemoveMarkup.php @@ -37,9 +37,11 @@ protected function setUp() { * Test beans_remove_markup() should return an anonymous filter instance. */ public function test_should_return_anonymous_filter_instance() { - Monkey\Functions\when( 'beans_add_filter' )->alias( function( $hook, $value ) { - return new Anonymous_Filter_Stub( $hook, $value, 10 ); - } ); + Monkey\Functions\when( 'beans_add_filter' )->alias( + function( $hook, $value ) { + return new Anonymous_Filter_Stub( $hook, $value, 10 ); + } + ); $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_remove_markup( 'beans_archive_title' ) ); } diff --git a/tests/phpunit/unit/api/html/beansRemoveOutput.php b/tests/phpunit/unit/api/html/beansRemoveOutput.php index df03be4e..08d09281 100644 --- a/tests/phpunit/unit/api/html/beansRemoveOutput.php +++ b/tests/phpunit/unit/api/html/beansRemoveOutput.php @@ -37,9 +37,11 @@ protected function setUp() { * Test beans_remove_output() should return an anonymous filter instance. */ public function test_should_return_anonymous_filter_instance() { - Monkey\Functions\when( 'beans_add_filter' )->alias( function( $hook, $value, $priority ) { - return new Anonymous_Filter_Stub( $hook, $value, $priority ); - } ); + Monkey\Functions\when( 'beans_add_filter' )->alias( + function( $hook, $value, $priority ) { + return new Anonymous_Filter_Stub( $hook, $value, $priority ); + } + ); $this->assertInstanceOf( Anonymous_Filter_Stub::class, beans_remove_output( 'beans_post_meta_item_date' ) ); } diff --git a/tests/phpunit/unit/api/html/includes/class-html-test-case.php b/tests/phpunit/unit/api/html/includes/class-html-test-case.php index 05b70c4b..3fc640c2 100644 --- a/tests/phpunit/unit/api/html/includes/class-html-test-case.php +++ b/tests/phpunit/unit/api/html/includes/class-html-test-case.php @@ -47,9 +47,12 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$test_markup = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-markup.php'; - static::$test_attributes = array_filter( static::$test_markup, function( $markup ) { - return isset( $markup['attributes'] ); - } ); + static::$test_attributes = array_filter( + static::$test_markup, + function( $markup ) { + return isset( $markup['attributes'] ); + } + ); static::$test_attachments = require dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'fixtures/test-attachment.php'; } @@ -62,14 +65,16 @@ protected function setUp() { $this->setup_function_mocks(); $this->setup_common_wp_stubs(); - $this->load_original_functions( [ - 'api/html/class-beans-attribute.php', - 'api/html/functions.php', - 'api/html/accessibility.php', - 'api/filters/functions.php', - 'api/layout/functions.php', - 'api/widget/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/html/class-beans-attribute.php', + 'api/html/functions.php', + 'api/html/accessibility.php', + 'api/filters/functions.php', + 'api/layout/functions.php', + 'api/widget/functions.php', + ] + ); // Reset the test fixtures. reset( static::$test_markup ); diff --git a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php index 3bc90539..1ed3fd64 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/createEditedImage.php @@ -64,9 +64,11 @@ public function test_should_edit_create_and_store_image() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $src ) { - imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); - } ); + ->andReturnUsing( + function( $edited_image_src ) use ( $src ) { + imagejpeg( imagecreatefromjpeg( $src ), $edited_image_src ); + } + ); Monkey\Functions\expect( 'wp_get_image_editor' )->with( $src )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); diff --git a/tests/phpunit/unit/api/image/beans-image-editor/run.php b/tests/phpunit/unit/api/image/beans-image-editor/run.php index 8b55617b..b862aced 100644 --- a/tests/phpunit/unit/api/image/beans-image-editor/run.php +++ b/tests/phpunit/unit/api/image/beans-image-editor/run.php @@ -51,9 +51,11 @@ public function test_should_edit_store_image_and_return_its_url() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); + ->andReturnUsing( + function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); + } + ); Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); @@ -123,9 +125,11 @@ public function test_should_edit_store_image_and_return_indexed_array() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); + ->andReturnUsing( + function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); + } + ); Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); @@ -195,9 +199,11 @@ public function test_should_edit_store_image_and_return_object() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); + ->andReturnUsing( + function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); + } + ); Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); @@ -278,9 +284,11 @@ public function test_should_edit_store_image_and_return_associative_array() { $wp_editor->shouldReceive( 'save' ) ->once() ->with( $edited_image_src ) - ->andReturnUsing( function( $edited_image_src ) use ( $actual_path ) { - imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); - } ); + ->andReturnUsing( + function( $edited_image_src ) use ( $actual_path ) { + imagejpeg( imagecreatefromjpeg( $actual_path ), $edited_image_src ); + } + ); Monkey\Functions\expect( 'wp_get_image_editor' )->with( $actual_path )->once()->andReturn( $wp_editor ); Monkey\Functions\when( 'is_wp_error' )->justReturn( false ); diff --git a/tests/phpunit/unit/api/image/beans-image-options/flush.php b/tests/phpunit/unit/api/image/beans-image-options/flush.php index 029897dd..f232412f 100644 --- a/tests/phpunit/unit/api/image/beans-image-options/flush.php +++ b/tests/phpunit/unit/api/image/beans-image-options/flush.php @@ -63,10 +63,12 @@ public function test_should_remove_cached_dir() { Monkey\Functions\expect( 'beans_remove_dir' ) ->once() ->with( vfsStream::url( 'uploads/beans/images/' ) ) - ->andReturnUsing( function() { - // Keep it simple. Remove by redefining. - vfsStream::setup( 'uploads', 0755, [ 'beans' => [] ] ); - } ); + ->andReturnUsing( + function() { + // Keep it simple. Remove by redefining. + vfsStream::setup( 'uploads', 0755, [ 'beans' => [] ] ); + } + ); $this->assertNull( ( new _Beans_Image_Options() )->flush() ); $this->assertDirectoryNotExists( vfsStream::url( 'uploads/beans/images/' ) ); diff --git a/tests/phpunit/unit/api/image/includes/class-base-test-case.php b/tests/phpunit/unit/api/image/includes/class-base-test-case.php index aa367885..77a52056 100644 --- a/tests/phpunit/unit/api/image/includes/class-base-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-base-test-case.php @@ -48,10 +48,12 @@ protected function setUp() { $this->set_up_virtual_filesystem(); - $this->load_original_functions( [ - 'api/utilities/functions.php', - 'api/image/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/utilities/functions.php', + 'api/image/functions.php', + ] + ); $this->setup_common_wp_stubs(); } diff --git a/tests/phpunit/unit/api/image/includes/class-image-test-case.php b/tests/phpunit/unit/api/image/includes/class-image-test-case.php index 294a2a5a..c692ffe1 100644 --- a/tests/phpunit/unit/api/image/includes/class-image-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-image-test-case.php @@ -74,9 +74,11 @@ protected function setUp() { $this->setup_function_mocks(); - $this->load_original_functions( [ - 'api/image/class-beans-image-editor.php', - ] ); + $this->load_original_functions( + [ + 'api/image/class-beans-image-editor.php', + ] + ); $this->images = [ $this->images_dir . '/image1.jpg' => static::$fixtures_dir . '/image1.jpg', @@ -127,13 +129,15 @@ protected function setup_function_mocks() { Monkey\Functions\when( 'beans_url_to_path' )->returnArg(); Monkey\Functions\when( 'beans_path_to_url' )->returnArg(); - Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( [ - 'path' => '', - 'url' => '', - 'subdir' => '', - 'basedir' => vfsStream::url( 'uploads' ), - 'baseurl' => $this->images_url, - 'error' => false, - ] ); + Monkey\Functions\expect( 'wp_upload_dir' )->andReturn( + [ + 'path' => '', + 'url' => '', + 'subdir' => '', + 'basedir' => vfsStream::url( 'uploads' ), + 'baseurl' => $this->images_url, + 'error' => false, + ] + ); } } diff --git a/tests/phpunit/unit/api/image/includes/class-options-test-case.php b/tests/phpunit/unit/api/image/includes/class-options-test-case.php index 6cfe3b5b..8ade49e2 100644 --- a/tests/phpunit/unit/api/image/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/image/includes/class-options-test-case.php @@ -24,9 +24,11 @@ abstract class Options_Test_Case extends Base_Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/image/class-beans-image-options.php', - 'api/options/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/image/class-beans-image-options.php', + 'api/options/functions.php', + ] + ); } } diff --git a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php index 4d43aefc..0c7cf010 100644 --- a/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetDefaultLayout.php @@ -27,10 +27,12 @@ class Tests_BeansGetDefaultLayout extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/layout/functions.php', - 'api/widget/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/layout/functions.php', + 'api/widget/functions.php', + ] + ); } /** diff --git a/tests/phpunit/unit/api/layout/beansGetLayout.php b/tests/phpunit/unit/api/layout/beansGetLayout.php index ea94e30d..a9d7b0f2 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayout.php +++ b/tests/phpunit/unit/api/layout/beansGetLayout.php @@ -27,11 +27,13 @@ class Tests_BeansGetLayout extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/layout/functions.php', - 'api/post-meta/functions.php', - 'api/term-meta/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/layout/functions.php', + 'api/post-meta/functions.php', + 'api/term-meta/functions.php', + ] + ); } /** diff --git a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php index 41f48172..ff2310a5 100644 --- a/tests/phpunit/unit/api/layout/beansGetLayoutClass.php +++ b/tests/phpunit/unit/api/layout/beansGetLayoutClass.php @@ -27,18 +27,22 @@ class Tests_BeansGetLayoutClass extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( - 'api/layout/functions.php', - 'api/utilities/functions.php', - 'api/post-meta/functions.php', - ) ); + $this->load_original_functions( + array( + 'api/layout/functions.php', + 'api/utilities/functions.php', + 'api/post-meta/functions.php', + ) + ); - Monkey\Functions\when( 'beans_get' )->alias( function ( $needle, $haystack ) { + Monkey\Functions\when( 'beans_get' )->alias( + function ( $needle, $haystack ) { - if ( isset( $haystack[ $needle ] ) ) { - return $haystack[ $needle ]; + if ( isset( $haystack[ $needle ] ) ) { + return $haystack[ $needle ]; + } } - } ); + ); } /** diff --git a/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php b/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php index 881d18b5..76fe0cb1 100644 --- a/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php +++ b/tests/phpunit/unit/api/layout/beansHasPrimarySidebar.php @@ -27,9 +27,11 @@ class Tests_BeansHasPrimarySidebar extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( array( - 'api/layout/functions.php', - ) ); + $this->load_original_functions( + array( + 'api/layout/functions.php', + ) + ); } /** diff --git a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php index 63d33d0d..31dbf248 100644 --- a/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php +++ b/tests/phpunit/unit/api/layout/beansHasSecondarySidebar.php @@ -27,9 +27,11 @@ class Tests_BeansHasSecondarySidebar extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/layout/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/layout/functions.php', + ] + ); } /** diff --git a/tests/phpunit/unit/api/options/beans-options/register.php b/tests/phpunit/unit/api/options/beans-options/register.php index e044ee1c..bf9a174e 100644 --- a/tests/phpunit/unit/api/options/beans-options/register.php +++ b/tests/phpunit/unit/api/options/beans-options/register.php @@ -32,17 +32,23 @@ public function test_should_merge_default_args_and_set_property() { $instance = new _Beans_Options(); $instance->register( 'foo', [] ); - $this->assertSame( [ - 'title' => 'Undefined', - 'context' => 'normal', - ], $property->getValue( $instance ) ); + $this->assertSame( + [ + 'title' => 'Undefined', + 'context' => 'normal', + ], + $property->getValue( $instance ) + ); $instance = new _Beans_Options(); $instance->register( 'beans_test', [ 'title' => 'Beans Tests' ] ); - $this->assertSame( [ - 'title' => 'Beans Tests', - 'context' => 'normal', - ], $property->getValue( $instance ) ); + $this->assertSame( + [ + 'title' => 'Beans Tests', + 'context' => 'normal', + ], + $property->getValue( $instance ) + ); } /** @@ -73,12 +79,15 @@ public function test_should_register_metabox_with_wp() { $this->assertArrayHasKey( $option['args']['context'], $wp_meta_boxes['beans_settings'] ); $this->assertArrayHasKey( 'default', $wp_meta_boxes['beans_settings'][ $option['args']['context'] ] ); $this->assertArrayHasKey( $option['section'], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'] ); - $this->assertSame( [ - 'id' => $option['section'], - 'title' => $option['args']['title'], - 'callback' => [ $instance, 'render_metabox' ], - 'args' => null, - ], $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] ); + $this->assertSame( + [ + 'id' => $option['section'], + 'title' => $option['args']['title'], + 'callback' => [ $instance, 'render_metabox' ], + 'args' => null, + ], + $wp_meta_boxes['beans_settings'][ $option['args']['context'] ]['default'][ $option['section'] ] + ); // Clean up. remove_action( 'admin_enqueue_scripts', [ $instance, 'enqueue_assets' ] ); diff --git a/tests/phpunit/unit/api/options/includes/class-options-test-case.php b/tests/phpunit/unit/api/options/includes/class-options-test-case.php index e9302455..480ab1bf 100644 --- a/tests/phpunit/unit/api/options/includes/class-options-test-case.php +++ b/tests/phpunit/unit/api/options/includes/class-options-test-case.php @@ -41,12 +41,14 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/utilities/functions.php', - 'api/options/class-beans-options.php', - 'api/options/functions.php', - 'api/fields/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/utilities/functions.php', + 'api/options/class-beans-options.php', + 'api/options/functions.php', + 'api/fields/functions.php', + ] + ); $this->setup_function_mocks(); $this->setup_common_wp_stubs(); @@ -66,28 +68,30 @@ protected function tearDown() { * Setup dependency function mocks. */ protected function setup_function_mocks() { - Monkey\Functions\when( 'add_meta_box' )->alias( function( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { - global $wp_meta_boxes; + Monkey\Functions\when( 'add_meta_box' )->alias( + function( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { + global $wp_meta_boxes; - if ( empty( $screen ) ) { - $screen = 'beans'; - } + if ( empty( $screen ) ) { + $screen = 'beans'; + } - // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited -- Mocking global here for tests. - $wp_meta_boxes = [ - $screen => [ - $context => [ - $priority => [ - $id => [ - 'id' => $id, - 'title' => $title, - 'callback' => $callback, - 'args' => $callback_args, + // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited -- Mocking global here for tests. + $wp_meta_boxes = [ + $screen => [ + $context => [ + $priority => [ + $id => [ + 'id' => $id, + 'title' => $title, + 'callback' => $callback, + 'args' => $callback_args, + ], ], ], ], - ], - ]; - } ); + ]; + } + ); } } diff --git a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php index 7ef2c41b..8ad522d5 100644 --- a/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php +++ b/tests/phpunit/unit/api/post-meta/beans-post-meta/renderMetaboxContent.php @@ -43,9 +43,11 @@ public function test_metabox_content_should_output_fields_markup() { ->once() ->with( 'post_meta', 'tm-beans' ) ->andReturn( [ $field ] ); - Monkey\Functions\expect( 'beans_field' )->once()->with( $field )->andReturnUsing( function () { - echo 'beans_field_html'; - } ); + Monkey\Functions\expect( 'beans_field' )->once()->with( $field )->andReturnUsing( + function () { + echo 'beans_field_html'; + } + ); ob_start(); $post_meta->render_metabox_content( 74 ); diff --git a/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php b/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php index 84549a64..4ee8b043 100644 --- a/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php +++ b/tests/phpunit/unit/api/post-meta/beansRegisterPostMeta.php @@ -37,13 +37,19 @@ public function test_should_return_false_when_conditions_are_false() { Monkey\Functions\when( '_beans_pre_standardize_fields' )->returnArg(); Monkey\Functions\expect( '_beans_is_post_meta_conditions' )->once()->andReturn( false ); - $this->assertFalse( beans_register_post_meta( [ - [ - 'id' => 'field_id', - 'type' => 'radio', - 'label' => 'Field Label', - ], - ], false, 'tm-beans' ) ); + $this->assertFalse( + beans_register_post_meta( + [ + [ + 'id' => 'field_id', + 'type' => 'radio', + 'label' => 'Field Label', + ], + ], + false, + 'tm-beans' + ) + ); } /** @@ -54,13 +60,19 @@ public function test_should_return_false_when_not_is_admin() { Monkey\Functions\expect( '_beans_is_post_meta_conditions' )->once()->andReturn( true ); Monkey\Functions\expect( 'is_admin' )->once()->andReturn( false ); - $this->assertFalse( beans_register_post_meta( [ - [ - 'id' => 'field_id', - 'type' => 'radio', - 'label' => 'Field Label', - ], - ], true, 'tm-beans' ) ); + $this->assertFalse( + beans_register_post_meta( + [ + [ + 'id' => 'field_id', + 'type' => 'radio', + 'label' => 'Field Label', + ], + ], + true, + 'tm-beans' + ) + ); } /** diff --git a/tests/phpunit/unit/api/post-meta/includes/class-post-meta-test-case.php b/tests/phpunit/unit/api/post-meta/includes/class-post-meta-test-case.php index 35c64858..b2437775 100644 --- a/tests/phpunit/unit/api/post-meta/includes/class-post-meta-test-case.php +++ b/tests/phpunit/unit/api/post-meta/includes/class-post-meta-test-case.php @@ -24,13 +24,15 @@ abstract class Post_Meta_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/post-meta/class-beans-post-meta.php', - 'api/post-meta/functions.php', - 'api/post-meta/functions-admin.php', - 'api/fields/functions.php', - 'api/utilities/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/post-meta/class-beans-post-meta.php', + 'api/post-meta/functions.php', + 'api/post-meta/functions-admin.php', + 'api/fields/functions.php', + 'api/utilities/functions.php', + ] + ); $this->setup_common_wp_stubs(); } diff --git a/tests/phpunit/unit/api/template/includes/class-template-test-case.php b/tests/phpunit/unit/api/template/includes/class-template-test-case.php index c7fee182..c904fdec 100644 --- a/tests/phpunit/unit/api/template/includes/class-template-test-case.php +++ b/tests/phpunit/unit/api/template/includes/class-template-test-case.php @@ -39,10 +39,12 @@ abstract class Template_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/template/functions.php', - 'api/utilities/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/template/functions.php', + 'api/utilities/functions.php', + ] + ); $this->set_up_virtual_filesystem(); diff --git a/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php b/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php index 230e3ff0..ddd54b7c 100644 --- a/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php +++ b/tests/phpunit/unit/api/term-meta/beans-term-meta/renderFields.php @@ -51,15 +51,19 @@ public function test_should_render_fields_html() { Monkey\Functions\expect( 'beans_field_label' ) ->once() ->with( static::$test_data['sample-field'] ) - ->andReturnUsing( function () { - echo 'field-label'; - } ); + ->andReturnUsing( + function () { + echo 'field-label'; + } + ); Monkey\Functions\expect( 'beans_field' ) ->once() ->with( static::$test_data['sample-field'] ) - ->andReturnUsing( function () { - echo 'field-markup'; - } ); + ->andReturnUsing( + function () { + echo 'field-markup'; + } + ); $terms_meta = new _Beans_Term_Meta( 'tm-beans' ); diff --git a/tests/phpunit/unit/api/term-meta/includes/class-term-meta-test-case.php b/tests/phpunit/unit/api/term-meta/includes/class-term-meta-test-case.php index 1ebec1cf..4542c0ab 100644 --- a/tests/phpunit/unit/api/term-meta/includes/class-term-meta-test-case.php +++ b/tests/phpunit/unit/api/term-meta/includes/class-term-meta-test-case.php @@ -41,14 +41,16 @@ public static function setUpBeforeClass() { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/actions/functions.php', - 'api/term-meta/class-beans-term-meta.php', - 'api/term-meta/functions.php', - 'api/term-meta/functions-admin.php', - 'api/fields/functions.php', - 'api/utilities/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/actions/functions.php', + 'api/term-meta/class-beans-term-meta.php', + 'api/term-meta/functions.php', + 'api/term-meta/functions-admin.php', + 'api/fields/functions.php', + 'api/utilities/functions.php', + ] + ); $this->setup_common_wp_stubs(); Monkey\Functions\when( '_beans_pre_standardize_fields' )->returnArg(); diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php index 8d238be0..4eb3180d 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/getAutoloadComponents.php @@ -37,10 +37,13 @@ public function test_should_return_empty_arrays_when_given_components_have_no_de 'dropdown', ]; - $this->assertSame( [ - 'core' => [], - 'add-ons' => [], - ], $beans_uikit->get_autoload_components( $components ) ); + $this->assertSame( + [ + 'core' => [], + 'add-ons' => [], + ], + $beans_uikit->get_autoload_components( $components ) + ); } /** @@ -231,19 +234,29 @@ public function test_should_return_all_dependencies_for_given_components() { ], 'add-ons' => [], ]; - $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ - 'panel', - 'overlay', - ] ) ); + $this->assertSame( + $expected, + $beans_uikit->get_autoload_components( + [ + 'panel', + 'overlay', + ] + ) + ); $expected = [ 'core' => [ 'switcher' ], 'add-ons' => [ 'slidenav' ], ]; - $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ - 'tab', - 'slider', - ] ) ); + $this->assertSame( + $expected, + $beans_uikit->get_autoload_components( + [ + 'tab', + 'slider', + ] + ) + ); $expected = [ 'core' => [ @@ -256,11 +269,16 @@ public function test_should_return_all_dependencies_for_given_components() { 'slidenav', ], ]; - $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ - 'modal', - 'slideshow', - 'notify', - ] ) ); + $this->assertSame( + $expected, + $beans_uikit->get_autoload_components( + [ + 'modal', + 'slideshow', + 'notify', + ] + ) + ); $expected = [ 'core' => [ @@ -277,12 +295,17 @@ public function test_should_return_all_dependencies_for_given_components() { 'dotnav', ], ]; - $this->assertSame( $expected, $beans_uikit->get_autoload_components( [ - 'lightbox', - 'notify', - 'panel', - 'slideshow', - 'tab', - ] ) ); + $this->assertSame( + $expected, + $beans_uikit->get_autoload_components( + [ + 'lightbox', + 'notify', + 'panel', + 'slideshow', + 'tab', + ] + ) + ); } } diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php index 3835f146..a0e24f67 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerJsComponents.php @@ -44,10 +44,13 @@ public function test_should_return_empty_array_when_no_components_registered_and public function test_should_return_base_core_components_when_no_components_registered() { // Check the global. global $_beans_uikit_enqueued_items; - $this->assertSame( [ - 'core' => [], - 'add-ons' => [], - ], $_beans_uikit_enqueued_items['components'] ); + $this->assertSame( + [ + 'core' => [], + 'add-ons' => [], + ], + $_beans_uikit_enqueued_items['components'] + ); // Run the test. $this->assertSame( diff --git a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php index 1af0c7a6..3dbdb605 100644 --- a/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php +++ b/tests/phpunit/unit/api/uikit/beans-uikit/registerLessComponents.php @@ -43,10 +43,13 @@ public function test_should_return_empty_array_when_no_theme_or_components_regis public function test_should_return_variables_and_fixes_when_no_theme_or_components_registered() { // Check the global. global $_beans_uikit_enqueued_items; - $this->assertSame( [ - 'core' => [], - 'add-ons' => [], - ], $_beans_uikit_enqueued_items['components'] ); + $this->assertSame( + [ + 'core' => [], + 'add-ons' => [], + ], + $_beans_uikit_enqueued_items['components'] + ); // Run the test. $this->assertSame( diff --git a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php index f40d7aa6..523775f3 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitDequeueComponents.php @@ -36,16 +36,22 @@ public function test_should_remove_given_core_component_from_registry_when_given beans_uikit_dequeue_components( 'alert' ); $this->assertNotContains( 'alert', $_beans_uikit_enqueued_items['components']['core'] ); - $this->assertSame( [ - 1 => 'button', - 2 => 'overlay', - ], $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( + [ + 1 => 'button', + 2 => 'overlay', + ], + $_beans_uikit_enqueued_items['components']['core'] + ); beans_uikit_dequeue_components( 'button' ); $this->assertNotContains( 'button', $_beans_uikit_enqueued_items['components']['core'] ); - $this->assertSame( [ - 2 => 'overlay', - ], $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( + [ + 2 => 'overlay', + ], + $_beans_uikit_enqueued_items['components']['core'] + ); beans_uikit_dequeue_components( 'overlay' ); $this->assertNotContains( 'button', $_beans_uikit_enqueued_items['components']['core'] ); @@ -66,16 +72,22 @@ public function test_should_remove_given_addons_component_from_registry_when_giv beans_uikit_dequeue_components( 'accordion', 'add-ons' ); $this->assertNotContains( 'accordion', $_beans_uikit_enqueued_items['components']['add-ons'] ); - $this->assertSame( [ - 1 => 'datepicker', - 2 => 'sticky', - ], $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( + [ + 1 => 'datepicker', + 2 => 'sticky', + ], + $_beans_uikit_enqueued_items['components']['add-ons'] + ); beans_uikit_dequeue_components( 'datepicker', 'add-ons' ); $this->assertNotContains( 'datepicker', $_beans_uikit_enqueued_items['components']['add-ons'] ); - $this->assertSame( [ - 2 => 'sticky', - ], $_beans_uikit_enqueued_items['components']['add-ons'] ); + $this->assertSame( + [ + 2 => 'sticky', + ], + $_beans_uikit_enqueued_items['components']['add-ons'] + ); beans_uikit_dequeue_components( 'sticky', 'add-ons' ); $this->assertNotContains( 'sticky', $_beans_uikit_enqueued_items['components']['add-ons'] ); @@ -97,10 +109,13 @@ public function test_should_remove_given_core_components_from_registry_when_give beans_uikit_dequeue_components( [ 'alert' ] ); $this->assertNotContains( 'alert', $_beans_uikit_enqueued_items['components']['core'] ); - $this->assertSame( [ - 1 => 'button', - 2 => 'overlay', - ], $_beans_uikit_enqueued_items['components']['core'] ); + $this->assertSame( + [ + 1 => 'button', + 2 => 'overlay', + ], + $_beans_uikit_enqueued_items['components']['core'] + ); beans_uikit_dequeue_components( $components ); $this->assertEmpty( $_beans_uikit_enqueued_items['components']['core'] ); diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php index cfc2760e..6c6f4e73 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueComponents.php @@ -150,13 +150,17 @@ public function test_should_not_add_duplicates_into_registry() { $this->assertSame( $addons, $_beans_uikit_enqueued_items['components']['add-ons'] ); // Check when duplicates are in different order. - beans_uikit_enqueue_components( [ - 'datepicker', - 'sticky', - 'tooltip', - 'autocomplete', - 'accordion', - ], 'add-ons', false ); + beans_uikit_enqueue_components( + [ + 'datepicker', + 'sticky', + 'tooltip', + 'autocomplete', + 'accordion', + ], + 'add-ons', + false + ); $this->assertCount( 5, $_beans_uikit_enqueued_items['components']['add-ons'] ); $this->assertSame( $addons, $_beans_uikit_enqueued_items['components']['add-ons'] ); } @@ -218,12 +222,14 @@ public function test_should_add_given_core_components_and_each_dependency_into_r Monkey\Functions\expect( '_beans_uikit_autoload_dependencies' ) ->once() ->with( $components ) - ->andReturnUsing( function() { - global $_beans_uikit_enqueued_items; - $_beans_uikit_enqueued_items['components']['core'] = [ 'flex', 'switcher' ]; + ->andReturnUsing( + function() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['core'] = [ 'flex', 'switcher' ]; - return [ 'flex', 'switcher' ]; - } ); + return [ 'flex', 'switcher' ]; + } + ); beans_uikit_enqueue_components( $components, 'core', true ); $expected = array_merge( [ 'flex', 'switcher' ], $components ); @@ -240,12 +246,14 @@ public function test_should_add_given_addons_components_and_each_dependency_into Monkey\Functions\expect( '_beans_uikit_autoload_dependencies' ) ->once() ->with( $components ) - ->andReturnUsing( function() { - global $_beans_uikit_enqueued_items; - $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'dotnav' ]; - - return [ 'dotnav' ]; - } ); + ->andReturnUsing( + function() { + global $_beans_uikit_enqueued_items; + $_beans_uikit_enqueued_items['components']['add-ons'] = [ 'dotnav' ]; + + return [ 'dotnav' ]; + } + ); beans_uikit_enqueue_components( $components, 'add-ons', true ); $expected = array_merge( [ 'dotnav' ], $components ); diff --git a/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php b/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php index 94bd7dd3..2f26d02b 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php +++ b/tests/phpunit/unit/api/uikit/beansUikitEnqueueTheme.php @@ -49,11 +49,13 @@ public function test_should_enqueue_when_theme_is_already_registered() { Monkey\Functions\when( 'beans_uikit_register_theme' )->justReturn( true ); Monkey\Functions\expect( '_beans_uikit_get_registered_theme' ) ->times( 5 ) - ->andReturnUsing( function( $id ) { - global $_beans_uikit_registered_items; + ->andReturnUsing( + function( $id ) { + global $_beans_uikit_registered_items; - return $_beans_uikit_registered_items['themes'][ $id ]; - } ); + return $_beans_uikit_registered_items['themes'][ $id ]; + } + ); // Check the built-in themes. foreach ( [ 'default', 'almost-flat', 'gradient', 'wordpress-admin' ] as $theme_id ) { @@ -80,12 +82,14 @@ public function test_should_register_and_then_enqueue_theme() { Monkey\Functions\expect( 'beans_uikit_register_theme' ) ->once() ->with( 'beans-child', $path ) - ->andReturnUsing( function( $id, $path ) { - global $_beans_uikit_registered_items; - $_beans_uikit_registered_items['themes'][ $id ] = $path; + ->andReturnUsing( + function( $id, $path ) { + global $_beans_uikit_registered_items; + $_beans_uikit_registered_items['themes'][ $id ] = $path; - return true; - } ); + return true; + } + ); Monkey\Functions\expect( '_beans_uikit_get_registered_theme' ) ->once() ->with( 'beans-child' ) diff --git a/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php b/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php index d52bbcb9..5f17ec37 100644 --- a/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php +++ b/tests/phpunit/unit/api/uikit/beansUikitGetAllDependencies.php @@ -35,10 +35,13 @@ public function test_should_return_empty_arrays_when_given_components_have_no_de 'dropdown', ]; - $this->assertSame( [ - 'core' => [], - 'add-ons' => [], - ], beans_uikit_get_all_dependencies( $components ) ); + $this->assertSame( + [ + 'core' => [], + 'add-ons' => [], + ], + beans_uikit_get_all_dependencies( $components ) + ); } /** @@ -204,19 +207,29 @@ public function test_should_return_all_dependencies_for_given_components() { ], 'add-ons' => [], ]; - $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ - 'panel', - 'overlay', - ] ) ); + $this->assertSame( + $expected, + beans_uikit_get_all_dependencies( + [ + 'panel', + 'overlay', + ] + ) + ); $expected = [ 'core' => [ 'switcher' ], 'add-ons' => [ 'slidenav' ], ]; - $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ - 'tab', - 'slider', - ] ) ); + $this->assertSame( + $expected, + beans_uikit_get_all_dependencies( + [ + 'tab', + 'slider', + ] + ) + ); $expected = [ 'core' => [ @@ -229,11 +242,16 @@ public function test_should_return_all_dependencies_for_given_components() { 'slidenav', ], ]; - $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ - 'modal', - 'slideshow', - 'notify', - ] ) ); + $this->assertSame( + $expected, + beans_uikit_get_all_dependencies( + [ + 'modal', + 'slideshow', + 'notify', + ] + ) + ); $expected = [ 'core' => [ @@ -250,12 +268,17 @@ public function test_should_return_all_dependencies_for_given_components() { 'dotnav', ], ]; - $this->assertSame( $expected, beans_uikit_get_all_dependencies( [ - 'lightbox', - 'notify', - 'panel', - 'slideshow', - 'tab', - ] ) ); + $this->assertSame( + $expected, + beans_uikit_get_all_dependencies( + [ + 'lightbox', + 'notify', + 'panel', + 'slideshow', + 'tab', + ] + ) + ); } } diff --git a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php index 295c1d36..cdef8c90 100644 --- a/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php +++ b/tests/phpunit/unit/api/uikit/includes/class-uikit-test-case.php @@ -54,12 +54,14 @@ abstract class UIkit_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/utilities/functions.php', - 'api/compiler/functions.php', - 'api/uikit/functions.php', - 'api/uikit/class-beans-uikit.php', - ] ); + $this->load_original_functions( + [ + 'api/utilities/functions.php', + 'api/compiler/functions.php', + 'api/uikit/functions.php', + 'api/uikit/class-beans-uikit.php', + ] + ); $this->set_up_virtual_filesystem(); $this->set_up_mocked_functions(); @@ -108,19 +110,25 @@ protected function get_virtual_structure() { * Set up the mocked functions. */ protected function set_up_mocked_functions() { - Monkey\Functions\when( 'trailingslashit' )->alias( function( $file ) { - return $file . '/'; - } ); + Monkey\Functions\when( 'trailingslashit' )->alias( + function( $file ) { + return $file . '/'; + } + ); - Monkey\Functions\when( 'beans_join_arrays' )->alias( function( &$array1, $array2 ) { - $array1 = array_merge( $array1, $array2 ); - } ); + Monkey\Functions\when( 'beans_join_arrays' )->alias( + function( &$array1, $array2 ) { + $array1 = array_merge( $array1, $array2 ); + } + ); - Monkey\Functions\when( 'beans_get' )->alias( function( $needle, array $haystack, $default = null ) { - return isset( $haystack[ $needle ] ) + Monkey\Functions\when( 'beans_get' )->alias( + function( $needle, array $haystack, $default = null ) { + return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : $default; - } ); + } + ); } /** diff --git a/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php b/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php index a240a64e..0b93077b 100644 --- a/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php +++ b/tests/phpunit/unit/api/utilities/beansJoinArraysClean.php @@ -51,19 +51,25 @@ public function test_should_clean_array1_when_array2_is_empty() { ]; $array2 = []; $this->assertSame( [ 'foo', 5 ], beans_join_arrays_clean( $array1, $array2 ) ); - $this->assertSame( [ - 'post_type' => 'foo', - 'number_of_posts' => 5, - ], beans_join_arrays_clean( $array1, $array2, false ) ); + $this->assertSame( + [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ], + beans_join_arrays_clean( $array1, $array2, false ) + ); $array1 = [ '', 'foo', 'bar', '', 'baz' ]; $array2 = []; $this->assertSame( [ 'foo', 'bar', 'baz' ], beans_join_arrays_clean( $array1, $array2 ) ); - $this->assertSame( [ - 1 => 'foo', - 2 => 'bar', - 4 => 'baz', - ], beans_join_arrays_clean( $array1, $array2, false ) ); + $this->assertSame( + [ + 1 => 'foo', + 2 => 'bar', + 4 => 'baz', + ], + beans_join_arrays_clean( $array1, $array2, false ) + ); } /** @@ -79,20 +85,26 @@ public function test_should_clean_array2_when_array1_is_empty() { 'bar' => null, ]; $this->assertSame( [ 'foo', 5 ], beans_join_arrays_clean( $array1, $array2 ) ); - $this->assertSame( [ - 'post_type' => 'foo', - 'number_of_posts' => 5, - ], beans_join_arrays_clean( $array1, $array2, false ) ); + $this->assertSame( + [ + 'post_type' => 'foo', + 'number_of_posts' => 5, + ], + beans_join_arrays_clean( $array1, $array2, false ) + ); // Check with indexed array. $array1 = []; $array2 = [ '', 'foo', 'bar', '', 'baz' ]; $this->assertSame( [ 'foo', 'bar', 'baz' ], beans_join_arrays_clean( $array1, $array2 ) ); - $this->assertSame( [ - 1 => 'foo', - 2 => 'bar', - 4 => 'baz', - ], beans_join_arrays_clean( $array1, $array2, false ) ); + $this->assertSame( + [ + 1 => 'foo', + 2 => 'bar', + 4 => 'baz', + ], + beans_join_arrays_clean( $array1, $array2, false ) + ); } /** @@ -113,11 +125,14 @@ public function test_should_join_and_clean_the_arrays_when_both_are_not_empty() 'baz' => 'Hello', ]; $this->assertSame( [ 'bar', 'Hello', 'foo', 5 ], beans_join_arrays_clean( $array1, $array2 ) ); - $this->assertSame( [ - 'foo' => 'bar', - 'baz' => 'Hello', - 'post_type' => 'foo', - 'number_of_posts' => 5, - ], beans_join_arrays_clean( $array1, $array2, false ) ); + $this->assertSame( + [ + 'foo' => 'bar', + 'baz' => 'Hello', + 'post_type' => 'foo', + 'number_of_posts' => 5, + ], + beans_join_arrays_clean( $array1, $array2, false ) + ); } } diff --git a/tests/phpunit/unit/api/utilities/beansRemoveDir.php b/tests/phpunit/unit/api/utilities/beansRemoveDir.php index abb57a86..34cca82a 100644 --- a/tests/phpunit/unit/api/utilities/beansRemoveDir.php +++ b/tests/phpunit/unit/api/utilities/beansRemoveDir.php @@ -62,10 +62,14 @@ public function test_should_remove_dir_with_no_files() { * Test beans_remove_dir() should remove a directory with files. */ public function test_should_remove_dir_with_files() { - vfsStream::setup( 'remove-dir', 0644, [ - 'foo.txt' => 'Testing Beans for foo.txt', - 'bar.txt' => 'Testing Beans for bar.txt', - ] ); + vfsStream::setup( + 'remove-dir', + 0644, + [ + 'foo.txt' => 'Testing Beans for foo.txt', + 'bar.txt' => 'Testing Beans for bar.txt', + ] + ); $dir = vfsStream::url( 'remove-dir' ); $this->directoryExists( $dir ); @@ -81,16 +85,20 @@ public function test_should_remove_dir_with_files() { * Test beans_remove_dir() should remove a deeply nested directory. */ public function test_should_remove_deeply_nested_dir() { - vfsStream::setup( 'remove-dir', 0644, [ - 'foo.txt' => 'Testing Beans for foo.txt', - 'sub-dir' => [ - 'bar.txt' => 'Testing Beans for bar.txt', - 'sub-sub-dir' => [ - 'baz.log' => 'Baz logger', - 'foobar.log' => 'Foobar logger', + vfsStream::setup( + 'remove-dir', + 0644, + [ + 'foo.txt' => 'Testing Beans for foo.txt', + 'sub-dir' => [ + 'bar.txt' => 'Testing Beans for bar.txt', + 'sub-sub-dir' => [ + 'baz.log' => 'Baz logger', + 'foobar.log' => 'Foobar logger', + ], ], - ], - ] ); + ] + ); $dir = vfsStream::url( 'remove-dir' ); $this->directoryExists( $dir ); diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunction.php b/tests/phpunit/unit/api/utilities/beansRenderFunction.php index e0cd9b97..42bdf3cc 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunction.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunction.php @@ -41,9 +41,14 @@ public function test_should_bail_when_noncallable() { * Test beans_render_function() should work when there are no arguments. */ public function test_should_work_when_no_arguments() { - $this->assertEquals( 'You called me!', beans_render_function( function () { - echo 'You called me!'; - } ) ); + $this->assertEquals( + 'You called me!', + beans_render_function( + function () { + echo 'You called me!'; + } + ) + ); } /** diff --git a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php index cd072b00..f5baecd9 100644 --- a/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php +++ b/tests/phpunit/unit/api/utilities/beansRenderFunctionArray.php @@ -40,9 +40,14 @@ public function test_should_bail_when_noncallable() { * Test beans_render_function_array() should work when there are no arguments. */ public function test_should_work_when_no_arguments() { - $this->assertEquals( 'You called me!', beans_render_function_array( function () { - echo 'You called me!'; - } ) ); + $this->assertEquals( + 'You called me!', + beans_render_function_array( + function () { + echo 'You called me!'; + } + ) + ); } /** diff --git a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php index f7f24a1d..f6211489 100644 --- a/tests/phpunit/unit/api/utilities/beansStrEndsWith.php +++ b/tests/phpunit/unit/api/utilities/beansStrEndsWith.php @@ -91,18 +91,24 @@ public function test_should_correctly_identify_when_array_of_needles_given() { $this->assertFalse( beans_str_ends_with( 'This is a string test', [ 'tests', 'Tests', 'tests!', 'Tests' ] ) ); $this->assertTrue( beans_str_ends_with( 'Hello from Tonya', [ 'From', 'Tonya' ] ) ); $this->assertFalse( beans_str_ends_with( 'Hello from Tonya', [ 'hello', 'From' ] ) ); - $this->assertFalse( beans_str_ends_with( - 'The WordPress Community Rocks!', - [ 'wordpress', 'wordPress', 'WordPress', 'WORDPRESS' ] - ) ); - $this->assertFalse( beans_str_ends_with( - 'The WordPress Community Rocks!', - [ 'rocks!', 'community', 'WordPress', 'the' ] - ) ); - $this->assertTrue( beans_str_ends_with( - 'The WordPress Community Rocks!', - [ 'community rocks!', 'unity Rocks!' ] - ) ); + $this->assertFalse( + beans_str_ends_with( + 'The WordPress Community Rocks!', + [ 'wordpress', 'wordPress', 'WordPress', 'WORDPRESS' ] + ) + ); + $this->assertFalse( + beans_str_ends_with( + 'The WordPress Community Rocks!', + [ 'rocks!', 'community', 'WordPress', 'the' ] + ) + ); + $this->assertTrue( + beans_str_ends_with( + 'The WordPress Community Rocks!', + [ 'community rocks!', 'unity Rocks!' ] + ) + ); } /** diff --git a/tests/phpunit/unit/api/utilities/beansStrStartsWith.php b/tests/phpunit/unit/api/utilities/beansStrStartsWith.php index 154d6944..4c88b3d4 100644 --- a/tests/phpunit/unit/api/utilities/beansStrStartsWith.php +++ b/tests/phpunit/unit/api/utilities/beansStrStartsWith.php @@ -35,11 +35,16 @@ protected function setUp() { public function test_should_return_false_when_case_does_not_match() { $this->assertFalse( beans_str_starts_with( 'Foo', 'f' ) ); $this->assertFalse( beans_str_starts_with( 'Checking the Case?', 'check' ) ); - $this->assertFalse( beans_str_starts_with( 'WordPress Community Rocks!', [ - 'wordpress', - 'wordPress', - 'WORDPRESS', - ] ) ); + $this->assertFalse( + beans_str_starts_with( + 'WordPress Community Rocks!', + [ + 'wordpress', + 'wordPress', + 'WORDPRESS', + ] + ) + ); } /** @@ -48,11 +53,16 @@ public function test_should_return_false_when_case_does_not_match() { public function test_should_return_true_when_case_matches() { $this->assertTrue( beans_str_starts_with( 'Foo', 'F' ) ); $this->assertTrue( beans_str_starts_with( 'Checking the Case?', 'Checking' ) ); - $this->assertTrue( beans_str_starts_with( 'WordPress Community Rocks!', [ - 'wordpress', - 'WordPress', - 'WORDPRESS', - ] ) ); + $this->assertTrue( + beans_str_starts_with( + 'WordPress Community Rocks!', + [ + 'wordpress', + 'WordPress', + 'WORDPRESS', + ] + ) + ); } /** @@ -93,37 +103,55 @@ public function test_should_correctly_identify_when_different_data_type_given() * Test beans_str_starts_with() should correctly identify when an array of needles is given. */ public function test_should_correctly_identify_when_array_of_needles_given() { - $this->assertTrue( beans_str_starts_with( - 'This is a string test', - [ 'this', ' this', ' This', 'This' ] - ) ); + $this->assertTrue( + beans_str_starts_with( + 'This is a string test', + [ 'this', ' this', ' This', 'This' ] + ) + ); $this->assertFalse( beans_str_starts_with( 'This is a string test', [ 'These', 'are' ] ) ); - $this->assertTrue( beans_str_starts_with( '.... This is a string test', [ - '... This', - 'this', - '. This', - '.... This', - ] ) ); - $this->assertFalse( beans_str_starts_with( '... this is a string test', [ - 'this', - ' this', - '.. this', - '...this', - ] ) ); + $this->assertTrue( + beans_str_starts_with( + '.... This is a string test', + [ + '... This', + 'this', + '. This', + '.... This', + ] + ) + ); + $this->assertFalse( + beans_str_starts_with( + '... this is a string test', + [ + 'this', + ' this', + '.. this', + '...this', + ] + ) + ); $this->assertTrue( beans_str_starts_with( 'Hello from Tonya', [ 'Hello', 'Tonya' ] ) ); $this->assertFalse( beans_str_starts_with( 'Hello from Tonya', [ 'hello', 'From' ] ) ); - $this->assertTrue( beans_str_starts_with( - 'WordPress Community Rocks!', - [ 'wordpress', 'wordPress', 'WordPress', 'WORDPRESS' ] - ) ); - $this->assertFalse( beans_str_starts_with( - 'The WordPress Community Rocks!', - [ 'the', 'WordPress', 'Community', 'Rocks!' ] - ) ); - $this->assertTrue( beans_str_starts_with( - 'The WordPress Community Rocks!', - [ 'The WordPress c', 'The WordPress' ] - ) ); + $this->assertTrue( + beans_str_starts_with( + 'WordPress Community Rocks!', + [ 'wordpress', 'wordPress', 'WordPress', 'WORDPRESS' ] + ) + ); + $this->assertFalse( + beans_str_starts_with( + 'The WordPress Community Rocks!', + [ 'the', 'WordPress', 'Community', 'Rocks!' ] + ) + ); + $this->assertTrue( + beans_str_starts_with( + 'The WordPress Community Rocks!', + [ 'The WordPress c', 'The WordPress' ] + ) + ); } /** diff --git a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php index b93dd4da..7055474a 100644 --- a/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php +++ b/tests/phpunit/unit/api/widget/beansRegisterWidgetArea.php @@ -61,10 +61,12 @@ public function test_should_return_widget_area_ID_when_widget_area_registered() $this->assertEquals( 'new-widget-area', - beans_register_widget_area( [ - 'id' => 'new-widget-area', - 'beans_type' => 'grid', - ] ) + beans_register_widget_area( + [ + 'id' => 'new-widget-area', + 'beans_type' => 'grid', + ] + ) ); } diff --git a/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php b/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php index f144f463..5ab103cf 100644 --- a/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php +++ b/tests/phpunit/unit/api/widget/includes/class-beans-widget-test-case.php @@ -24,10 +24,12 @@ abstract class Beans_Widget_Test_Case extends Test_Case { protected function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/widget/functions.php', - 'api/utilities/functions.php', - ] ); + $this->load_original_functions( + [ + 'api/widget/functions.php', + 'api/utilities/functions.php', + ] + ); $this->setup_common_wp_stubs(); } diff --git a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php index 60f1d896..6dc85251 100644 --- a/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php +++ b/tests/phpunit/unit/api/wp-customize/includes/class-wp-customize-test-case.php @@ -49,11 +49,13 @@ public static function setUpBeforeClass() { public function setUp() { parent::setUp(); - $this->load_original_functions( [ - 'api/wp-customize/functions.php', - 'api/wp-customize/class-beans-wp-customize.php', - 'api/wp-customize/class-beans-wp-customize-control.php', - ] ); + $this->load_original_functions( + [ + 'api/wp-customize/functions.php', + 'api/wp-customize/class-beans-wp-customize.php', + 'api/wp-customize/class-beans-wp-customize-control.php', + ] + ); $this->setup_common_wp_stubs(); @@ -73,16 +75,19 @@ public function setUp() { * @return array */ protected function merge_field_with_default( array $field, $set_value = true ) { - $merged_field = array_merge( [ - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => 'wp_customize', - 'attributes' => [ - 'data-customize-setting-link' => $field['id'], + $merged_field = array_merge( + [ + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => 'wp_customize', + 'attributes' => [ + 'data-customize-setting-link' => $field['id'], + ], + 'db_group' => false, ], - 'db_group' => false, - ], $field ); + $field + ); $merged_field['name'] = $field['id']; if ( $set_value ) { diff --git a/tests/phpunit/unit/class-test-case.php b/tests/phpunit/unit/class-test-case.php index 10104943..c1c1d39c 100644 --- a/tests/phpunit/unit/class-test-case.php +++ b/tests/phpunit/unit/class-test-case.php @@ -38,25 +38,29 @@ protected function setUp() { parent::setUp(); Monkey\setUp(); - Functions\when( 'wp_normalize_path' )->alias( function( $path ) { + Functions\when( 'wp_normalize_path' )->alias( + function( $path ) { - if ( true === $this->just_return_path ) { - return $path; - } + if ( true === $this->just_return_path ) { + return $path; + } - $path = str_replace( '\\', '/', $path ); - $path = preg_replace( '|(?<=.)/+|', '/', $path ); + $path = str_replace( '\\', '/', $path ); + $path = preg_replace( '|(?<=.)/+|', '/', $path ); - if ( ':' === substr( $path, 1, 1 ) ) { - $path = ucfirst( $path ); - } + if ( ':' === substr( $path, 1, 1 ) ) { + $path = ucfirst( $path ); + } - return $path; - } ); + return $path; + } + ); - Functions\when( 'wp_json_encode' )->alias( function( $array ) { - return json_encode( $array ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Required as part of our mock. - } ); + Functions\when( 'wp_json_encode' )->alias( + function( $array ) { + return json_encode( $array ); // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Required as part of our mock. + } + ); } /** @@ -64,21 +68,25 @@ protected function setUp() { */ protected function setup_common_wp_stubs() { // Common escaping functions. - Monkey\Functions\stubs( [ - 'esc_attr', - 'esc_html', - 'esc_textarea', - 'esc_url', - 'wp_kses_post', - ] ); + Monkey\Functions\stubs( + [ + 'esc_attr', + 'esc_html', + 'esc_textarea', + 'esc_url', + 'wp_kses_post', + ] + ); // Common internationalization functions. - Monkey\Functions\stubs( [ - '__', - 'esc_html__', - 'esc_html_x', - 'esc_attr_x', - ] ); + Monkey\Functions\stubs( + [ + '__', + 'esc_html__', + 'esc_html_x', + 'esc_attr_x', + ] + ); foreach ( [ 'esc_attr_e', 'esc_html_e', '_e' ] as $wp_function ) { Monkey\Functions\when( $wp_function )->echoArg();