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


Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Software Engineer Lead (PHP)
CivicPlus, LLC
Full-time Senior Web Developer
Detroit, MI
Wayne State University
Senior Software Engineer
Sydney, Australia
Full Stack Engineer
Remote or Medford, Oregon
Empire Medical
Laravel Developer (fulltime - Dutch only)
Qbixx | Webservices
Full Stack or Back-End Developer
Alexandria, VA; Tallahassee, FL; Orlando, FL
Marketing for Change
Senior Quality Assurance Engineer
Bisnow Media