Skip to content

Commit 14691ab

Browse files
committed
identity: add driver creation test cases
1 parent 05db625 commit 14691ab

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/IdentityManagerTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace CodingSocks\UploadHandler\Tests;
4+
5+
use CodingSocks\UploadHandler\Identifier\AuthIdentifier;
6+
use CodingSocks\UploadHandler\Identifier\NopIdentifier;
7+
use CodingSocks\UploadHandler\Identifier\SessionIdentifier;
8+
use CodingSocks\UploadHandler\IdentityManager;
9+
10+
class IdentityManagerTest extends TestCase
11+
{
12+
/**
13+
* @var IdentityManager
14+
*/
15+
private $manager;
16+
17+
/**
18+
* {@inheritDoc}
19+
*/
20+
protected function setUp(): void
21+
{
22+
parent::setUp();
23+
24+
$this->manager = new IdentityManager($this->app);
25+
}
26+
27+
public function availableDrivers()
28+
{
29+
return [
30+
'auth' => ['auth', AuthIdentifier::class],
31+
'nop' => ['nop', NopIdentifier::class],
32+
'session' => ['session', SessionIdentifier::class],
33+
];
34+
}
35+
36+
/**
37+
* @dataProvider availableDrivers
38+
*/
39+
public function testDriverCreation($driverName, $expectedInstanceOf)
40+
{
41+
$driver = $this->manager->driver($driverName);
42+
$this->assertInstanceOf($expectedInstanceOf, $driver);
43+
}
44+
45+
public function testDefaultDriver()
46+
{
47+
$driver = $this->manager->driver();
48+
$this->assertInstanceOf(SessionIdentifier::class, $driver);
49+
}
50+
}

0 commit comments

Comments
 (0)