Skip to main content

Introduction

Deck by PromptPHP is designed to be easily testable. This guide covers strategies for testing prompts, commands, tracking, and AI SDK integration in your Laravel application.

Setting up tests

Test base class

If you’re using Orchestra Testbench (recommended for package testing), register the service provider in your test case:

Disabling cache and tracking

For most tests, disable caching and tracking to avoid side effects:

Testing prompts

Creating test prompt files

Create fixture prompt files in your test directory:
tests/fixtures/prompts/order-summary/v1/system.md:
tests/fixtures/prompts/order-summary/v1/user.md:

Testing prompt loading

Testing variable interpolation

Testing roles

Testing messages output

Testing with the facade

You can mock the facade in tests where you don’t want filesystem access:

Testing version management

Testing execution tracking

When testing tracking, enable it and run the migrations in your test setup:

Using factories

Use the included factories to seed test data:

Testing Artisan commands

Testing AI SDK integration

Testing HasPromptTemplate

Create a test agent class that uses the trait:

Clearing cached templates

When testing with different prompt versions:
Always call forgetPromptTemplate() in tests where you modify prompt files or change the active version between assertions.