forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpBlockStylesRegistry.php
More file actions
101 lines (91 loc) · 2.34 KB
/
wpBlockStylesRegistry.php
File metadata and controls
101 lines (91 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Tests for WP_Block_Styles_Registry.
*
* @package WordPress
* @subpackage Blocks
* @since 6.6.0
*
* @group blocks
*/
class Tests_Blocks_wpBlockStylesRegistry extends WP_UnitTestCase {
/**
* Fake block styles registry.
*
* @since 6.6.0
* @var WP_Block_Styles_Registry
*/
private $registry = null;
/**
* Set up each test method.
*
* @since 6.6.0
*/
public function set_up() {
parent::set_up();
$this->registry = new WP_Block_Styles_Registry();
}
/**
* Tear down each test method.
*
* @since 6.6.0
*/
public function tear_down() {
$this->registry = null;
parent::tear_down();
}
/**
* Should accept valid string block type name.
*
* @ticket 61274
*/
public function test_register_block_style_with_string_block_name() {
$name = 'core/paragraph';
$style_properties = array( 'name' => 'fancy' );
$result = $this->registry->register( $name, $style_properties );
$this->assertTrue( $result );
$this->assertTrue( $this->registry->is_registered( 'core/paragraph', 'fancy' ) );
}
/**
* Should accept valid array of block type names.
*
* @ticket 61274
*/
public function test_register_block_style_with_array_of_block_names() {
$names = array( 'core/paragraph', 'core/group' );
$style_properties = array( 'name' => 'plain' );
$result = $this->registry->register( $names, $style_properties );
$this->assertTrue( $result );
$this->assertTrue( $this->registry->is_registered( 'core/paragraph', 'plain' ) );
$this->assertTrue( $this->registry->is_registered( 'core/group', 'plain' ) );
}
/**
* @ticket 63957
*/
public function test_is_registered_returns_false_for_null_block_name() {
$style_name = 'fancy-style';
$this->assertFalse(
$this->registry->is_registered( null, $style_name ),
'Empty block name should return false.'
);
}
/**
* @ticket 63957
*/
public function test_is_registered_returns_false_for_null_style_name() {
$block_name = 'core/paragraph';
$this->assertFalse(
$this->registry->is_registered( $block_name, null ),
'Empty style name should return false.'
);
}
/**
* @ticket 63957
*/
public function test_is_registered_returns_false_for_both_null_params() {
$this->assertFalse(
$this->registry->is_registered( null, null ),
'Both empty block and style name should return false.'
);
}
}