Laravel Spark Open Sources its Integration Tests

Laravel Spark Open Sources its Integration Tests

Spark is a commercial Laravel package that provides scaffolding for quickly setting up a SaaS app and more. Spark was officially released back in April, and they have just made available a repository holding all the integration tests.

Even if you are not a Spark customer, this can be useful as a learning resource to see how they structured and utilized integration testing within the project.

One example of this is within the StripeWebhookControllerTest. It includes examples of testing with web hooks:

public function test_events_are_fired_when_subscriptions_are_deleted()
    $user = $this->createSubscribedUser('spark-test-1');
    $this->json('POST', '/webhook/stripe', [
        'type' => 'customer.subscription_deleted',
        'id' => 'event-id',
        'data' => [
            'object' => [
                'id' => $user->subscriptions->first()->stripe_id,
                'customer' => $user->stripe_id,

Then in that same file I came across a forceFill method on an Eloquent model:

$user = $this->createSubscribedUser('spark-test-1');
    'card_country' => 'US',

This allows you to fill the model with an array of attributes and bypass the mass assignment. Which is handy when writing your tests.

If you are looking for examples of tests from a real world app, give it a look, and you might just pick up on some new framework features in the process.

Filed in: Laravel Tutorials / Spark / Testing
Laravel News Partners

Laravel Jobs

Senior Full Stack Engineer - Laravel
Laravel partner seeks Lead Developer
Kirschbaum Development Group
Senior Programmer **Immediate Opening** (send resume to
SBG Corp
Web Developer - Laravel
Grand Forks, North Dakota
Center for Rural Health
Senior Full-Stack Laravel Developer
Berlin, Germany


Join 31,000+ others and never miss out on new tips, tutorials, and more.