WordpressAPITest
extends OAuth2ProviderLiveTestAbstract
in package
OAuth2 live API test
Attributes
- #[Group]
- 'providerLiveTest'
- #[Provider]
- \chillerlan\OAuth\Providers\WordPress::class
Table of Contents
Constants
- CACERT = self::PROJECT_ROOT . '/tests/cacert.pem'
- CFGDIR = self::PROJECT_ROOT . '/.config'
- PROJECT_ROOT = __DIR__ . '/../..'
Properties
- $provider : OAuthInterface|UserInfo
- $provider : OAuth2Interface
- $provider : WordPress
- $clientCredentialsScopes : array<string|int, string>
- $dotEnv : DotEnv
- $ENV_IS_CI : bool
- $ENV_PREFIX : string
- $HTTP_CLIENT_FACTORY : string
- $logger : LoggerInterface
- $options : OAuthOptions
- $provider : OAuthInterface
- $providerFactory : OAuthProviderFactory
- $reflection : ReflectionObject
- $storage : OAuthStorageInterface
- $TEST_USER : string
- a test username for live API tests, defined in `.env` as `<$provider::IDENTIFIER>_TESTUSER`
Methods
- testMe() : void
- testMeUnauthorizedAccessException() : void
- testRequestCredentialsToken() : void
- assertMeResponse() : void
- getMockHttpClient() : ClientInterface
- Creates a stupid simple `ClientInterface` that returns the given response instance
- getProviderFQCN() : string
- Returns the fully qualified class name (FQCN) of the test subject
- getReflectionProperty() : mixed
- Returns the current value of the given propertyin the current provider instance
- getTestToken() : AccessToken
- Creates a test access token with the given parameters or a set of defaults
- initConfig() : void
- Initializes the environment config (from `phpunit.xml`)
- initOptions() : OAuthOptions
- Initializes an `OAuthOptions` instance
- initStorage() : OAuthStorageInterface
- Initializes an `OAuthStorageInterface` instance
- invokeReflectionMethod() : mixed
- Invokes a method vith the given arguments in the current provider instance
- setMockResponse() : void
- Sets a custom response in the mock http client and sets the client in the current provider
- setReflectionProperty() : void
- Sets a property in the current provider instance with the given value
- setUp() : void
- Initializes the unit test
Constants
CACERT
protected
mixed
CACERT
= self::PROJECT_ROOT . '/tests/cacert.pem'
CFGDIR
protected
mixed
CFGDIR
= self::PROJECT_ROOT . '/.config'
PROJECT_ROOT
protected
mixed
PROJECT_ROOT
= __DIR__ . '/../..'
Properties
$provider
public
OAuthInterface|UserInfo
$provider
$provider
public
OAuth2Interface
$provider
$provider
public
WordPress
$provider
$clientCredentialsScopes
protected
array<string|int, string>
$clientCredentialsScopes
= []
$dotEnv
protected
DotEnv
$dotEnv
$ENV_IS_CI
protected
bool
$ENV_IS_CI
$ENV_PREFIX
protected
string
$ENV_PREFIX
$HTTP_CLIENT_FACTORY
protected
string
$HTTP_CLIENT_FACTORY
= \chillerlan\OAuthTest\Providers\ProviderLiveTestHttpClientFactory::class
$logger
protected
LoggerInterface
$logger
$options
protected
OAuthOptions
$options
$provider
protected
OAuthInterface
$provider
$providerFactory
protected
OAuthProviderFactory
$providerFactory
$reflection
protected
ReflectionObject
$reflection
$storage
protected
OAuthStorageInterface
$storage
$TEST_USER
a test username for live API tests, defined in `.env` as `<$provider::IDENTIFIER>_TESTUSER`
protected
string
$TEST_USER
= ''
Methods
testMe()
public
testMe() : void
testMeUnauthorizedAccessException()
public
testMeUnauthorizedAccessException() : void
testRequestCredentialsToken()
public
testRequestCredentialsToken() : void
assertMeResponse()
protected
assertMeResponse(AuthenticatedUser $user) : void
Parameters
- $user : AuthenticatedUser
getMockHttpClient()
Creates a stupid simple `ClientInterface` that returns the given response instance
protected
getMockHttpClient(ResponseInterface $response) : ClientInterface
Parameters
- $response : ResponseInterface
Return values
ClientInterfacegetProviderFQCN()
Returns the fully qualified class name (FQCN) of the test subject
protected
final getProviderFQCN() : string
Tags
Return values
stringgetReflectionProperty()
Returns the current value of the given propertyin the current provider instance
protected
final getReflectionProperty(string $property) : mixed
Parameters
- $property : string
getTestToken()
Creates a test access token with the given parameters or a set of defaults
protected
getTestToken([array<string, scalar|null>|null $params = null ]) : AccessToken
Parameters
- $params : array<string, scalar|null>|null = null
Return values
AccessTokeninitConfig()
Initializes the environment config (from `phpunit.xml`)
protected
initConfig() : void
initOptions()
Initializes an `OAuthOptions` instance
protected
initOptions() : OAuthOptions
Return values
OAuthOptionsinitStorage()
Initializes an `OAuthStorageInterface` instance
protected
initStorage(OAuthOptions $options) : OAuthStorageInterface
Parameters
- $options : OAuthOptions
Return values
OAuthStorageInterfaceinvokeReflectionMethod()
Invokes a method vith the given arguments in the current provider instance
protected
final invokeReflectionMethod(string $method[, array<int, mixed> $args = [] ]) : mixed
Parameters
- $method : string
- $args : array<int, mixed> = []
setMockResponse()
Sets a custom response in the mock http client and sets the client in the current provider
protected
setMockResponse(ResponseInterface|StreamInterface $response) : void
Parameters
- $response : ResponseInterface|StreamInterface
setReflectionProperty()
Sets a property in the current provider instance with the given value
protected
final setReflectionProperty(string $property, mixed $value) : void
Parameters
- $property : string
- $value : mixed
setUp()
Initializes the unit test
protected
setUp() : void