8000 [Notifier][Firebase] Add Firebase v1 API support by vojtechsmejkal · Pull Request #60205 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Notifier][Firebase] Add Firebase v1 API support #60205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 7.4
Choose a base branch
from
Prev Previous commit
Next Next commit
[Notifier][Firebase] Update tests to reflect move to v1 API
The private key used in tests was generated only for the purposes of these tests and is not connected to anything real.
  • Loading branch information
Vojtech Smejkal committed May 25, 2025
commit 6136bc18183ca9020bee9fab7a294e43e22aabcc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* @author Oskar Stark <oskarstark@googlemail.com>
* @author Vojtech Smejkal <https://vojtechsmejkal.cz>
*/
final class FirebaseTransportFactoryTest extends AbstractTransportFactoryTestCase
{
Expand All @@ -30,14 +31,15 @@ public function createFactory(): FirebaseTransportFactory
public static function createProvider(): iterable
{
yield [
'firebase://host.test',
'firebase://username:password@host.test',
'firebase://fcm.googleapis.com',
'firebase://firebase-adminsdk@iam.gserviceaccount.com@default?project_id=PROJECT_ID&private_key_id=PRIVATE_KEY_ID&private_key=PRIVATE_KEY',
];
}

public static function supportsProvider(): iterable
{
yield [true, 'firebase://username:password@default'];
yield [true, 'firebase://firebase-adminsdk@iam.gserviceaccount.com@default?project_id=PROJECT_ID&private_key_id=PRIVATE_KEY_ID&private_key=PRIVATE_KEY'];
yield [false, 'somethingElse://username:password@default'];
}

Expand All @@ -49,6 +51,5 @@ public static function unsupportedSchemeProvider(): iterable
public static function incompleteDsnProvider(): iterable
{
yield ['firebase://:password@default'];
yield ['firebase://username@default'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,25 @@

/**
* @author Oskar Stark <oskarstark@googlemail.com>
* @author Vojtech Smejkal <https://vojtechsmejkal.cz>
*/
final class FirebaseTransportTest extends TransportTestCase
{
public static function createTransport(?HttpClientInterface $client = null): FirebaseTransport
{
return new FirebaseTransport('username:password', $client ?? new MockHttpClient());
return new FirebaseTransport(
'',
'test_project_id',
'firebase-adminsdk-test@test-project.iam.gserviceaccount.com',
'private_key_id',
"-----BEGIN PRIVATE KEY-----\nMIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmU2f/GKCLuvw8NAl\nbqJW5RxhMrUrcampGQxz2F2OT3fqoyKBhAGzNhxbgPZYDeXp7WNNLTk9WLT7sDNM\ndjVUuQIDAQABAkAtOTX52QF4YAfKskxoj6E8oxuVPtabCCanCgJekHK7xDpYpYre\ncvxoPhw0c4McZiFoBOlr0TqyY9qpDWXDHLDFAiEAy9jNU/N438WrurUPuOfyqIYx\n25NJWQ7sgjfDJBMVHO8CIQDAhmed4Uih7QKZAMPeRayFeemdjcXNmN4wp/YjiLZ4\n1wIgaTWnnBnAnDYo0T+cMsI8QvCoEP0u0TFbrkXbiOX0cq8CIQCrg9GxrG75mt1y\nk2TrkuS0cLy4GQJ8PFDNxgSY+YWeNwIgavjv+v6MgyLrMTuZsAd67+5Z5axjdJL8\nbwLzq+QOXk8=\n-----END PRIVATE KEY-----\n",
$client ?? new MockHttpClient(),
);
}

public static function toStringProvider(): iterable
{
yield ['firebase://fcm.googleapis.com/fcm/send', self::createTransport()];
yield ['firebase://fcm.googleapis.com', self::createTransport()];
}

public static function supportedMessagesProvider(): iterable
Expand Down Expand Up @@ -67,12 +75,12 @@ public function testSendWithErrorThrowsTransportException(ResponseInterface $res
public static function sendWithErrorThrowsExceptionProvider(): iterable
{
yield [new MockResponse(
json_encode(['results' => [['error' => 'testErrorCode']]]),
json_encode(['error' => ['message' => 'testErrorCode']]),
['response_headers' => ['content-type' => ['application/json']], 'http_code' => 200]
)];

yield [new MockResponse(
json_encode(['results' => [['error' => 'testErrorCode']]]),
json_encode(['error' => ['message' => 'testErrorCode']]),
['response_headers' => ['content-type' => ['application/json']], 'http_code' => 400]
)];
}
Expand Down
0