Skip to content

Commit

Permalink
Add UnitTest for ProductCategory's canArchive method
Browse files Browse the repository at this point in the history
see #817
  • Loading branch information
wernerkrauss committed Feb 20, 2024
1 parent 8c2d512 commit 13d7d63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/php/Fixtures/shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ SilverShop\Page\ProductCategory:
Parent: =>SilverShop\Page\ProductCategory.electronics
clearance:
Title: Clearance
empty:
Title: Empty
URLSegment: empty
Parent: =>SilverShop\Page\ProductCategory.products

SilverShop\Page\Product:
socks:
Expand Down
10 changes: 10 additions & 0 deletions tests/php/Page/ProductCategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function setUp(): void
$this->clothing->publishSingle();
$this->electronics = $this->objFromFixture(ProductCategory::class, 'electronics');
$this->electronics->publishSingle();
$this->empty = $this->objFromFixture(ProductCategory::class, 'empty');
$this->empty->publishSingle();

$this->socks = $this->objFromFixture(Product::class, 'socks');
$this->socks->publishSingle();
Expand Down Expand Up @@ -196,4 +198,12 @@ public function testFiltering()
//check published/ non published / allow purchase etc
//Hide product if no price...or if product has variations, allow viewing.
}

public function testCanArchive()
{
$this->logInWithPermission('ADMIN');
$this->assertFalse($this->electronics->canArchive(), 'A productcategory with products cannot be archived');
$this->assertTrue($this->empty->canArchive(), 'A productcategory without products can be archived');
$this->logOut();
}
}

0 comments on commit 13d7d63

Please sign in to comment.