Skip to content

Commit b09644a

Browse files
committed
Merge branch 'Ciki-patch-1'
2 parents 7fefa44 + 1e21743 commit b09644a

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/Account/AccountCollectionFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class AccountCollectionFactory
88
{
99

1010
/**
11-
* @param array<string, array{token: string, account: string}> $accounts
11+
* @param array<string|int, array{token: string, account: string}> $accounts
1212
*/
1313
public static function create(array $accounts): AccountCollection
1414
{
@@ -19,7 +19,7 @@ public static function create(array $accounts): AccountCollection
1919
} elseif (!isset($info['account']) || $info['account'] === '') { /* @phpstan-ignore-line */
2020
throw new Exceptions\InvalidArgument(sprintf('Key "account" is required for alias "%s".', $alias));
2121
}
22-
$accountCollection->addAccount($alias, new FioAccount($info['account'], $info['token']));
22+
$accountCollection->addAccount((string) $alias, new FioAccount($info['account'], $info['token']));
2323
}
2424

2525
return $accountCollection;

tests/src/Unit/Account/AccountCollectionTest.php

+22-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testAddAccount(): void
3737
public function testInvalidAlias(): void
3838
{
3939
$account1 = new FioAccount('323536', 'foo');
40-
$accounts = new AccountCollection;
40+
$accounts = new AccountCollection();
4141
$accounts->addAccount('foo', $account1);
4242
$accounts->account('bar');
4343
}
@@ -47,7 +47,7 @@ public function testCount(): void
4747
{
4848
$account1 = new FioAccount('323536', 'foo');
4949
$account2 = new FioAccount('978654', 'bar');
50-
$accounts = new AccountCollection;
50+
$accounts = new AccountCollection();
5151
Assert::equal(0, $accounts->count());
5252

5353
$accounts->addAccount('foo', $account1);
@@ -60,7 +60,7 @@ public function testIteration(): void
6060
{
6161
$account1 = new FioAccount('323536', 'foo');
6262
$account2 = new FioAccount('978654', 'bar');
63-
$accounts = new AccountCollection;
63+
$accounts = new AccountCollection();
6464
$accounts->addAccount('foo', $account1);
6565
$accounts->addAccount('bar', $account2);
6666

@@ -76,7 +76,7 @@ public function testIteration(): void
7676
*/
7777
public function testEmpty(): void
7878
{
79-
(new AccountCollection)->account();
79+
(new AccountCollection())->account();
8080
}
8181

8282

@@ -87,7 +87,7 @@ public function testDuplicity(): void
8787
{
8888
$account1 = new FioAccount('323536', 'foo');
8989
$account2 = new FioAccount('978654', 'bar');
90-
$accounts = new AccountCollection;
90+
$accounts = new AccountCollection();
9191
$accounts->addAccount('foo', $account1);
9292
$accounts->addAccount('foo', $account2);
9393
}
@@ -118,6 +118,23 @@ public function testAccountCollectionFactoryThrowToken(): void
118118
}, InvalidArgument::class, 'Key "token" is required for alias "foo".');
119119
}
120120

121+
public function testKeysLikeNumber(): void
122+
{
123+
$collections = AccountCollectionFactory::create([
124+
'1' => [
125+
'account' => '123456/0800',
126+
'token' => 'bar',
127+
],
128+
2 => [
129+
'account' => '987564/0800',
130+
'token' => 'foo',
131+
],
132+
]);
133+
134+
Assert::same('bar', $collections->account('1')->getToken());
135+
Assert::same('foo', $collections->account('2')->getToken());
136+
}
137+
121138
}
122139

123140
(new AccountCollectionTest())->run();

0 commit comments

Comments
 (0)