Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Document/AuthCodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public function __construct(DocumentManager $dm, $class)
$this->class = $class;
}

public function getDocumentManager(): DocumentManager
{
return $this->dm;
}

/**
* {@inheritdoc}
*/
Expand Down
10 changes: 0 additions & 10 deletions Document/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ public function __construct(DocumentManager $dm, $class)
$this->class = $class;
}

public function getRepository(): DocumentRepository
{
return $this->repository;
}

public function getDocumentManager(): DocumentManager
{
return $this->dm;
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 0 additions & 5 deletions Entity/AuthCodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public function __construct(EntityManagerInterface $em, $class)
$this->class = $class;
}

public function getEntityManager(): EntityManagerInterface
{
return $this->em;
}

/**
* {@inheritdoc}
*/
Expand Down
10 changes: 0 additions & 10 deletions Entity/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,4 @@ public function deleteClient(ClientInterface $client)
$this->em->remove($client);
$this->em->flush();
}

public function getEntityManager(): EntityManagerInterface
{
return $this->em;
}

public function getRepository(): EntityRepository
{
return $this->repository;
}
}
10 changes: 0 additions & 10 deletions Entity/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,4 @@ public function deleteExpired()

return $qb->getQuery()->execute();
}

public function getEntityManager(): EntityManagerInterface
{
return $this->em;
}

public function getRepository(): EntityRepository
{
return $this->repository;
}
}
10 changes: 0 additions & 10 deletions Form/Handler/AuthorizeFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ public function getScope()
return $this->form->getData()->scope;
}

public function getForm(): FormInterface
{
return $this->form;
}

public function getRequest()
{
return $this->requestStack;
}

/**
* Put form data in $_GET so that OAuth2 library will call Request::createFromGlobals().
*
Expand Down
4 changes: 2 additions & 2 deletions Tests/Document/AuthCodeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use Doctrine\ORM\AbstractQuery;
use FOS\OAuthServerBundle\Document\AuthCodeManager;
use FOS\OAuthServerBundle\Model\AuthCodeInterface;
use FOS\OAuthServerBundle\Tests\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @group time-sensitive
Expand Down Expand Up @@ -81,7 +81,7 @@ public function setUp(): void

public function testConstructWillSetParameters(): void
{
self::assertSame($this->documentManager, $this->instance->getDocumentManager());
self::assertObjectPropertySame($this->documentManager, $this->instance, 'dm');
self::assertSame($this->className, $this->instance->getClass());
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/Document/ClientManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
use FOS\OAuthServerBundle\Document\ClientManager;
use FOS\OAuthServerBundle\Model\ClientInterface;
use FOS\OAuthServerBundle\Tests\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function random_bytes;
use stdClass;

Expand Down Expand Up @@ -79,8 +79,8 @@ public function setUp(): void

public function testConstructWillSetParameters(): void
{
self::assertSame($this->documentManager, $this->instance->getDocumentManager());
self::assertSame($this->repository, $this->instance->getRepository());
self::assertObjectPropertySame($this->documentManager, $this->instance, 'dm');
self::assertObjectPropertySame($this->repository, $this->instance, 'repository');
self::assertSame($this->className, $this->instance->getClass());
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Entity/AuthCodeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Doctrine\ORM\QueryBuilder;
use FOS\OAuthServerBundle\Entity\AuthCodeManager;
use FOS\OAuthServerBundle\Model\AuthCodeInterface;
use FOS\OAuthServerBundle\Tests\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @group time-sensitive
Expand Down Expand Up @@ -62,7 +62,7 @@ public function setUp(): void

public function testConstructWillSetParameters(): void
{
self::assertSame($this->entityManager, $this->instance->getEntityManager());
self::assertObjectPropertySame($this->entityManager, $this->instance, 'em');
self::assertSame($this->className, $this->instance->getClass());
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/Entity/ClientManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Doctrine\ORM\EntityRepository;
use FOS\OAuthServerBundle\Entity\ClientManager;
use FOS\OAuthServerBundle\Model\ClientInterface;
use FOS\OAuthServerBundle\Tests\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function random_bytes;

/**
Expand Down Expand Up @@ -74,8 +74,8 @@ public function setUp(): void

public function testConstructWillSetParameters(): void
{
self::assertSame($this->entityManager, $this->instance->getEntityManager());
self::assertSame($this->repository, $this->instance->getRepository());
self::assertObjectPropertySame($this->entityManager, $this->instance, 'em');
self::assertObjectPropertySame($this->repository, $this->instance, 'repository');
self::assertSame($this->className, $this->instance->getClass());
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/Entity/TokenManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use FOS\OAuthServerBundle\Entity\AccessToken;
use FOS\OAuthServerBundle\Entity\TokenManager;
use FOS\OAuthServerBundle\Model\TokenInterface;
use FOS\OAuthServerBundle\Tests\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function random_bytes;

/**
Expand Down Expand Up @@ -78,8 +78,8 @@ public function setUp(): void

public function testConstructWillSetParameters(): void
{
self::assertSame($this->entityManager, $this->instance->getEntityManager());
self::assertSame($this->repository, $this->instance->getRepository());
self::assertObjectPropertySame($this->entityManager, $this->instance, 'em');
self::assertObjectPropertySame($this->repository, $this->instance, 'repository');
self::assertSame($this->className, $this->instance->getClass());
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/Form/Handler/AuthorizeFormHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use FOS\OAuthServerBundle\Form\Handler\AuthorizeFormHandler;
use FOS\OAuthServerBundle\Form\Model\Authorize;
use FOS\OAuthServerBundle\Tests\TestCase;
use InvalidArgumentException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function random_bytes;
use ReflectionException;
use ReflectionMethod;
Expand Down Expand Up @@ -476,7 +476,7 @@ protected function getReflectionMethod(string $methodName): ReflectionMethod
*/
private function assertAttributesWereSet(?MockObject $request): void
{
self::assertSame($this->form, $this->instance->getForm());
self::assertSame($request, $this->instance->getRequest());
self::assertObjectPropertySame($this->form, $this->instance, 'form');
self::assertObjectPropertySame($request, $this->instance, 'requestStack');
}
}
33 changes: 32 additions & 1 deletion Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,37 @@

namespace FOS\OAuthServerBundle\Tests;

class TestCase extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase as BaseTestCase;
use ReflectionClass;

class TestCase extends BaseTestCase
{
/**
* Assert sameness to the value of an object's private or protected member.
*
* @param mixed $expected
* @param object $object
* @param string $property
*/
protected static function assertObjectPropertySame($expected, object $object, string $property): void
{
self::assertSame($expected, self::getProtectedMemberValue($object, $property));
}

/**
* Get the value of an object's private or protected member.
*
* @param object $object
* @param string $property
*
* @return mixed
*/
protected static function getProtectedMemberValue(object $object, string $property)
{
$reflectionClass = new ReflectionClass($object);
$reflectionProperty = $reflectionClass->getProperty($property);
$reflectionProperty->setAccessible(true);

return $reflectionProperty->getValue($object);
}
}