set('websockets.managers.app', SQLiteAppManager::class); } public function setUp(): void { parent::setUp(); $this->apps = app()->make(AppManager::class); // Test if SQLite async database is working try { $this->await($this->apps->all(), null, 2); } catch (\Exception $e) { $this->markTestSkipped('SQLite async database is not available: ' . $e->getMessage()); } } public function test_can_return_all_apps() { $apps = $this->await($this->apps->all()); $this->assertCount(0, $apps); $this->await($this->apps->createApp([ 'id' => 1, 'key' => 'test', 'secret' => 'secret', 'name' => 'Test', 'enable_client_messages' => true, 'enable_statistics' => false, ])); $apps = $this->await($this->apps->all()); $this->assertCount(1, $apps); } public function test_can_find_apps_by_id() { $this->await($this->apps->createApp([ 'id' => 1, 'key' => 'test', 'secret' => 'secret', 'name' => 'Test', 'enable_client_messages' => true, 'enable_statistics' => false, ])); $app = $this->await($this->apps->findById(1)); $this->assertInstanceOf(App::class, $app); $this->assertSame('test', $app->key); } public function test_can_find_apps_by_key() { $this->await($this->apps->createApp([ 'id' => 1, 'key' => 'key', 'secret' => 'secret', 'name' => 'Test', 'enable_client_messages' => true, 'enable_statistics' => false, ])); $app = $this->await($this->apps->findByKey('key')); $this->assertInstanceOf(App::class, $app); $this->assertSame('key', $app->key); } public function test_can_find_apps_by_secret() { $this->await($this->apps->createApp([ 'id' => 1, 'key' => 'key', 'secret' => 'secret', 'name' => 'Test', 'enable_client_messages' => true, 'enable_statistics' => false, ])); $app = $this->await($this->apps->findBySecret('secret')); $this->assertInstanceOf(App::class, $app); $this->assertSame('key', $app->key); } }