diff --git a/src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalLoaderTest.php b/src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalLoaderTest.php
index 5ecac7f2c..2d16e33f5 100644
--- a/src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalLoaderTest.php
+++ b/src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalLoaderTest.php
@@ -261,6 +261,51 @@ public function test_inserts_new_rows_or_updates_already_existed_based_on_primar
);
}
+ public function test_inserts_xml_entry() : void
+ {
+ $this->pgsqlDatabaseContext->createTable((new Table(
+ $table = 'flow_doctrine_bulk_test',
+ [
+ new Column('id', Type::getType(Types::INTEGER), ['notnull' => true]),
+ new Column('name', Type::getType(Types::STRING), ['notnull' => true, 'length' => 255]),
+ new Column('description', Type::getType(Types::STRING), ['notnull' => true, 'length' => 255]),
+ ],
+ ))
+ ->setPrimaryKey(['id']));
+
+ $loader = to_dbal_table_insert($this->connectionParams(), $table);
+
+ $documentA = new \DOMDocument();
+ $documentA->loadXml('Description One');
+
+ $documentB = new \DOMDocument();
+ $documentB->loadXml('Description Two');
+
+ $documentC = new \DOMDocument();
+ $documentC->loadXml('Description Three');
+
+ (data_frame())
+ ->read(
+ from_array([
+ ['id' => 1, 'name' => 'Name One', 'description' => $documentA],
+ ['id' => 2, 'name' => 'Name Two', 'description' => $documentB],
+ ['id' => 3, 'name' => 'Name Three', 'description' => $documentC],
+ ]),
+ )
+ ->load($loader)
+ ->run();
+
+ self::assertEquals(3, $this->pgsqlDatabaseContext->tableCount($table));
+ self::assertEquals(
+ [
+ ['id' => 1, 'name' => 'Name One', 'description' => 'Description One'],
+ ['id' => 2, 'name' => 'Name Two', 'description' => 'Description Two'],
+ ['id' => 3, 'name' => 'Name Three', 'description' => 'Description Three'],
+ ],
+ $this->pgsqlDatabaseContext->selectAll($table)
+ );
+ }
+
public function test_update_multiple_rows_at_once() : void
{
$this->pgsqlDatabaseContext->createTable((new Table(
diff --git a/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php b/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php
index d969b272e..ec40ad3f9 100644
--- a/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php
+++ b/src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JsonTest.php
@@ -9,12 +9,34 @@
use function Flow\ETL\DSL\{average, df, from_array, overwrite, ref};
use function Flow\ETL\DSL\{config, flow_context, rows};
use function Flow\Filesystem\DSL\path;
+
use Flow\ETL\Adapter\JSON\JsonLoader;
use Flow\ETL\Tests\Double\FakeExtractor;
use Flow\ETL\{Tests\FlowTestCase};
final class JsonTest extends FlowTestCase
{
+ public function test_domdocument_json_file() : void
+ {
+ $domDocument = new \DOMDocument();
+ $domDocument->loadXml('red');
+
+ df()
+ ->read(from_array([
+ ['id' => 1, 'descriptionHtml' => $domDocument, 'size' => 'small'],
+ ]))
+ ->saveMode(overwrite())
+ ->write(to_json($path = __DIR__ . '/var/test_domdocument.json'))
+ ->run();
+
+ self::assertStringContainsString(
+ <<<'JSON'
+[{"id":1,"descriptionHtml":"red<\/b>","size":"small"}]
+JSON,
+ \file_get_contents($path)
+ );
+ }
+
public function test_json_loader() : void
{
$path = __DIR__ . '/var/test_json_loader.json';
diff --git a/src/core/etl/tests/Flow/ETL/Tests/Integration/Function/DOMElementValueTest.php b/src/core/etl/tests/Flow/ETL/Tests/Integration/Function/DOMElementValueTest.php
index 41e9b4f25..de2ea7f63 100644
--- a/src/core/etl/tests/Flow/ETL/Tests/Integration/Function/DOMElementValueTest.php
+++ b/src/core/etl/tests/Flow/ETL/Tests/Integration/Function/DOMElementValueTest.php
@@ -4,11 +4,37 @@
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, type_string, xml_element_entry, xml_entry};
+
use Flow\ETL\Tests\FlowTestCase;
final class DOMElementValueTest extends FlowTestCase
{
+ public function test_dom_element_cast_as_string() : void
+ {
+ $document = new \DOMDocument();
+ $document->loadXml('User Name 01');
+
+ $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' => 'User Name 01'],
+ ],
+ $rows->toArray()
+ );
+ }
+
public function test_dom_element_value() : void
{
$rows = df()
@@ -53,6 +79,31 @@ public function test_dom_element_value_from_dom_document() : void
);
}
+ public function test_dom_element_value_on_dom_document() : void
+ {
+ $document = new \DOMDocument();
+ $document->loadXml('User Name 01');
+
+ $rows = df()
+ ->read(from_rows(
+ rows(
+ row(
+ xml_entry('html_raw', $document)
+ )
+ )
+ ))
+ ->withEntry('html', ref('html_raw')->domElementValue())
+ ->drop('html_raw')
+ ->fetch();
+
+ self::assertSame(
+ [
+ ['html' => 'User Name 01'],
+ ],
+ $rows->toArray()
+ );
+ }
+
public function test_dom_element_value_on_xpath_result() : void
{
$rows = df()