Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover all expressions with integration tests #507

Closed
norberttech opened this issue Oct 4, 2023 · 1 comment
Closed

Cover all expressions with integration tests #507

norberttech opened this issue Oct 4, 2023 · 1 comment
Assignees

Comments

@norberttech
Copy link
Member

Every expression is covered with a unit tests that looks like this:

<?php

    public function test_array_unpack() : void
    {
        $row = Row::create(
            Entry::int('id', 1),
            Entry::array('array_entry', [
                'status' => 'PENDING',
                'enabled' => true,
                'array' => ['foo' => 'bar'],
            ]),
        );

        $this->assertSame(
            [
                'status' => 'PENDING',
                'enabled' => true,
                'array' => ['foo' => 'bar'],
            ],
            (new ArrayUnpack(ref('array_entry')))->eval($row)
        );
    }

however this does not show how to use given expressions, integration tests would solve that problem, for example:

<?php

namespace Flow\ETL\Tests\Integration\Row\Reference\Expression;

use Flow\ETL\DSL\Entry;
use Flow\ETL\DSL\From;
use Flow\ETL\DSL\To;
use Flow\ETL\Flow;
use Flow\ETL\Memory\ArrayMemory;
use Flow\ETL\Row;
use Flow\ETL\Rows;
use PHPUnit\Framework\TestCase;
use function Flow\ETL\DSL\array_expand;
use function Flow\ETL\DSL\ref;

final class ArrayUnpackTest extends TestCase
{
    public function test_array_unpack() : void
    {
        (new Flow())
            ->read(
                From::rows(new Rows(
                    Row::with(Entry::int('id', 1), Entry::array('array', ['a' => 1, 'b' => 2, 'c' => 3])),
                ))
            )
            ->withEntry('expanded', array_expand(ref('array')))
            ->write(To::memory($memory = new ArrayMemory()))
            ->run();

        $this->assertSame(
            [
                ['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3], 'expanded' => 1],
                ['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3], 'expanded' => 2],
                ['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3], 'expanded' => 3],
            ],
            $memory->data
        );
    }
}
@stloyd
Copy link
Member

stloyd commented Oct 13, 2023

@norberttech I think we have covered maybe not all of the tests as integration ones but for sure the critical ones are covered. I guess this task is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants