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

Commit

Permalink
Merge branch 'sheridans-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Sep 21, 2018
2 parents 1f49e3d + 8215fed commit 755b542
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Repository/Pdo/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public function __construct(\PDO $pdo)
*/
protected function scopesToString(array $scopes) : string
{
if (empty($scopes)) {
return '';
}

return trim(array_reduce($scopes, function ($result, $item) {
return $result . ' ' . $item->getIdentifier();
}));
Expand Down
41 changes: 41 additions & 0 deletions test/Repository/Pdo/AbstractRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @see https://github.com/zendframework/zend-expressive-authentication-oauth2 for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-expressive-authentication-oauth2/blob/master/LICENSE.md
* New BSD License
*/

declare(strict_types=1);

namespace ZendTest\Expressive\Authentication\OAuth2\Repository\Pdo;

use PHPUnit\Framework\TestCase;
use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\AbstractRepository;
use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\PdoService;

class AbstractRepositoryTest extends TestCase
{
public function setUp()
{
$this->pdo = $this->prophesize(PdoService::class);
}

public function testConstructor()
{
$abstract = new AbstractRepository($this->pdo->reveal());
$this->assertInstanceOf(AbstractRepository::class, $abstract);
}

public function testScopesToString()
{
$proxy = new class($this->pdo->reveal()) extends AbstractRepository {
public function scopesToString(array $scopes): string
{
return parent::scopesToString($scopes);
}
};
$result = $proxy->scopesToString([]);
$this->assertEquals('', $result);
}
}

0 comments on commit 755b542

Please sign in to comment.