Skip to content

8.1.0

Latest

Choose a tag to compare

@tabuna tabuna released this 16 Nov 08:43
08c99e8

8.1.0 - 2026-11-16

A fluent testing API for JSON-RPC methods, with the existing helpers retained for compatibility.

Added

  • Sajya\Server\Testing\MakesRpcRequests with withRpcEndpoint() and rpc().
  • Configure the endpoint once in your test setup, then use rpc('tennis@ping') with Laravel's standard response assertions.
  • A clear setup error when calling rpc() without an endpoint.

Deprecated

  • ProceduralRequests remains available with its existing behavior. Its four public methods carry native #[Deprecated] attributes; the trait has a PHPDoc deprecation tag. Native warnings are emitted on PHP 8.4 and later.

Migration

Replace ProceduralRequests with MakesRpcRequests:

use PHPUnit\Framework\Attributes\Test;
use Sajya\Server\Testing\MakesRpcRequests;
use Tests\TestCase;

class PingPongTest extends TestCase
{
    use MakesRpcRequests;

    protected function setUp(): void
    {
        parent::setUp();

        $this->withRpcEndpoint(route('rpc.endpoint'));
    }

    #[Test]
    public function ping_returns_pong(): void
    {
        $this->rpc('tennis@ping')
            ->assertOk()
            ->assertHeader('content-type', 'application/json')
            ->assertJsonPath('result', 'pong')
            ->assertJsonMissingPath('error');
    }
}

Use withRpcEndpoint(route($name)) instead of setRpcRoute($name), and withRpcEndpoint($url) instead of setRpcUrl($url).
Replace callProcedure() or callHttpProcedure() with rpc().

rpc() returns a TestResponse without automatic assertions. When replacing callProcedure(), keep its previous status and content-type checks explicitly, as shown above.

Tests

All server test methods and the test documentation examples use PHPUnit's #[Test] attribute instead of a test method prefix.

Full changelog: 8.0.0...8.1.0