mercredi 26 février 2020

Stripe webhook test returns empty table on execution, but works on stripe's webhook tester

We're having a problem with our test suite. When we run this using the test suite we get a 'The table is empty...' response from PHPUnit.

We know it works as we've also tested using Stripe's 'Send a web hook' test function which works, and the response is stored as expected.

Our code is here:

public function test_webhook_received()
{
    $this->expectsJobs([StoreStripeWebHookJob::class]);
    $this->postJson('/stripeHook', [
        'created' => 1326853478,
        'livemode' => false,
        'id' => 'evt_00000000000000',
        'type' => 'account.external_account.created',
        'object' => 'event',
        'request' => NULL,
        'pending_webhooks' => 1,
        'api_version' => '2019-12-03',
        'data' => [
            'object' => [
                'id' => 'ba_00000000000000',
                'object' => 'bank_account',
                'account' => 'acct_00000000000000',
                'account_holder_name' => 'Jane Austin',
                'account_holder_type' => 'individual',
                'bank_name' => 'STRIPE TEST BANK',
                'country' => 'US',
                'currency' => 'gbp',
                'fingerprint' => '8JXtPxqbdX5GnmYz',
                'last4' => '6789',
                'metadata' => [],
                'routing_number' => '110000000',
                'status' => 'new',
            ],
            ],
        ]);

        $this->assertDatabaseHas('stripe_webhooks', [
            'stripe_created_at' => 1326853478,
            'type' => 'account.external_account.created',
        ]);
}

The response received is:

Failed asserting that a row in the table [stripe_webhooks] matches the attributes { "stripe_created_at": 1326853478, "type": "account.external_account.created" }.

The table is empty..

If we remove the

$this->expectsJobs([StoreStripeWebHookJob::class]);

tests succeed. Obviously the expectsJob() call should be where it is though.

Aucun commentaire:

Enregistrer un commentaire