|
| 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