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

Commit

Permalink
Merge branch 'hotfix/qa' into release-1.0.0
Browse files Browse the repository at this point in the history
Close #20
Close #21
  • Loading branch information
weierophinney committed Feb 27, 2018
2 parents 06cb9c8 + 2dd0970 commit 290e4d6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Exception/InvalidConfigException.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
/**
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2017-2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Zend\Expressive\Authentication\Exception;

class InvalidConfigException extends RuntimeException implements ExceptionInterface
class InvalidConfigException extends RuntimeException
{
}
5 changes: 2 additions & 3 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php
/**
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2017-2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Zend\Expressive\Authentication\Exception;

class RuntimeException extends \RuntimeException implements
ExceptionInterface
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}
50 changes: 50 additions & 0 deletions test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace ZendTest\Expressive\Authentication;

use PHPUnit\Framework\TestCase;
use Zend\Expressive\Authentication\AuthenticationMiddleware;
use Zend\Expressive\Authentication\ConfigProvider;
use Zend\Expressive\Authentication\UserRepository;

class ConfigProviderTest extends TestCase
{
/** @var ConfigProvider */
private $provider;

protected function setUp()
{
$this->provider = new ConfigProvider();
}

public function testProviderDefinesExpectedFactoryServices()
{
$config = $this->provider->getDependencies();
$factories = $config['factories'];

$this->assertArrayHasKey(AuthenticationMiddleware::class, $factories);
$this->assertArrayHasKey(UserRepository\Htpasswd::class, $factories);
$this->assertArrayHasKey(UserRepository\PdoDatabase::class, $factories);
}

public function testInvocationReturnsArrayWithDependencies()
{
$config = ($this->provider)();

$this->assertInternalType('array', $config);
$this->assertArrayHasKey('authentication', $config);
$this->assertInternalType('array', $config['authentication']);

$this->assertArrayHasKey('dependencies', $config);
$this->assertInternalType('array', $config['dependencies']);
$this->assertArrayHasKey('aliases', $config['dependencies']);
$this->assertArrayHasKey('factories', $config['dependencies']);
}
}
39 changes: 39 additions & 0 deletions test/ExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace ZendTest\Expressive\Authentication;

use Generator;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerExceptionInterface;
use Zend\Expressive\Authentication\Exception\ExceptionInterface;

class ExceptionTest extends TestCase
{
public function exception() : Generator
{
$namespace = substr(ExceptionInterface::class, 0, strrpos(ExceptionInterface::class, '\\') + 1);

$exceptions = glob(__DIR__ . '/../src/Exception/*.php');
foreach ($exceptions as $exception) {
$class = substr(basename($exception), 0, -4);

yield $class => [$namespace . $class];
}
}

/**
* @dataProvider exception
*/
public function testExceptionIsInstanceOfExceptionInterface(string $exception) : void
{
$this->assertContains('Exception', $exception);
$this->assertTrue(is_a($exception, ExceptionInterface::class, true));
}
}

0 comments on commit 290e4d6

Please sign in to comment.