From 13d7d635789b028020b3b5ffc4e826f45d433f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Werner=20Krau=C3=9F?= Date: Tue, 20 Feb 2024 13:07:43 +0100 Subject: [PATCH] Add UnitTest for ProductCategory's canArchive method see #817 --- tests/php/Fixtures/shop.yml | 4 ++++ tests/php/Page/ProductCategoryTest.php | 10 ++++++++++ 2 files changed, 14 insertions(+) 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(); + } }