Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type declarations to Tests/ for PHPStan #665

Merged
merged 1 commit into from
Oct 7, 2020
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
3 changes: 3 additions & 0 deletions Tests/DependencyInjection/FOSOAuthServerExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

class FOSOAuthServerExtensionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ContainerBuilder
*/
private $container;

public function setUp()
Expand Down
19 changes: 15 additions & 4 deletions Tests/Form/Handler/AuthorizeFormHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,25 @@
*/
class AuthorizeFormHandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var FormInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $form;

/**
* @var Request&\PHPUnit\Framework\MockObject\MockObject
*/
protected $request;

/**
* @var ParameterBag&\PHPUnit\Framework\MockObject\MockObject
*/
protected $requestQuery;

/**
* @var ParameterBag&\PHPUnit\Framework\MockObject\MockObject
*/
protected $requestRequest;

/**
* @var ContainerInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $container;

/**
Expand Down
3 changes: 3 additions & 0 deletions Tests/Form/Type/AuthorizeFormTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public function testGetBlockPrefix()
$this->assertSame('fos_oauth_server_authorize', $this->instance->getBlockPrefix());
}

/**
* @return array<object>
*/
protected function getTypes()
{
return [
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getCacheDir()
return sys_get_temp_dir().'/FOSOAuthServerBundle/';
}

public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
Expand Down
3 changes: 3 additions & 0 deletions Tests/Functional/BootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function testBoot($env)
}
}

/**
* @return array<mixed>
*/
public function getTestBootData()
{
return [
Expand Down
13 changes: 9 additions & 4 deletions Tests/Functional/TestBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ class User implements UserInterface
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var ?int
*/
protected $id;

/**
* @ORM\Column(type="string")
*
* @var ?string
*/
protected $password;

public function getId()
public function getId(): ?int
{
return $this->id;
}
Expand All @@ -43,26 +47,27 @@ public function getRoles()
return ['ROLE_USER'];
}

public function getPassword()
public function getPassword(): ?string
{
return $this->password;
}

public function setPassword($password)
public function setPassword(?string $password): void
{
$this->password = $password;
}

public function getSalt()
{
return null;
}

public function getUsername()
{
return $this->getId();
}

public function eraseCredentials()
public function eraseCredentials(): void
{
}
}
3 changes: 3 additions & 0 deletions Tests/Functional/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ protected function tearDown(): void
static::$kernel = null;
}

/**
* @param array<mixed> $options
*/
protected static function createKernel(array $options = [])
{
$env = @$options['env'] ?: 'test';
Expand Down
3 changes: 3 additions & 0 deletions Tests/Model/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function testHasExpired($expiresAt, $expect)
$this->assertSame($expect, $token->hasExpired());
}

/**
* @return array<mixed>
*/
public static function getTestHasExpiredData()
{
return [
Expand Down
2 changes: 1 addition & 1 deletion Tests/Security/Authentification/Token/OAuthTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testSetTokenWillSetToken()
;

$this->assertNull($this->instance->setToken($token));
$this->assertAttributeSame($token, 'token', $this->instance);
$this->assertSame($token, $this->instance->getToken());
}

public function testGetTokenWillReturnToken()
Expand Down
12 changes: 12 additions & 0 deletions Tests/Security/Firewall/OAuthListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@

class OAuthListenerTest extends TestCase
{
/**
* @var OAuth2&\PHPUnit\Framework\MockObject\MockObject
*/
protected $serverService;

/**
* @var AuthenticationManagerInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $authManager;

/**
* @var mixed&\PHPUnit\Framework\MockObject\MockObject
*/
protected $securityContext;

/**
* @var RequestEvent&\PHPUnit\Framework\MockObject\MockObject
*/
protected $event;

public function setUp()
Expand Down
41 changes: 34 additions & 7 deletions Tests/Storage/OAuthStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,33 @@

class OAuthStorageTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ClientManagerInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $clientManager;

/**
* @var AccessTokenManagerInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $accessTokenManager;

/**
* @var RefreshTokenManagerInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $refreshTokenManager;

/**
* @var AuthCodeManagerInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $authCodeManager;

/**
* @var UserProviderInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $userProvider;

/**
* @var EncoderFactoryInterface&\PHPUnit\Framework\MockObject\MockObject
*/
protected $encoderFactory;

/**
* @var OAuthStorage
*/
protected $storage;

public function setUp()
Expand Down Expand Up @@ -605,31 +620,43 @@ public function testMarkAuthCodeAsUsedIfAuthCodeNotFound()

class User implements UserInterface
{
/**
* @var string|int
*/
private $username;

/**
* @param string|int $username
*/
public function __construct($username)
{
$this->username = $username;
}

public function getRoles()
{
return [];
}

public function getPassword()
{
return null;
}

public function getSalt()
{
return null;
}

/**
* @return string|int
*/
public function getUsername()
{
return $this->username;
}

public function eraseCredentials()
public function eraseCredentials(): void
{
}
}