Skip to content

Commit

Permalink
format file and mark some tests as incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Jun 2, 2024
1 parent 37a7991 commit defab0a
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions tests/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
final class ProductTest extends TestCase
{
use Database;

private ?Product $dummy_product;
private ?Client $dummy_client;
private ?Review $dummy_review;

/**
* @throws Exception
*/
public function setUp(): void
{
$address = new Location("Royal Road", "Curepipe", 1);
Expand Down Expand Up @@ -85,8 +89,14 @@ public function testConstructor(): void
self::assertEquals("Velvet Bean Image", $this->dummy_product->getImgAltText());
self::assertEquals("Velvet", $this->dummy_product->getCategory());
self::assertEquals(6.50, $this->dummy_product->getPrice());
self::assertEquals("Each bottle contains 90% Pure Coffee powder and 10% Velvet bean Powder", $this->dummy_product->getDescription());
self::assertInstanceOf(DateTime::class, $this->dummy_product->getCreatedDate()); // Check if created_date is an instance of DateTime
self::assertEquals(
"Each bottle contains 90% Pure Coffee powder and 10% Velvet bean Powder",
$this->dummy_product->getDescription()
);
self::assertInstanceOf(
DateTime::class,
$this->dummy_product->getCreatedDate()
); // Check if created_date is an instance of DateTime
}

public function testToArray(): void
Expand All @@ -111,8 +121,14 @@ public function testToArray(): void
self::assertEquals("Velvet Bean Image", $result['img_alt_text']);
self::assertEquals("Velvet", $result['category']);
self::assertEquals(6.50, $result['price']);
self::assertEquals("Each bottle contains 90% Pure Coffee powder and 10% Velvet bean Powder", $result['description']);
self::assertInstanceOf(DateTime::class, $result['created_date']); // Check if created_date is an instance of DateTime
self::assertEquals(
"Each bottle contains 90% Pure Coffee powder and 10% Velvet bean Powder",
$result['description']
);
self::assertInstanceOf(
DateTime::class,
$result['created_date']
); // Check if created_date is an instance of DateTime
}

public function testSave(): void
Expand All @@ -132,6 +148,10 @@ public function testValidate(): void

// Check if there are no validation errors
$this->assertEmpty($errors);

$this->markTestIncomplete(
'This test lacks test cases, ...',
);
}

public function testGetRatingDistribution(): void
Expand All @@ -141,6 +161,10 @@ public function testGetRatingDistribution(): void
// Check if the distribution contains the expected keys and values
$this->assertArrayHasKey(5, $distribution);
$this->assertEquals(100.0, $distribution[5]); // 1 out of 1 reviews is 5 stars

$this->markTestIncomplete(
'This test lacks test cases, ...',
);
}

public function testDeleteProduct(): void
Expand All @@ -154,6 +178,10 @@ public function testDeleteProduct(): void
// Check if the product no longer exists in the database
$product = Product::getByID($product_id);
$this->assertNull($product);

$this->markTestIncomplete(
'This test lacks test cases, ...',
);
}

public function testUpdateProduct(): void
Expand Down Expand Up @@ -189,6 +217,10 @@ public function testGetAverageRating(): void
$averageRating = $this->dummy_product->getAverageRating();

$this->assertNotEquals(999.0, $averageRating);

$this->markTestIncomplete(
'This test lacks test cases, ...',
);
}

public function testGetReviews(): void
Expand Down

0 comments on commit defab0a

Please sign in to comment.