Skip to content

Commit

Permalink
(WIP) NEW test for register_block_variations() method
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion committed Oct 1, 2024
1 parent e5b8ea2 commit 52ef721
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/unit/php/includes/core/classes/class-test-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'

Check warning on line 98 in test/unit/php/includes/core/classes/class-test-block.php

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"singelton" should be "singleton".
);

// 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.'

Check warning on line 106 in test/unit/php/includes/core/classes/class-test-block.php

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"singelton" should be "singleton".
);
}

/**
* Coverage for get_block_variations.
*
Expand All @@ -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.'
);
}


}

0 comments on commit 52ef721

Please sign in to comment.