1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
||
18 | class Test_Blocks extends TestCase { |
||
19 | /** |
||
20 | * Test block name. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public $block_name = 'jetpack/apple'; |
||
25 | |||
26 | /** |
||
27 | * Setup runs before each test. |
||
28 | */ |
||
29 | public function setUp() { |
||
35 | |||
36 | /** |
||
37 | * Teardown runs after each test. |
||
38 | */ |
||
39 | public function tearDown() { |
||
45 | |||
46 | /** |
||
47 | * Test the different inputs and matching output for Classes. |
||
48 | * |
||
49 | * @since 9.0.0 |
||
50 | * |
||
51 | * @covers Automattic\Jetpack\Blocks::classes |
||
52 | */ |
||
53 | public function test_block_classes() { |
||
73 | |||
74 | /** |
||
75 | * Test for invalid alignment values. |
||
76 | * |
||
77 | * @since 9.0.0 |
||
78 | * |
||
79 | * @covers Automattic\Jetpack\Blocks::classes |
||
80 | */ |
||
81 | public function test_block_classes_invalid_align() { |
||
87 | |||
88 | /** |
||
89 | * Test whether we can detect an AMP view. |
||
90 | * |
||
91 | * @since 9.0.0 |
||
92 | * |
||
93 | * @covers Automattic\Jetpack\Blocks::is_amp_request |
||
94 | */ |
||
95 | public function test_is_amp_request() { |
||
103 | |||
104 | /** |
||
105 | * Test whether we can detect an AMP view. |
||
106 | * |
||
107 | * @since 9.0.0 |
||
108 | * |
||
109 | * @covers Automattic\Jetpack\Blocks::is_amp_request |
||
110 | */ |
||
111 | public function test_is_not_amp_request() { |
||
114 | |||
115 | /** |
||
116 | * Test WordPress and Gutenberg version requirements. |
||
117 | * |
||
118 | * @covers Automattic\Jetpack\Blocks::is_gutenberg_version_available |
||
119 | */ |
||
120 | public function test_returns_false_if_core_wp_version_less_than_minimum() { |
||
121 | $version_gated = Blocks::is_gutenberg_version_available( |
||
122 | array( |
||
123 | 'wp' => '999999', |
||
124 | 'gutenberg' => '999999', |
||
125 | ), |
||
126 | 'gated_block' |
||
127 | ); |
||
128 | $this->assertFalse( false, $version_gated ); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Test WordPress and Gutenberg version requirements. |
||
133 | * |
||
134 | * @covers Automattic\Jetpack\Blocks::is_gutenberg_version_available |
||
135 | */ |
||
136 | public function test_returns_true_if_core_wp_version_greater_or_equal_to_minimum() { |
||
137 | $version_gated = Blocks::is_gutenberg_version_available( |
||
138 | array( |
||
139 | 'wp' => '1', |
||
140 | 'gutenberg' => '999999', |
||
141 | ), |
||
142 | 'ungated_block' |
||
143 | ); |
||
144 | $this->assertTrue( true, $version_gated ); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Testing removing the Jetpack prefix from a block slug. |
||
149 | * |
||
150 | * @covers Automattic\Jetpack\Blocks::remove_extension_prefix |
||
151 | * |
||
152 | * @dataProvider get_extension_name_provider |
||
153 | * |
||
154 | * @param string $extension_slug Block / Extension name. |
||
155 | * @param string $expected_short_slug Extension name without Jetpack prefix. |
||
156 | */ |
||
157 | public function test_remove_extension_prefix( $extension_slug, $expected_short_slug ) { |
||
162 | |||
163 | /** |
||
164 | * Get different possible block names. |
||
165 | * |
||
166 | * Data provider for test_remove_extension_prefix. |
||
167 | */ |
||
168 | public function get_extension_name_provider() { |
||
184 | |||
185 | /** |
||
186 | * Test to ensure that an extension is returned as registered. |
||
187 | * |
||
188 | * @covers Automattic\Jetpack\Blocks::is_registered |
||
189 | */ |
||
190 | public function test_is_extension_registered() { |
||
196 | |||
197 | /** |
||
198 | * Ensure blocks cannot be registered twice. |
||
199 | * |
||
200 | * @covers Automattic\Jetpack\Blocks::jetpack_register_block |
||
201 | */ |
||
202 | public function test_jetpack_register_block_twice() { |
||
206 | |||
207 | /** |
||
208 | * Test to ensure blocks without a Jetpack prefix are registered, but with a jetpack prefix. |
||
209 | * |
||
210 | * @expectedIncorrectUsage Automattic\Jetpack\Blocks::jetpack_register_block |
||
211 | * @covers Automattic\Jetpack\Blocks::jetpack_register_block |
||
212 | */ |
||
213 | public function test_jetpack_register_block_without_jetpack() { |
||
217 | } |
||
218 |