Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Sep 23, 2024
1 parent 90ad662 commit f4ecafc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/framework/helpers/class-wc-gzd-helper-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public static function create_allergen() {
return $term;
}

public static function create_attachment( $name = 'woocommerce-placeholder' ) {
$attachment = get_page_by_path( $name, 'OBJECT', 'attachment' );
public static function create_attachment() {
$attachment = get_page_by_path( 'woocommerce-placeholder', 'OBJECT', 'attachment' );

if ( ! is_a( $attachment, 'WP_Post' ) ) {
$upload_dir = wp_upload_dir();
Expand All @@ -84,9 +84,8 @@ public static function create_attachment( $name = 'woocommerce-placeholder' ) {
$filetype = wp_check_filetype( basename( $filename ), null );
$attachment = array(
'guid' => $upload_dir['url'] . '/' . basename( $filename ),
'post_mime_type' => $filetype,
'post_mime_type' => $filetype['type'],
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
'post_name' => $name,
'post_content' => '',
'post_status' => 'inherit',
);
Expand Down Expand Up @@ -159,6 +158,9 @@ public static function create_simple_product() {
'ref_value' => 22.1,
),
),
'_safety_attachment_ids' => array(
$attachment
),
'_allergen_ids' => array(
$allergen->term_id,
),
Expand Down

0 comments on commit f4ecafc

Please sign in to comment.