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

Feedback Wanted [Proposal] Phase 2 Project: Drive #7

Open
adamkelso opened this issue Jun 7, 2019 · 0 comments

Comments

@adamkelso
Copy link
Member

commented Jun 7, 2019

Please either leave a thumbs up, thumbs down, or any other reaction, or respond with a comment.

For the next phase of Guzzler, I'd really appreciate feedback from anyone interested in the project. For a full description of the next project Drive, please see the related page on the documentation site; Drive

The basic idea is a response factory system for a your tests based on either a Swagger/OpenAPI, RAML, or Blueprint API spec doc provided by any service you want to interact with. For example, you might want to integrate with an invoicing service. If so, you may want to specify what your code expects back from a GET endpoint for querying an invoice.

You may build out something like the following:

use function BlastCloud/Drive/drive;

class SomeTest extends TestCase
{
// ...

    $this->guzzler->expects($this->once())
        ->get('/v3/company/{$this->companyId}/invoice/{$this->itemId}')
        ->willRespond( drive('invoice-fountain.invoices.get', 200) );

By default, any data specified in the spec would auto-fill to the same structure with data provided by Faker. You could also fill anything specific you'd like returned, much like Laravel's Model Factories.

//...

$this->guzzler->expects($this->once())
    ->get('/v3/company/{$this->companyId}/invoice/{$this->itemId}')
    ->willRespond( 
        drive('invoice-fountain.invoice.get', 200)
            ->json([
                'data' => drive('invoice-fountain.invoice', [
                    'customer_id' => 42,
                    'date_issued' => $faker->dateThisYear()
                ])
            ])
    );

Again, please leave a reaction or any thoughts on this issue. Feedback is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.