Something went wrong. Try again.
Parse and validate AT Protocol Lexicons with DTO generation for Laravel
Something went wrong. Try again.
2.0 kB · 73 lines
PHP
at dev
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374<?php
namespace SocialDept\AtpSchema\Tests\Unit\Console;
use Orchestra\Testbench\TestCase;use SocialDept\AtpSchema\Console\ValidateCommand;use SocialDept\AtpSchema\SchemaServiceProvider;
class ValidateCommandTest extends TestCase{ protected function getPackageProviders($app): array { return [SchemaServiceProvider::class]; }
protected function setUp(): void { parent::setUp();
config([ 'schema.sources' => [__DIR__.'/../../fixtures'], ]); }
public function test_it_validates_valid_data(): void { $data = json_encode([ 'text' => 'Hello, World!', 'createdAt' => '2024-01-01T00:00:00Z', ]);
$this->artisan(ValidateCommand::class, [ 'nsid' => 'app.bsky.feed.post', '--data' => $data, ]) ->expectsOutput('Validating data against schema: app.bsky.feed.post') ->expectsOutput('✓ Validation passed') ->assertSuccessful(); }
public function test_it_fails_on_invalid_data(): void { $data = json_encode([ 'text' => 'Hello, World!', // Missing required createdAt ]);
$this->artisan(ValidateCommand::class, [ 'nsid' => 'app.bsky.feed.post', '--data' => $data, ]) ->expectsOutput('✗ Validation failed:') ->assertFailed(); }
public function test_it_requires_data_or_file_option(): void { $this->artisan(ValidateCommand::class, [ 'nsid' => 'app.bsky.feed.post', ]) ->expectsOutput('Either --data or --file option must be provided') ->assertFailed(); }
public function test_it_handles_invalid_json(): void { $this->artisan(ValidateCommand::class, [ 'nsid' => 'app.bsky.feed.post', '--data' => '{invalid json}', ]) ->assertFailed(); }}