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

Adds new match() method #407

Merged
merged 9 commits into from
Sep 24, 2021
Merged

Adds new match() method #407

merged 9 commits into from
Sep 24, 2021

Conversation

mertasan
Copy link
Contributor

Q A
Bug fix? no
New feature? yes

This is an alternative to #406.

it('database test', function () {
    
    expect(new Foo())
        ->foo->toBe('foo')
        ->match(DB::getDriverName(), [
            'mysql'  => fn ($foo) => $foo->mysql->toBeTrue(),
            'sqlite' => fn ($foo) => $foo->sqlite->toBeTrue(),
        ])
        ->bar->toBe('bar');

});
it('builder test', function ($driver) {
    
    expect(new Builder())
        ->match($driver, [
            'mysql'   => fn ($b) => $b->where('...')->toBe(...),
            'postgre' => fn ($b) => $b->whereRaw('...')->toBe(...),
        ]);
    
})->with([
    'mysql',
    'postgre',
]);

For more examples, please review the tests.

Thank you.

@nunomaduro
Copy link
Member

@lukeraymonddowning What do you think?

src/Expectation.php Outdated Show resolved Hide resolved
src/Expectation.php Outdated Show resolved Hide resolved
@lukeraymonddowning
Copy link
Member

I actually like this a lot. It's a sharp knife, for sure, but a valuable one I think.

@nunomaduro nunomaduro merged commit dc12419 into pestphp:master Sep 24, 2021
@mertasan mertasan deleted the method-match branch September 25, 2021 00:11
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.

3 participants