OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
/
vendor
/
kreait
/
firebase-php
/
tests
/
Unit
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/12/2024 10:34:14 AM
rwxr-xr-x
📁
Auth
-
08/12/2024 10:36:28 AM
rwxr-xr-x
📄
AuthTest.php
989 bytes
08/12/2024 10:34:13 AM
rw-r--r--
📁
Database
-
08/12/2024 10:36:41 AM
rwxr-xr-x
📄
DatabaseTest.php
2.07 KB
08/12/2024 10:34:13 AM
rw-r--r--
📄
DynamicLinksTest.php
17.29 KB
08/12/2024 10:34:13 AM
rw-r--r--
📁
Exception
-
08/12/2024 10:35:41 AM
rwxr-xr-x
📄
FactoryTest.php
10.34 KB
08/12/2024 10:34:13 AM
rw-r--r--
📁
Http
-
08/12/2024 10:35:42 AM
rwxr-xr-x
📁
Messaging
-
08/12/2024 10:35:42 AM
rwxr-xr-x
📄
MessagingTest.php
2.42 KB
08/12/2024 10:34:13 AM
rw-r--r--
📁
RemoteConfig
-
08/12/2024 10:35:43 AM
rwxr-xr-x
📁
Request
-
08/12/2024 10:35:43 AM
rwxr-xr-x
📄
ServiceAccountTest.php
3.39 KB
08/12/2024 10:34:13 AM
rw-r--r--
📁
Util
-
08/12/2024 10:35:43 AM
rwxr-xr-x
📁
Value
-
08/12/2024 10:35:44 AM
rwxr-xr-x
Editing: ServiceAccountTest.php
Close
<?php declare(strict_types=1); namespace Kreait\Firebase\Tests\Unit; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\ServiceAccount; use Kreait\Firebase\Tests\UnitTestCase; use stdClass; /** * @internal */ final class ServiceAccountTest extends UnitTestCase { private string $pathToUnreadableJson; private string $pathToValidJson; private string $validJson; /** @var array<string, string> */ private array $validData; protected function setUp(): void { $this->pathToUnreadableJson = self::$fixturesDir.'/ServiceAccount/unreadable.json'; @\chmod($this->pathToUnreadableJson, 0000); $this->pathToValidJson = self::$fixturesDir.'/ServiceAccount/valid.json'; $this->validJson = (string) \file_get_contents($this->pathToValidJson); $this->validData = \json_decode($this->validJson, true); } protected function tearDown(): void { @\chmod($this->pathToUnreadableJson, 0644); } public function testCreateFromJsonText(): void { $serviceAccount = ServiceAccount::fromValue($this->validJson); $this->assertSame($this->validData, $serviceAccount->asArray()); } public function testCreateFromJsonFile(): void { $serviceAccount = ServiceAccount::fromValue($this->pathToValidJson); $this->assertSame($this->validData, $serviceAccount->asArray()); } public function testCreateFromMissingFile(): void { $this->expectException(InvalidArgumentException::class); ServiceAccount::fromValue('missing.json'); } public function testCreateFromDirectory(): void { $this->expectException(InvalidArgumentException::class); ServiceAccount::fromValue(__DIR__); } public function testCreateFromUnreadableFile(): void { $this->expectException(InvalidArgumentException::class); ServiceAccount::fromValue($this->pathToUnreadableJson); } public function testCreateFromArray(): void { $serviceAccount = ServiceAccount::fromValue($this->validData); $this->assertSame($this->validData, $serviceAccount->asArray()); } public function testCreateFromArrayWithMissingTypeField(): void { $data = $this->validData; unset($data['type']); $this->expectException(InvalidArgumentException::class); ServiceAccount::fromValue($data); } public function testCreateFromServiceAccount(): void { $serviceAccount = $this->createMock(ServiceAccount::class); $this->assertSame($serviceAccount, ServiceAccount::fromValue($serviceAccount)); } /** * @dataProvider invalidValues * * @param mixed $value */ public function testCreateFromInvalidValue($value): void { $this->expectException(InvalidArgumentException::class); ServiceAccount::fromValue($value); } /** * @return array<string, array<int, mixed>> */ public function invalidValues(): array { return [ 'true' => [true], 'false' => [false], 'malformed_json' => ['{'], 'empty_json' => ['{}'], 'empty_array' => [[]], 'invalid_type' => [['type' => 'invalid']], 'unsupported' => [new stdClass()], ]; } }