Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at dev 1.7 kB view raw
1<?php 2 3namespace SocialDept\AtpSchema\Tests\Unit\Console; 4 5use Illuminate\Support\Facades\Cache; 6use Orchestra\Testbench\TestCase; 7use SocialDept\AtpSchema\Console\ClearCacheCommand; 8use SocialDept\AtpSchema\SchemaServiceProvider; 9 10class ClearCacheCommandTest extends TestCase 11{ 12 protected function getPackageProviders($app): array 13 { 14 return [SchemaServiceProvider::class]; 15 } 16 17 protected function setUp(): void 18 { 19 parent::setUp(); 20 21 Cache::flush(); 22 23 config([ 24 'schema.cache.prefix' => 'schema', 25 ]); 26 } 27 28 public function test_it_clears_specific_schema_cache(): void 29 { 30 // Set a cache value 31 Cache::put('schema:parsed:test.nsid', ['data'], 3600); 32 33 $this->artisan(ClearCacheCommand::class, [ 34 '--nsid' => 'test.nsid', 35 ]) 36 ->expectsOutput('Clearing cache for schema: test.nsid') 37 ->expectsOutput('✓ Cache cleared') 38 ->assertSuccessful(); 39 40 $this->assertFalse(Cache::has('schema:parsed:test.nsid')); 41 } 42 43 public function test_it_clears_all_caches(): void 44 { 45 // Set some cache values 46 Cache::put('schema:parsed:test1', ['data'], 3600); 47 Cache::put('schema:parsed:test2', ['data'], 3600); 48 49 $this->artisan(ClearCacheCommand::class, [ 50 '--all' => true, 51 ]) 52 ->expectsOutput('Clearing all schema caches...') 53 ->assertSuccessful(); 54 } 55 56 public function test_it_requires_nsid_or_all_option(): void 57 { 58 $this->artisan(ClearCacheCommand::class) 59 ->expectsOutput('Either --nsid or --all option must be provided') 60 ->assertFailed(); 61 } 62}