A comprehensive testing package for the Streams platform that provides a pre-configured Laravel testing environment with sample data and utilities for testing Streams applications.
- Pre-configured Test Environment: Extends Orchestra Testbench for seamless Laravel/Streams integration
- Sample Test Data: Includes Star Wars-themed sample streams (films, people, planets, species, starships, vehicles, files)
- Automatic Data Restoration: Automatically restores test data after each test to ensure clean state
- PHPUnit 10 Support: Fully compatible with the latest PHPUnit version
- Custom TestCase: Base test case class with built-in utilities for Streams testing
composer require streams/testing --dev<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:aiGINJ0oFnqrMGUwJYWJuhe6meZoW+GqppwDJD4YZeM="/>
</php>
</phpunit><?php
namespace Tests;
use Streams\Core\Support\Facades\Streams;
class FilmTest extends \Streams\Testing\TestCase
{
public function test_can_query_films()
{
$films = Streams::entries('films')->get();
$this->assertCount(7, $films);
}
public function test_can_create_film()
{
$film = Streams::make('films')->create([
'title' => 'New Film',
'director' => 'New Director',
]);
$this->assertEquals('New Film', $film->title);
}
}vendor/bin/phpunitPre-configured sample streams with Star Wars data:
- films - 7 films with directors, release dates, and more
- people - Characters with attributes like homeworld, species
- planets - Planetary data including climate, terrain, population
- species - Species classifications and characteristics
- starships - Starship specifications and capabilities
- vehicles - Vehicle details and stats
- files - File handling examples
The base TestCase provides:
- Automatic test data restoration after each test
- Full Laravel application context
- Orchestra Testbench integration
- Pre-configured streams environment
// Query entries
$films = Streams::entries('films')
->where('director', 'George Lucas')
->orderBy('release_date')
->get();
// Create entries
$film = Streams::make('films')->create([
'title' => 'A New Film',
'director' => 'New Director',
]);
// Update entries
$film->update(['director' => 'Updated Director']);
// Delete entries
$film->delete();
// Count entries
$count = Streams::entries('films')->count();Comprehensive documentation is available at /docs/testing/introduction (see docs/00-introduction.md in this repository):
- Introduction - Overview and key concepts (
/docs/testing/introduction) - Installation - Setup and configuration
- Test Data - Understanding sample streams
- Writing Tests - Test patterns and best practices
- Configuration - Advanced configuration options
- Troubleshooting - Common issues and solutions
- 📚 Full Streams Documentation
- 🚀 Getting Started Guide
- 💡 Test Examples
- 🔧 Configuration Guide
- ❓ Troubleshooting
- PHP 8.1 or higher
- Laravel 10.x or 11.x
- Streams Core ^2.0
- PHPUnit 10.x
- Test Environment: Uses Orchestra Testbench to create a full Laravel application context
- Data Management: Sample data stored in
laravel/streams/with backups inlaravel/streams.bak/ - Automatic Cleanup: The
tearDown()method restores original test data after each test - Laravel Integration: Complete Laravel application structure in
laravel/directory
Contributions are welcome! Please see CONTRIBUTING.md for details.
The Streams Testing package is open-sourced software licensed under the MIT license.
- Documentation: https://streams.dev/docs/testing/introduction
- Issues: https://github.com/laravel-streams/streams-testing/issues
- Discord: Join the Streams community