Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 941544f

Browse files
committed
Improved unit test coverage
1 parent e5cdee5 commit 941544f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

test/DefaultUserFactoryTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace ZendTest\Expressive\Authentication;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use Psr\Container\ContainerInterface;
14+
use Zend\Expressive\Authentication\DefaultUser;
15+
use Zend\Expressive\Authentication\DefaultUserFactory;
16+
use Zend\Expressive\Authentication\UserInterface;
17+
18+
class DefaultUserFactoryTest extends TestCase
19+
{
20+
public function setUp()
21+
{
22+
$this->container = $this->prophesize(ContainerInterface::class);
23+
}
24+
25+
public function testConstructor()
26+
{
27+
$factory = new DefaultUserFactory();
28+
$this->assertInstanceOf(DefaultUserFactory::class, $factory);
29+
}
30+
31+
public function testInvoke()
32+
{
33+
$factory = new DefaultUserFactory();
34+
$userFactory = $factory($this->container->reveal());
35+
$defaultUser = $userFactory('foo');
36+
$this->assertInstanceOf(DefaultUser::class, $defaultUser);
37+
}
38+
}

test/DefaultUserTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,18 @@ public function testGetRoles()
3232
$user = new DefaultUser('foo', ['foo', 'bar']);
3333
$this->assertEquals(['foo', 'bar'], $user->getRoles());
3434
}
35+
36+
public function testGetDetails()
37+
{
38+
$user = new DefaultUser('foo', ['foo', 'bar'], ['name' => 'Foo']);
39+
$this->assertEquals(['name' => 'Foo'], $user->getDetails());
40+
}
41+
42+
public function testGetDetail()
43+
{
44+
$user = new DefaultUser('foo', ['foo', 'bar'], ['name' => 'Foo']);
45+
$this->assertEquals('Foo', $user->getDetail('name'));
46+
$this->assertEquals(false, $user->getDetail('email', false));
47+
$this->assertEquals(null, $user->getDetail('email'));
48+
}
3549
}

0 commit comments

Comments
 (0)