Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Jan 8, 2023
1 parent 9f9aa5b commit ee11e3e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 90 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Unreleased

* Dropped support for Lumen
* Upgraded `kreait/firebase-php` from 6.x to 7.x
* Dropped support for PHP <8.1, Laravel <9.0
* Dropped support for Lumen ([it is not recommended anymore to use it](https://github.com/laravel/lumen/commit/69b26578d2f15595ea901278434b74df459c4329))
* The ability to disable credentials auto-discovery has been removed. If you don't want a service account to be
auto-discovered, provide it by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or by adapting
auto-discovered, provide it by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or by modifying
the package configuration.

## 4.2.0 - 2022-07-28
Expand Down
23 changes: 14 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"kreait/firebase-php": "^6.7",
"illuminate/contracts": "^8.0 || ^9.0",
"illuminate/support": "^8.0 || ^9.0",
"symfony/cache": "^5.4 || ^6.1.2"
"php": "~8.1.0 || ~8.2.0",
"kreait/firebase-php": "^7.0",
"illuminate/contracts": "^9.0",
"illuminate/support": "^9.0",
"symfony/cache": "^6.1.2"
},
"require-dev": {
"orchestra/testbench": "^6.0 || 7.0",
"orchestra/testbench": "^7.0",
"symplify/easy-coding-standard": "^11.1"
},
"autoload": {
Expand All @@ -32,9 +32,6 @@
}
},
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
},
"laravel": {
"providers": [
"Kreait\\Laravel\\Firebase\\ServiceProvider"
Expand All @@ -43,5 +40,13 @@
"Firebase": "Kreait\\Laravel\\Firebase\\Facades\\Firebase"
}
}
},
"scripts": {
"cs": [
"vendor/bin/ecs --fix"
],
"test": [
"vendor/bin/phpunit"
]
}
}
5 changes: 0 additions & 5 deletions src/FirebaseProjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ protected function configure(string $name): FirebaseProject
$factory = $factory->withServiceAccount($resolvedCredentials);
}

$enableAutoDiscovery = $config['credentials']['auto_discovery'] ?? ($this->getDefaultProject() === $name);
if (!$enableAutoDiscovery) {
$factory = $factory->withDisabledAutoDiscovery();
}

if ($databaseUrl = $config['database']['url'] ?? null) {
$factory = $factory->withDatabaseUri($databaseUrl);
}
Expand Down
80 changes: 6 additions & 74 deletions tests/FirebaseProjectManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ public function credentials_can_be_configured(): void
$factory = $this->factoryForProject($projectName);

// Retrieve service account
/** @var Firebase\ServiceAccount $serviceAccount */
$serviceAccount = $this->getAccessibleMethod($factory, 'getServiceAccount')->invoke($factory);
$serviceAccount = $this->getAccessibleProperty($factory, 'serviceAccount')->getValue($factory);

// Validate value
$this->assertSame($credentials, $serviceAccount->asArray());
$this->assertSame($credentials, $serviceAccount);
}

/**
Expand All @@ -108,79 +107,12 @@ public function projects_can_have_different_credentials(): void
$factory = $this->factoryForProject($projectName);
$secondFactory = $this->factoryForProject($secondProjectName);

/** @var Firebase\ServiceAccount $serviceAccount */
$serviceAccount = $this->getAccessibleMethod($factory, 'getServiceAccount')->invoke($factory);

/** @var Firebase\ServiceAccount $secondServiceAccount */
$secondServiceAccount = $this->getAccessibleMethod($factory, 'getServiceAccount')->invoke($secondFactory);
$serviceAccount = $this->getAccessibleProperty($factory, 'serviceAccount')->getValue($factory);
$secondServiceAccount = $this->getAccessibleProperty($factory, 'serviceAccount')->getValue($secondFactory);

// Validate values
$this->assertSame($credentials, $serviceAccount->asArray());
$this->assertSame($secondCredentials, $secondServiceAccount->asArray());
}

/**
* @test
*/
public function credential_auto_discovery_is_enabled_by_default_for_default_project(): void
{
$projectName = $this->app->config->get('firebase.default');

$factory = $this->factoryForProject($projectName);

$this->getAccessibleMethod($factory, 'getServiceAccount')->invoke($factory);

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

$this->assertFalse($property->getValue($factory));
}

/**
* @test
*/
public function credential_auto_discovery_can_be_disabled_for_default_project(): void
{
$projectName = $this->app->config->get('firebase.default');

$this->app->config->set('firebase.projects.' . $projectName . '.credentials.auto_discovery', false);

$factory = $this->factoryForProject($projectName);

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

$this->assertTrue($property->getValue($factory));
}

/**
* @test
*/
public function credential_auto_discovery_is_not_enabled_by_default_for_other_projects(): void
{
$projectName = 'another-app';

$this->app->config->set('firebase.projects.' . $projectName . '.credentials', []);

$factory = $this->factoryForProject($projectName); // factory for default project with default settings

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

$this->assertTrue($property->getValue($factory));
}

/**
* @test
*/
public function credential_auto_discovery_can_be_enabled_for_other_project(): void
{
$projectName = 'another-app';

$this->app->config->set('firebase.projects.' . $projectName . '.credentials.auto_discovery', true);

$factory = $this->factoryForProject($projectName);

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

$this->assertFalse($property->getValue($factory));
$this->assertSame($credentials, $serviceAccount);
$this->assertSame($secondCredentials, $secondServiceAccount);
}

/**
Expand Down

0 comments on commit ee11e3e

Please sign in to comment.