| 1 |
<?php |
| 2 |
/** |
| 3 |
* Tests for Cookiebot_Abilities_Registrar. |
| 4 |
* |
| 5 |
* @package cookiebot |
| 6 |
* @subpackage tests |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace cybot\cookiebot\tests\integration\abilities; |
| 10 |
|
| 11 |
use cybot\cookiebot\abilities\Cookiebot_Abilities_Registrar; |
| 12 |
use WP_UnitTestCase; |
| 13 |
|
| 14 |
/** |
| 15 |
* Test class for Cookiebot_Abilities_Registrar. |
| 16 |
* |
| 17 |
* @since 4.8.0 |
| 18 |
*/ |
| 19 |
class Test_Cookiebot_Abilities_Registrar extends WP_UnitTestCase { |
| 20 |
|
| 21 |
/** |
| 22 |
* Test that register_hooks adds both actions. |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public function test_register_hooks_adds_both_actions() { |
| 27 |
$registrar = new Cookiebot_Abilities_Registrar(); |
| 28 |
$registrar->register_hooks(); |
| 29 |
$this->assertNotFalse( has_action( 'wp_abilities_api_categories_init', array( $registrar, 'register_category' ) ) ); |
| 30 |
$this->assertNotFalse( has_action( 'wp_abilities_api_init', array( $registrar, 'register' ) ) ); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Test that all six abilities are registered after hooks fire. |
| 35 |
* |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
public function test_all_six_abilities_are_registered_after_hooks_fire() { |
| 39 |
$expected = array( |
| 40 |
'cookiebot/get-status', |
| 41 |
'cookiebot/verify-setup', |
| 42 |
'cookiebot/get-compliance-summary', |
| 43 |
'cookiebot/set-cbid', |
| 44 |
'cookiebot/toggle-gcm', |
| 45 |
'cookiebot/install-ppg', |
| 46 |
); |
| 47 |
foreach ( $expected as $name ) { |
| 48 |
$this->assertTrue( wp_has_ability( $name ), "Expected ability '{$name}' to be registered." ); |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|