From 52ef72149f0c07aea1a1444303947864c0ae0f68 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Tue, 1 Oct 2024 11:47:33 +0200 Subject: [PATCH] (WIP) NEW test for register_block_variations() method --- .../core/classes/class-test-block.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/unit/php/includes/core/classes/class-test-block.php b/test/unit/php/includes/core/classes/class-test-block.php index 2892c51f0..83cc07e5d 100644 --- a/test/unit/php/includes/core/classes/class-test-block.php +++ b/test/unit/php/includes/core/classes/class-test-block.php @@ -85,6 +85,28 @@ public function test_register_blocks(): void { $this->assertSame( $blocks, $expected ); } + /** + * Coverage for register_block_variations. + * + * @covers ::register_block_variations + * + * @return void + */ + public function test_register_block_variations(): void { + $this->assertFalse( + class_exists( 'GatherPress\Core\Block\Add_To_Calendar' ), + 'Failed to assert Add_To_Calendar singelton does not yet exist.' + ); + + // Register our block variations. + $instance->register_block_variations(); + + $this->assertTrue( + class_exists( 'GatherPress\Core\Block\Add_To_Calendar' ), + 'Failed to assert Add_To_Calendar singelton does exist.' + ); + } + /** * Coverage for get_block_variations. * @@ -103,4 +125,22 @@ public function test_get_block_variations(): void { 'Failed to assert, to get all block variations from the "/src" directory.' ); } + + /** + * Coverage for get_classname_from_foldername. + * + * @covers ::get_classname_from_foldername + * + * @return void + */ + public function test_get_classname_from_foldername(): void { + $instance = Block::get_instance(); + $this->assertSame( + '', + Utility::invoke_hidden_method( $instance, 'get_classname_from_foldername', array( __DIR__ ) ), + 'Failed to assert, to get class name from foldername.' + ); + } + + }