Skip to content

Commit f9bf415

Browse files
committed
Add a new HTMLElementEntry & related stuff
1 parent 35cf84f commit f9bf415

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/core/etl/tests/Flow/ETL/Tests/Unit/Row/Entry/HTMLEntryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ public function test_with_value() : void
159159
{
160160
$entry = html_entry('html', '<!DOCTYPE html><html lang="en"><head></head><body><div>foobar</div></body></html>');
161161

162-
$html = '<!DOCTYPE html><html lang="en"><head></head><body><div>different</div></body></html>';
162+
$html = HTMLDocument::createFromString('<!DOCTYPE html><html lang="en"><head></head><body><div>different</div></body></html>');
163163

164164
$newEntry = $entry->withValue($html);
165165

166166
self::assertNotEquals($entry->toString(), $newEntry->toString());
167-
self::assertEquals($html, $newEntry->toString());
167+
self::assertEquals($html, $newEntry->value());
168168
}
169169
}

src/core/etl/tests/Flow/ETL/Tests/Unit/Row/EntryFactoryTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,13 @@ public function test_html_from_string() : void
274274
#[RequiresPhp('>= 8.4')]
275275
public function test_html_string_with_html_definition_provided() : void
276276
{
277+
$document = HTMLDocument::createFromString(
278+
$html = '<!DOCTYPE html><html lang="en"><head></head><body><div>2</div><p>bar</p></body></html>'
279+
);
280+
277281
self::assertEquals(
278-
html_entry('e', $html = '<!DOCTYPE html><html lang="en"><head></head><body><div>2</div><p>bar</p></body></html>'),
279-
$this->entryFactory->create('e', $html, schema(html_schema('e')))
282+
html_entry('e', $html),
283+
$this->entryFactory->create('e', $document, schema(html_schema('e')))
280284
);
281285
}
282286

src/lib/types/tests/Flow/Types/Tests/Unit/Type/Logical/HTMLTypeTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ public static function cast_data_provider() : \Generator
8080
];
8181

8282
yield 'valid HTML string' => [
83-
'value' => $html = '<!DOCTYPE html><html lang="en"><head></head><body><div><span>1</span></div></body></html>',
84-
'expected' => $html,
85-
'exceptionClass' => null,
83+
'value' => '<!DOCTYPE html><html lang="en"><head></head><body><div><span>1</span></div></body></html>',
84+
'expected' => null,
85+
'exceptionClass' => CastingException::class,
8686
];
8787

8888
yield 'valid HTML with spaces' => [
8989
'value' => '<!DOCTYPE html><html> <head><title></title></head> <body><p>invalid</p> </body> </html>',
90-
'expected' => '<!DOCTYPE html><html> <head><title></title></head> <body><p>invalid</p> </body> </html>',
91-
'exceptionClass' => null,
90+
'expected' => null,
91+
'exceptionClass' => CastingException::class,
9292
];
9393

9494
yield 'valid HTML with new lines' => [
@@ -101,8 +101,8 @@ public static function cast_data_provider() : \Generator
101101
</body>
102102
</html>
103103
HTML,
104-
'expected' => '<!DOCTYPE html><html> <head><title></title></head> <body> <p> invalid</p> </body></html>',
105-
'exceptionClass' => null,
104+
'expected' => null,
105+
'exceptionClass' => CastingException::class,
106106
];
107107

108108
yield 'missing doctype' => [
@@ -134,7 +134,7 @@ public static function is_valid_data_provider() : \Generator
134134

135135
yield 'valid HTML string' => [
136136
'value' => '<!DOCTYPE html><html lang="en"><head></head><body><div><span>1</span></div></body></html>',
137-
'expected' => true,
137+
'expected' => false,
138138
];
139139

140140
yield 'invalid HTML string' => [

0 commit comments

Comments
 (0)