yadm icon indicating copy to clipboard operation
yadm copied to clipboard

testShouldTrackAddedValueToEmptyCollection not up to date?

Open gregor-tb opened this issue 6 years ago • 1 comments

I just patched our code because $set on empty array has created an object when using key.0 = val instead of key = [ val ] (https://github.com/makasim/yadm/commit/8d61d69592b953328c63d4fffd8e175c7422e49c)

But I wonder, why the build does not fail, on my setup this test seems invalid now:

public function testShouldTrackAddedValueToEmptyCollection()
    {
        $obj = $this->createPersistedObject();
        $collector = new ChangesCollector();
        $collector->register($obj, get_values($obj));
        add_value($obj, 'aKey', 'aVal');
        self::assertEquals([
            '$set' => [
                'aKey.0' => 'aVal',
            ],
        ], $collector->changes(get_values($obj), $collector->getOriginalValues($obj)));
    }

Shouldn't it be changed to

            '$set' => [
                'aKey' => [ 'aVal' ],
            ],

?

Thanks for your great work Gregor

gregor-tb avatar Aug 14 '18 08:08 gregor-tb

Yeah, you are right, tests are a bit out of date.

makasim avatar Aug 14 '18 10:08 makasim