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

Fix custom morph map sort by #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eduPHP
Copy link

@eduPHP eduPHP commented Aug 23, 2024

Noticed ->sortByMeta was not working properly in an application where the model has a custom morph map, so here is the fix!

Test suite all green

OK (244 tests, 1891 assertions)

New test: \Zoha\Meta\Tests\Clauses\TestCustomMorphMapOrderBy

New helper method to replace the owner_type from the fakeDataMeta array, looks a little clumsy but it is the way I managed to get a failing test without rewriting the whole seeder.

public function replaceOwnerType(string $type): void
{
    foreach ($this->fakeDataMeta as $i => $item) {
        foreach ($item as $j => $meta) {
            $this->fakeDataMeta[$i][$j]['owner_type'] = $type;
        }
    }
}

Not sure if I should push .phpunit.result.cache, so I didn't

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

Successfully merging this pull request may close these issues.

1 participant