Programming Language PHP
Namespace Oro\Component\Testing
Class ReflectionUtil
Method/Function callMethod
Total Examples 3
3 code examples of PHP Oro\Component\Testing\ReflectionUtil::callMethod extracted from open source projects
/**
* Test bad scenario for isCurrentUser
*/
public function testIsCurrentUserFalse()
{
$userMock = $this->createMock(User::class);
$userMock->expects($this->once())
->method('getId')
->willReturn(1);
$this->token->expects($this->any())
->method('getUser')
->willReturn(null);
$this->tokenAccessor->expects($this->once())
->method('getToken')
->willReturn($this->token);
ReflectionUtil::callMethod($this->subscriber, 'isCurrentUser', [$userMock]);
}
public function testSecurityShouldBeMergedCorrectly()
{
$originalConfig = [
[
'access_decision_manager' => [
'strategy' => 'unanimous',
],
'firewalls' => [
'dev' => [
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
'security' => false,
],
'main' => [
'pattern' => '^/',
'provider' => 'chain_provider',
'organization-form-login' => [
'csrf_token_generator' => 'security.csrf.token_manager',
'check_path' => 'oro_user_security_check',
'login_path' => 'oro_user_security_login',
],
'logout' => [
'path' => 'oro_user_security_logout',
],
'organization-remember-me' => [
'key' => '%secret%',
'name' => 'CRMRM',
'lifetime' => 1209600,
'httponly' => true,
],
'anonymous' => false,
],
],
],
[
'firewalls' => [
'main' => [
'organization-http-basic' => [
'realm' => 'Secured REST Area',
],
'provider' => 'oro_user',
'http-basic' => false,
'organization-form-login' => false,
'logout' => false,
'organization-remember-me' => false,
'anonymous' => true,
],
],
'acl' => [
'connection' => 'default',
],
],
];
$additionalConfig = [
'firewalls' => [
'oauth' => [
'resource_owners' => [
'google' => '/login/check-google',
],
],
],
];
$expectedConfig = $originalConfig;
$expectedConfig[0]['firewalls']['oauth'] = $additionalConfig['firewalls']['oauth'];
$containerBuilder = new ExtendedContainerBuilder();
$containerBuilder->setExtensionConfig('security', $originalConfig);
$platformExtension = new OroPlatformExtension();
ReflectionUtil::callMethod(
$platformExtension,
'mergeConfigIntoOne',
[$containerBuilder, 'security', $additionalConfig]
);
$this->assertEquals($expectedConfig, $containerBuilder->getExtensionConfig('security'));
}
/**
* @dataProvider buildDatasourceProvider
*/
public function testBuildDatasource(
DatagridConfiguration $config,
array $dataSources,
?array $expectedException,
bool $processCallExpects = false
): void {
$builder = $this->getBuilder($dataSources);
$grid = $this->createMock(DatagridInterface::class);
foreach ($dataSources as $obj) {
if ($processCallExpects) {
$obj->expects($this->once())
->method('process')
->with($grid);
}
}
if ($expectedException !== null) {
[$name, $message] = $expectedException;
$this->expectException($name);
$this->expectExceptionMessage($message);
}
ReflectionUtil::callMethod($builder, 'buildDataSource', [$grid, $config]);
}