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 077c489 commit 5bd2190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 5 additions & 3 deletions tests/framework/helpers/class-wc-gzd-helper-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function create_allergen() {
return $term;
}

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

if ( ! is_a( $attachment, 'WP_Post' ) ) {
Expand All @@ -81,7 +81,7 @@ public static function create_attachment( $name = 'woocommerce-placeholder', $fi
copy( $source, $filename ); // @codingStandardsIgnoreLine.
}

$filetype = empty( $file_type ) ? wp_check_filetype( basename( $filename ), null ) : $file_type;
$filetype = wp_check_filetype( basename( $filename ), null );
$attachment = array(
'guid' => $upload_dir['url'] . '/' . basename( $filename ),
'post_mime_type' => $filetype,
Expand All @@ -106,7 +106,7 @@ public static function create_simple_product() {
$allergen = self::create_allergen();
$nutrient = self::create_nutrient();
$manufacturer = self::create_manufacturer();
// $attachment = self::create_attachment();
$attachment = self::create_attachment();

$product = WC_Helper_Product::create_simple_product();

Expand Down Expand Up @@ -140,6 +140,8 @@ public static function create_simple_product() {
),
'_is_food' => 'yes',
'_manufacturer_slug' => $manufacturer->slug,
'_product_safety_attachments' => array( $attachment ),
'_product_warranty_pdf' => $attachment,
'_deposit_type' => $deposit_type->slug,
'_deposit_quantity' => 5,
'_ingredients' => '<strong>Hazelnut</strong>, Fish',
Expand Down
5 changes: 1 addition & 4 deletions tests/unit-tests/api/products.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ public function test_get_product() {
$this->assertEquals( true, $product['free_shipping'] );
$this->assertEquals( true, $product['is_food'] );

// $this->assertEquals( true, ! empty( $product['safety_attachment_ids'] ) );
// $this->assertEquals( true, ! empty( $product['warranty_attachment_id'] ) );

$nutrient = get_term_by( 'slug', 'energy', 'product_nutrient' );
$allergen = get_term_by( 'slug', 'hazelnut', 'product_allergen' );

Expand Down Expand Up @@ -101,7 +98,7 @@ public function test_create_product() {
$nutrient = wp_insert_term( 'Salt', 'product_nutrient', array( 'slug' => 'salt' ) );
$nutrient_2 = wp_insert_term( 'Natrium', 'product_nutrient', array( 'slug' => 'natrium' ) );
$allergen = wp_insert_term( 'Nut', 'product_allergen', array( 'slug' => 'nut' ) );
// $attachment_id = WC_GZD_Helper_Product::create_attachment( 'test' );
$attachment_id = WC_GZD_Helper_Product::create_attachment( 'test' );

// Create simple.
$request = new WP_REST_Request( 'POST', '/wc/v3/products' );
Expand Down

0 comments on commit 5bd2190

Please sign in to comment.