Skip to content

Commit

Permalink
test(firestore): allow firestore database override
Browse files Browse the repository at this point in the history
  • Loading branch information
saiht committed Jan 12, 2024
1 parent 5a2f07f commit 5230634
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/FirebaseProjectManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,34 @@ public function it_uses_the_laravel_cache_as_verifier_cache(): void
$this->assertInstanceOf(CacheItemPoolInterface::class, $property->getValue($factory));
}

/**
* @test
*/
public function it_use_the_default_firestore_database(): void
{
config(['firebase.projects.app.firestore.database' => null]);
$projectName = $this->app->config->get('firebase.default');
$factory = $this->factoryForProject($projectName);

$property = $this->getAccessibleProperty($factory, 'firestoreClientConfig');

$this->assertEquals('(default)', $property->getValue($factory)['database']);
}

/**
* @test
*/
public function it_overrides_the_default_firestore_database(): void
{
config(['firebase.projects.app.firestore.database' => 'override-database']);
$projectName = $this->app->config->get('firebase.default');
$factory = $this->factoryForProject($projectName);

$property = $this->getAccessibleProperty($factory, 'firestoreClientConfig');

$this->assertEquals('override-database', $property->getValue($factory)['database']);
}

/**
* @test
*/
Expand All @@ -289,7 +317,7 @@ public function it_uses_the_laravel_cache_as_auth_token_cache(): void
$this->assertInstanceOf(CacheItemPoolInterface::class, $property->getValue($factory));
}

private function factoryForProject(string $project = null): Factory
private function factoryForProject(?string $project = null): Factory
{
$project = $this->app->make(FirebaseProjectManager::class)->project($project);

Expand Down

0 comments on commit 5230634

Please sign in to comment.