diff --git a/tests/php/Fixtures/shop.yml b/tests/php/Fixtures/shop.yml index 1fb1cc97..72b0a6f8 100644 --- a/tests/php/Fixtures/shop.yml +++ b/tests/php/Fixtures/shop.yml @@ -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: diff --git a/tests/php/Page/ProductCategoryTest.php b/tests/php/Page/ProductCategoryTest.php index 35eb013a..6ece2f8f 100644 --- a/tests/php/Page/ProductCategoryTest.php +++ b/tests/php/Page/ProductCategoryTest.php @@ -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(); @@ -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(); + } }