Use Case

PHPUnit Fixtures with MockHero

Base Test Case

<?php
use PHPUnit\Framework\TestCase;
use GuzzleHttp\Client;

abstract class IntegrationTestCase extends TestCase {
  protected static array $data;

  public static function setUpBeforeClass(): void {
    $client = new Client();
    $res = $client->post("https://api.mockhero.dev/api/v1/generate", [
      "headers" => [
        "x-api-key" => getenv("MOCKHERO_API_KEY"),
      ],
      "json" => [
        "seed" => 1,
        "tables" => [[
          "name" => "users", "count" => 10, "fields" => [
            ["name" => "id", "type" => "uuid"],
            ["name" => "email", "type" => "email"],
          ]
        ]]
      ]
    ]);
    self::$data = json_decode($res->getBody(), true);
  }
}

Get Started

Free API key.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles