Skip to content

Commit cf1e56b

Browse files
committed
Merge tests for invalid input
1 parent 4c59153 commit cf1e56b

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

projects/packages/block-delimiter/tests/php/Block_Delimiter_Test.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,36 +108,28 @@ public static function provideValidBlockDelimiters(): array {
108108
* @dataProvider provideInvalidBlockDelimiters
109109
*/
110110
#[DataProvider( 'provideInvalidBlockDelimiters' )]
111-
public function test_next_delimiter_with_invalid_input( string $input, int $start_offset ): void {
111+
public function test_next_delimiter_with_invalid_input( string $input, int $start_offset, ?string $expected_error ): void {
112112
$delimiter = Block_Delimiter::next_delimiter( $input, $start_offset );
113113

114114
$this->assertNull( $delimiter );
115+
$this->assertEquals( $expected_error, Block_Delimiter::get_last_error() );
115116
}
116117

117118
/**
118119
* Data provider for invalid block delimiters.
119120
*/
120121
public static function provideInvalidBlockDelimiters(): array {
121122
return array(
122-
'no block delimiter' => array( 'Just some regular text', 0 ),
123-
'regular HTML comment' => array( '<!-- This is a regular comment -->', 0 ),
124-
'incomplete wp prefix' => array( '<!-- w:paragraph -->', 0 ),
125-
'no whitespace after comment start' => array( '<!--wp:paragraph -->', 0 ),
126-
'invalid block name' => array( '<!-- wp:123invalid -->', 0 ),
127-
'empty input' => array( '', 0 ),
123+
'no block delimiter' => array( 'Just some regular text', 0, null ),
124+
'regular HTML comment' => array( '<!-- This is a regular comment -->', 0, null ),
125+
'incomplete wp prefix' => array( '<!-- w:paragraph -->', 0, null ),
126+
'no whitespace after comment start' => array( '<!--wp:paragraph -->', 0, null ),
127+
'invalid block name' => array( '<!-- wp:123invalid -->', 0, null ),
128+
'empty input' => array( '', 0, null ),
129+
'incomplete input' => array( '<!-- wp:paragraph', 0, Block_Delimiter::INCOMPLETE_INPUT ),
128130
);
129131
}
130132

131-
/**
132-
* Test next_delimiter with incomplete input.
133-
*/
134-
public function test_next_delimiter_with_incomplete_input(): void {
135-
$delimiter = Block_Delimiter::next_delimiter( '<!-- wp:paragraph', 0 );
136-
137-
$this->assertNull( $delimiter );
138-
$this->assertEquals( Block_Delimiter::INCOMPLETE_INPUT, Block_Delimiter::get_last_error() );
139-
}
140-
141133
/**
142134
* Test scanning multiple delimiters.
143135
*/

0 commit comments

Comments
 (0)