-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
StaticEntryTransformer
(#533)
- Loading branch information
Showing
5 changed files
with
113 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/core/etl/src/Flow/ETL/Transformer/StaticEntryTransformer.php
This file was deleted.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
src/core/etl/tests/Flow/ETL/Tests/Integration/Row/Reference/Expression/AddJsonTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Tests\Integration\Row\Reference\Expression; | ||
|
||
use function Flow\ETL\DSL\lit; | ||
use function Flow\ETL\DSL\ref; | ||
use Flow\ETL\DSL\From; | ||
use Flow\ETL\DSL\To; | ||
use Flow\ETL\Flow; | ||
use Flow\ETL\Memory\ArrayMemory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class AddJsonTest extends TestCase | ||
{ | ||
public function test_add_json_into_existing_reference() : void | ||
{ | ||
(new Flow()) | ||
->read( | ||
From::array( | ||
[['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3]]], | ||
) | ||
) | ||
->withEntry('row', ref('row')->unpack()) | ||
->renameAll('row.', '') | ||
->drop('row') | ||
->withEntry('array', ref('array')->arrayMerge(lit(['d' => 4]))) | ||
->write(To::memory($memory = new ArrayMemory())) | ||
->run(); | ||
|
||
$this->assertSame( | ||
[ | ||
['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4]], | ||
], | ||
$memory->data | ||
); | ||
} | ||
|
||
public function test_add_json_string_into_existing_reference() : void | ||
{ | ||
(new Flow()) | ||
->read( | ||
From::array( | ||
[['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3]]], | ||
) | ||
) | ||
->withEntry('row', ref('row')->unpack()) | ||
->renameAll('row.', '') | ||
->drop('row') | ||
->withEntry('json', lit('{"d": 4}')) | ||
->withEntry('array', ref('array')->arrayMerge(ref('json')->jsonDecode())) | ||
->drop('json') | ||
->write(To::memory($memory = new ArrayMemory())) | ||
->run(); | ||
|
||
$this->assertSame( | ||
[ | ||
['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4]], | ||
], | ||
$memory->data | ||
); | ||
} | ||
|
||
public function test_adding_json_as_object_from_string_entry() : void | ||
{ | ||
(new Flow()) | ||
->read( | ||
From::array([['id' => 1]]) | ||
) | ||
->withEntry('row', ref('row')->unpack()) | ||
->renameAll('row.', '') | ||
->drop('row') | ||
->withEntry('json', lit(['id' => 1, 'name' => 'test'])) | ||
->withEntry('json', ref('json')->jsonEncode(\JSON_FORCE_OBJECT)) | ||
->write(To::memory($memory = new ArrayMemory())) | ||
->run(); | ||
|
||
$this->assertSame( | ||
[ | ||
[ | ||
'id' => 1, | ||
'json' => '{"id":1,"name":"test"}', | ||
], | ||
], | ||
$memory->data | ||
); | ||
} | ||
|
||
public function test_adding_json_from_string_entry() : void | ||
{ | ||
(new Flow()) | ||
->read( | ||
From::array([['id' => 1]]) | ||
) | ||
->withEntry('row', ref('row')->unpack()) | ||
->renameAll('row.', '') | ||
->drop('row') | ||
->withEntry('json', lit('[{"id":1},{"id":2}]')) | ||
->write(To::memory($memory = new ArrayMemory())) | ||
->run(); | ||
|
||
$this->assertSame( | ||
[ | ||
[ | ||
'id' => 1, | ||
'json' => '[{"id":1},{"id":2}]', | ||
], | ||
], | ||
$memory->data | ||
); | ||
} | ||
} |
78 changes: 0 additions & 78 deletions
78
src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/StaticEntryTransformerTest.php
This file was deleted.
Oops, something went wrong.