Skip to content

Commit

Permalink
Add example of casting to string
Browse files Browse the repository at this point in the history
  • Loading branch information
jmortlock committed Feb 12, 2025
1 parent 8cea442 commit 48bd5e2
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Flow\ETL\Tests\Integration\Function;

use function Flow\ETL\DSL\{df, from_rows, ref, row, rows, xml_element_entry, xml_entry};
use function Flow\ETL\DSL\{df, from_rows, ref, row, rows, xml_element_entry, xml_entry, type_string};

use DOMDocument;
use Flow\ETL\Tests\FlowTestCase;
Expand Down Expand Up @@ -80,6 +80,31 @@ public function test_dom_element_value_on_dom_document() : void
);
}

public function test_dom_element_cast_as_string() : void
{
$document = new DOMDocument();
$document->loadHTML('<b>User Name 01</b>');

$rows = df()
->read(from_rows(
rows(
row(
xml_entry('html_raw', $document)
)
)
))
->withEntry('html', ref('html_raw')->cast(type_string()))
->drop('html_raw')
->fetch();

self::assertSame(
[
['html' => '<b>User Name 01</b>'],
],
$rows->toArray()
);
}

public function test_dom_element_value_on_xpath_result() : void
{
$rows = df()
Expand Down

0 comments on commit 48bd5e2

Please sign in to comment.