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

Commit 2dd0970

Browse files
committed
Merge pull request #21 from webimpress/test/config-provider
Added ConfigProvider tests
2 parents 1fb3364 + a3c1484 commit 2dd0970

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/ConfigProviderTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 Zend\Expressive\Authentication\AuthenticationMiddleware;
14+
use Zend\Expressive\Authentication\ConfigProvider;
15+
use Zend\Expressive\Authentication\UserRepository;
16+
17+
class ConfigProviderTest extends TestCase
18+
{
19+
/** @var ConfigProvider */
20+
private $provider;
21+
22+
protected function setUp()
23+
{
24+
$this->provider = new ConfigProvider();
25+
}
26+
27+
public function testProviderDefinesExpectedFactoryServices()
28+
{
29+
$config = $this->provider->getDependencies();
30+
$factories = $config['factories'];
31+
32+
$this->assertArrayHasKey(AuthenticationMiddleware::class, $factories);
33+
$this->assertArrayHasKey(UserRepository\Htpasswd::class, $factories);
34+
$this->assertArrayHasKey(UserRepository\PdoDatabase::class, $factories);
35+
}
36+
37+
public function testInvocationReturnsArrayWithDependencies()
38+
{
39+
$config = ($this->provider)();
40+
41+
$this->assertInternalType('array', $config);
42+
$this->assertArrayHasKey('authentication', $config);
43+
$this->assertInternalType('array', $config['authentication']);
44+
45+
$this->assertArrayHasKey('dependencies', $config);
46+
$this->assertInternalType('array', $config['dependencies']);
47+
$this->assertArrayHasKey('aliases', $config['dependencies']);
48+
$this->assertArrayHasKey('factories', $config['dependencies']);
49+
}
50+
}

0 commit comments

Comments
 (0)