fix test deprecations
This commit is contained in:
@@ -50,6 +50,7 @@ class MapTest extends TestCase
|
||||
private $table;
|
||||
private $metadataProvider;
|
||||
private $cacheKeyProvider;
|
||||
private $dataCache;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
||||
@@ -29,73 +29,48 @@
|
||||
|
||||
namespace tests\unit\Espo\Core;
|
||||
|
||||
use Espo\Core\{
|
||||
Acl\Permission,
|
||||
AclManager,
|
||||
Acl\Table,
|
||||
Acl\AccessChecker\AccessCheckerFactory,
|
||||
Acl\OwnershipChecker\OwnershipCheckerFactory,
|
||||
Acl\OwnerUserFieldProvider,
|
||||
Acl\Table\TableFactory,
|
||||
Acl\GlobalRestriction,
|
||||
Acl\Map\MapFactory,
|
||||
ORM\EntityManager};
|
||||
use Espo\Core\Acl\AccessChecker\AccessCheckerFactory;
|
||||
use Espo\Core\Acl\GlobalRestriction;
|
||||
use Espo\Core\Acl\Map\MapFactory;
|
||||
use Espo\Core\Acl\OwnershipChecker\OwnershipCheckerFactory;
|
||||
use Espo\Core\Acl\OwnerUserFieldProvider;
|
||||
use Espo\Core\Acl\Permission;
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Acl\Table\TableFactory;
|
||||
use Espo\Core\AclManager;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
use Espo\Entities\{
|
||||
User,
|
||||
};
|
||||
use Espo\Entities\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AclManagerTest extends \PHPUnit\Framework\TestCase
|
||||
class AclManagerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var AclManager
|
||||
*/
|
||||
/** @var AclManager */
|
||||
private $aclManager;
|
||||
|
||||
/**
|
||||
* @var AccessCheckerFactory
|
||||
*/
|
||||
private $accessCheckerFactory;
|
||||
|
||||
/**
|
||||
* @var OwnershipCheckerFactory
|
||||
*/
|
||||
private $ownershipCheckerFactory;
|
||||
|
||||
/**
|
||||
* @var TableFactory
|
||||
*/
|
||||
/** @var TableFactory */
|
||||
private $tableFactory;
|
||||
|
||||
/**
|
||||
* @var GlobalRestriction
|
||||
*/
|
||||
private $globalRestriction;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
private $mapFactory;
|
||||
private $table;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->user = $this->createMock(User::class);
|
||||
$this->table = $this->createMock(Table::class);
|
||||
|
||||
$this->accessCheckerFactory = $this->createMock(AccessCheckerFactory::class);
|
||||
$this->ownershipCheckerFactory = $this->createMock(OwnershipCheckerFactory::class);
|
||||
$accessCheckerFactory = $this->createMock(AccessCheckerFactory::class);
|
||||
$ownershipCheckerFactory = $this->createMock(OwnershipCheckerFactory::class);
|
||||
$this->tableFactory = $this->createMock(TableFactory::class);
|
||||
$this->mapFactory = $this->createMock(MapFactory::class);
|
||||
$this->globalRestriction = $this->createMock(GlobalRestriction::class);
|
||||
$mapFactory = $this->createMock(MapFactory::class);
|
||||
$globalRestriction = $this->createMock(GlobalRestriction::class);
|
||||
|
||||
$this->aclManager = new AclManager(
|
||||
$this->accessCheckerFactory,
|
||||
$this->ownershipCheckerFactory,
|
||||
$accessCheckerFactory,
|
||||
$ownershipCheckerFactory,
|
||||
$this->tableFactory,
|
||||
$this->mapFactory,
|
||||
$this->globalRestriction,
|
||||
$mapFactory,
|
||||
$globalRestriction,
|
||||
$this->createMock(OwnerUserFieldProvider::class),
|
||||
$this->createMock(EntityManager::class)
|
||||
);
|
||||
|
||||
@@ -29,19 +29,17 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Api;
|
||||
|
||||
use Psr\Http\Message\{
|
||||
ServerRequestInterface as Psr7Request,
|
||||
StreamInterface,
|
||||
};
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ServerRequestInterface as Psr7Request;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Slim\Psr7\Factory\RequestFactory;
|
||||
|
||||
use Espo\Core\Api\RequestWrapper;
|
||||
|
||||
class RequestTest extends \PHPUnit\Framework\TestCase
|
||||
class RequestTest extends TestCase
|
||||
{
|
||||
private $request;
|
||||
|
||||
protected function setUp() : void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->request = $this->getMockBuilder(Psr7Request::class)->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ use Espo\Core\Binding\ContextualBinder;
|
||||
use Espo\Core\Binding\Key\NamedClassKey;
|
||||
use Espo\Core\Binding\Key\NamedKey;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
use ReflectionParameter;
|
||||
use ReflectionNamedType;
|
||||
@@ -50,25 +51,24 @@ use tests\unit\testClasses\Core\Binding\SomeInterface2;
|
||||
use tests\unit\testClasses\Core\Binding\SomeClass1;
|
||||
use tests\unit\testClasses\Core\Binding\SomeClass2;
|
||||
|
||||
class BindingContainerTest extends \PHPUnit\Framework\TestCase
|
||||
class BindingContainerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Binder
|
||||
*/
|
||||
/** @var Binder */
|
||||
private $binder;
|
||||
private $loader;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->loader = $this->createMock(BindingLoader::class);
|
||||
|
||||
$this->data = new BindingData();
|
||||
$data = new BindingData();
|
||||
|
||||
$this->binder = new Binder($this->data);
|
||||
$this->binder = new Binder($data);
|
||||
|
||||
$this->loader
|
||||
->expects($this->any())
|
||||
->method('load')
|
||||
->willReturn($this->data);
|
||||
->willReturn($data);
|
||||
}
|
||||
|
||||
protected function createClassMock(string $className) : ReflectionClass
|
||||
|
||||
@@ -45,6 +45,8 @@ class CommandManagerTest extends TestCase
|
||||
private ?Metadata $metadata = null;
|
||||
private ?CommandManager $manager = null;
|
||||
|
||||
private $command;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->injectableFactory = $this->createMock(InjectableFactory::class);
|
||||
|
||||
@@ -36,6 +36,9 @@ use RuntimeException;
|
||||
|
||||
class CurrencyConfigDataProviderTest extends TestCase
|
||||
{
|
||||
private $config;
|
||||
private $provider;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->config = $this->createMock(Config::class);
|
||||
|
||||
@@ -29,32 +29,24 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Field\EmailAddress;
|
||||
|
||||
use Espo\Core\{
|
||||
Field\EmailAddress\EmailAddressGroupFactory,
|
||||
Utils\Metadata,
|
||||
};
|
||||
use Espo\Core\Field\EmailAddress\EmailAddressGroupFactory;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\ORM\{
|
||||
EntityManager,
|
||||
Entity,
|
||||
};
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Repositories\EmailAddress as EmailAddressRepository;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
class EmailAddressGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
class EmailAddressGroupFactoryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Metadata
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var EmailAddressRepository
|
||||
*/
|
||||
@@ -69,13 +61,13 @@ class EmailAddressGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->metadata = $this->createMock(Metadata::class);
|
||||
|
||||
$this->entityManager = $this->createMock(EntityManager::class);
|
||||
$entityManager = $this->createMock(EntityManager::class);
|
||||
|
||||
$this->emailAddressRepository = $this->createMock(EmailAddressRepository::class);
|
||||
|
||||
$this->factory = new EmailAddressGroupFactory($this->metadata, $this->entityManager);
|
||||
$this->factory = new EmailAddressGroupFactory($this->metadata, $entityManager);
|
||||
|
||||
$this->entityManager
|
||||
$entityManager
|
||||
->expects($this->any())
|
||||
->method('getRepository')
|
||||
->with('EmailAddress')
|
||||
@@ -175,20 +167,20 @@ class EmailAddressGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$entity
|
||||
->method('has')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', false],
|
||||
['test', true],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$entity
|
||||
->method('get')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', null],
|
||||
['test', 'ONE@test.com'],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$group = $this->factory->createFromEntity($entity, 'test');
|
||||
@@ -294,20 +286,20 @@ class EmailAddressGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$entity
|
||||
->method('has')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', false],
|
||||
['test', true],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$entity
|
||||
->method('get')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', null],
|
||||
['test', null],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$group = $this->factory->createFromEntity($entity, 'test');
|
||||
|
||||
@@ -175,20 +175,20 @@ class PhoneNumberGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$entity
|
||||
->method('has')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', false],
|
||||
['test', true],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$entity
|
||||
->method('get')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', null],
|
||||
['test', '+1'],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$group = $this->factory->createFromEntity($entity, 'test');
|
||||
@@ -296,20 +296,20 @@ class PhoneNumberGroupFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$entity
|
||||
->method('has')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', false],
|
||||
['test', true],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$entity
|
||||
->method('get')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['testData', null],
|
||||
['test', null],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$group = $this->factory->createFromEntity($entity, 'test');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php /** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -27,6 +28,8 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
namespace tests\unit\Espo\Core\Formula;
|
||||
|
||||
use Espo\Core\Binding\BindingContainerBuilder;
|
||||
@@ -43,7 +46,6 @@ use Espo\Core\Utils\FieldUtil;
|
||||
use Espo\Core\Utils\NumberUtil;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Log;
|
||||
use Espo\Core\Repositories\Database as DatabaseRepository;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity as Entity;
|
||||
@@ -57,25 +59,29 @@ use tests\unit\ContainerMocker;
|
||||
|
||||
class FormulaTest extends TestCase
|
||||
{
|
||||
private $entity;
|
||||
private $entityManager;
|
||||
private $applicationConfig;
|
||||
private $container;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->entity = $this->getEntityMock();
|
||||
$this->entityManager = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->getMock();
|
||||
$this->repository = $this->getMockBuilder(DatabaseRepository::class)->disableOriginalConstructor()->getMock();
|
||||
$this->entityManager = $this->createMock(EntityManager::class);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
$this->dateTime = new DateTime();
|
||||
$dateTime = new DateTime();
|
||||
|
||||
$this->number = new NumberUtil();
|
||||
$number = new NumberUtil();
|
||||
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->config
|
||||
$config = $this->createMock(Config::class);
|
||||
$config
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap([
|
||||
->willReturnMap([
|
||||
['timeZone', null, 'UTC']
|
||||
]));
|
||||
]);
|
||||
|
||||
$this->applicationConfig = $this->createMock(Config\ApplicationConfig::class);
|
||||
$this->applicationConfig
|
||||
@@ -83,29 +89,27 @@ class FormulaTest extends TestCase
|
||||
->method('getTimeZone')
|
||||
->willReturn('UTC');
|
||||
|
||||
$this->user = $this->getMockBuilder(User::class)->disableOriginalConstructor()->getMock();
|
||||
$user = $this->createMock(User::class);
|
||||
$log = $this->createMock(Log::class);
|
||||
|
||||
$this->log = $this->getMockBuilder(Log::class)->disableOriginalConstructor()->getMock();
|
||||
$user->set('id', '1');
|
||||
|
||||
$this->user->set('id', '1');
|
||||
|
||||
$this->user
|
||||
$user
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap([
|
||||
->willReturnMap([
|
||||
['id', '1']
|
||||
]));
|
||||
|
||||
]);
|
||||
|
||||
$containerMocker = new ContainerMocker($this);
|
||||
|
||||
$this->container = $containerMocker->create([
|
||||
'entityManager' => $this->entityManager,
|
||||
'dateTime' => $this->dateTime,
|
||||
'number' => $this->number,
|
||||
'config' => $this->config,
|
||||
'user' => $this->user,
|
||||
'log' => $this->log,
|
||||
'dateTime' => $dateTime,
|
||||
'number' => $number,
|
||||
'config' => $config,
|
||||
'user' => $user,
|
||||
'log' => $log,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -173,7 +177,7 @@ class FormulaTest extends TestCase
|
||||
$entity
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap($map));
|
||||
->willReturnMap($map);
|
||||
}
|
||||
|
||||
protected function setEntityFetchedAttributes($entity, $attributes)
|
||||
@@ -186,7 +190,7 @@ class FormulaTest extends TestCase
|
||||
$entity
|
||||
->expects($this->any())
|
||||
->method('getFetched')
|
||||
->will($this->returnValueMap($map));
|
||||
->willReturnMap($map);
|
||||
}
|
||||
|
||||
function testAttribute()
|
||||
@@ -274,7 +278,7 @@ class FormulaTest extends TestCase
|
||||
$this->entity
|
||||
->expects($this->once())
|
||||
->method('isAttributeChanged')
|
||||
->will($this->returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
$result = $this->createProcessor()->process($item);
|
||||
|
||||
@@ -302,7 +306,7 @@ class FormulaTest extends TestCase
|
||||
$this->entity
|
||||
->expects($this->once())
|
||||
->method('isAttributeChanged')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$result = $this->createProcessor()->process($item);
|
||||
|
||||
|
||||
@@ -27,20 +27,26 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
namespace tests\unit\Espo\Core\Formula;
|
||||
|
||||
use Espo\Core\Formula\Exceptions\SyntaxError;
|
||||
use Espo\Core\Formula\Parser;
|
||||
use Espo\Core\Formula\Parser\Ast\Attribute;
|
||||
use Espo\Core\Formula\Parser\Ast\Node;
|
||||
use Espo\Core\Formula\Parser\Ast\Value;
|
||||
use Espo\Core\Formula\Parser\Ast\Variable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
|
||||
class ParserTest extends \PHPUnit\Framework\TestCase
|
||||
class ParserTest extends TestCase
|
||||
{
|
||||
private $parser;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->parser = new \Espo\Core\Formula\Parser();
|
||||
$this->parser = new Parser();
|
||||
}
|
||||
|
||||
private function parse(string $expression): stdClass
|
||||
|
||||
@@ -44,12 +44,14 @@ use Espo\Core\Utils\Module\PathProvider;
|
||||
|
||||
class HookManagerTest extends TestCase
|
||||
{
|
||||
private $hookManager;
|
||||
|
||||
private $filesPath = 'tests/unit/testData/Hooks';
|
||||
|
||||
private ?Config\SystemConfig $systemConfig = null;
|
||||
|
||||
private $pathProvider;
|
||||
private $reflection;
|
||||
private $metadata;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->metadata = $this->createMock(Metadata::class);
|
||||
@@ -57,24 +59,24 @@ class HookManagerTest extends TestCase
|
||||
|
||||
$this->systemConfig = $this->createMock(Config\SystemConfig::class);
|
||||
|
||||
$this->injectableFactory = $this->createMock(InjectableFactory::class);
|
||||
$this->dataCache = $this->createMock(DataCache::class);
|
||||
$this->fileManager = new FileManager();
|
||||
$injectableFactory = $this->createMock(InjectableFactory::class);
|
||||
$dataCache = $this->createMock(DataCache::class);
|
||||
$fileManager = new FileManager();
|
||||
$this->pathProvider = $this->createMock(PathProvider::class);
|
||||
$this->generalInvoker = $this->createMock(GeneralInvoker::class);
|
||||
$generalInvoker = $this->createMock(GeneralInvoker::class);
|
||||
|
||||
$this->hookManager = new HookManager(
|
||||
$this->injectableFactory,
|
||||
$this->fileManager,
|
||||
$hookManager = new HookManager(
|
||||
$injectableFactory,
|
||||
$fileManager,
|
||||
$this->metadata,
|
||||
$this->dataCache,
|
||||
$dataCache,
|
||||
$this->createMock(Log::class),
|
||||
$this->pathProvider,
|
||||
$this->generalInvoker,
|
||||
$generalInvoker,
|
||||
$this->systemConfig,
|
||||
);
|
||||
|
||||
$this->reflection = new ReflectionHelper($this->hookManager);
|
||||
$this->reflection = new ReflectionHelper($hookManager);
|
||||
}
|
||||
|
||||
private function initPathProvider(string $folder): void
|
||||
@@ -260,21 +262,21 @@ class HookManagerTest extends TestCase
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->metadata
|
||||
->expects($this->once())
|
||||
->method('getModuleList')
|
||||
->will($this->returnValue(array(
|
||||
->willReturn([
|
||||
'Crm',
|
||||
'Test',
|
||||
)));
|
||||
]);
|
||||
|
||||
$this->reflection->invokeMethod('loadHooks');
|
||||
|
||||
$result = array (
|
||||
$result = [
|
||||
'Note' =>
|
||||
array (
|
||||
[
|
||||
'beforeSave' =>
|
||||
[
|
||||
[
|
||||
@@ -282,8 +284,8 @@ class HookManagerTest extends TestCase
|
||||
'order' => 7,
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($result, $this->reflection->getProperty('data'));
|
||||
}
|
||||
@@ -295,31 +297,31 @@ class HookManagerTest extends TestCase
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->metadata
|
||||
->expects($this->once())
|
||||
->method('getModuleList')
|
||||
->will($this->returnValue(array(
|
||||
->willReturn([
|
||||
'Crm',
|
||||
'Test',
|
||||
)));
|
||||
]);
|
||||
|
||||
$this->reflection->invokeMethod('loadHooks');
|
||||
|
||||
$result = array (
|
||||
$result = [
|
||||
'Note' =>
|
||||
array (
|
||||
[
|
||||
'beforeSave' =>
|
||||
array (
|
||||
array (
|
||||
[
|
||||
[
|
||||
'className' =>
|
||||
'tests\\unit\\testData\\Hooks\\testCase2\\application\\Espo\\Modules\\Crm\\Hooks\\Note\\Mentions',
|
||||
'order' => 9,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($result, $this->reflection->getProperty('data'));
|
||||
}
|
||||
@@ -331,31 +333,31 @@ class HookManagerTest extends TestCase
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->metadata
|
||||
->expects($this->once())
|
||||
->method('getModuleList')
|
||||
->will($this->returnValue(array(
|
||||
->willReturn([
|
||||
'Test',
|
||||
'Crm',
|
||||
)));
|
||||
]);
|
||||
|
||||
$this->reflection->invokeMethod('loadHooks');
|
||||
|
||||
$result = array (
|
||||
$result = [
|
||||
'Note' =>
|
||||
array (
|
||||
[
|
||||
'beforeSave' =>
|
||||
array (
|
||||
array (
|
||||
[
|
||||
[
|
||||
'className' =>
|
||||
'tests\\unit\\testData\\Hooks\\testCase2\\application\\Espo\\Modules\\Test\\Hooks\\Note\\Mentions',
|
||||
'order' => 9,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($result, $this->reflection->getProperty('data'));
|
||||
}
|
||||
@@ -367,13 +369,12 @@ class HookManagerTest extends TestCase
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
->willReturn(false);
|
||||
|
||||
$this->metadata
|
||||
->expects($this->once())
|
||||
->method('getModuleList')
|
||||
->will($this->returnValue(array(
|
||||
)));
|
||||
->willReturn([]);
|
||||
|
||||
$this->reflection->invokeMethod('loadHooks');
|
||||
|
||||
|
||||
@@ -29,13 +29,12 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Job;
|
||||
|
||||
use Espo\Core\{
|
||||
Job\QueuePortionNumberProvider,
|
||||
Job\QueueName,
|
||||
Utils\Config,
|
||||
};
|
||||
use Espo\Core\Job\QueueName;
|
||||
use Espo\Core\Job\QueuePortionNumberProvider;
|
||||
use Espo\Core\Utils\Config;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class QueuePortionNumberProviderTest extends \PHPUnit\Framework\TestCase
|
||||
class QueuePortionNumberProviderTest extends TestCase
|
||||
{
|
||||
private $config;
|
||||
|
||||
@@ -58,13 +57,13 @@ class QueuePortionNumberProviderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->config
|
||||
->method('get')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['jobQ0MaxPortion', null, 201],
|
||||
['jobQ1MaxPortion', null, 501],
|
||||
['jobE0MaxPortion', null, 101],
|
||||
['jobTestDefaultMaxPortion', null, 301]
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$provider = new QueuePortionNumberProvider($this->config);
|
||||
|
||||
@@ -36,10 +36,11 @@ use Espo\Core\Log\Handler\EspoRotatingFileHandler;
|
||||
use Espo\Core\Log\HandlerListLoader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class HandlerListLoaderTest extends TestCase
|
||||
{
|
||||
private $injectableFactory;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->injectableFactory = $this->getMockBuilder(InjectableFactory::class)
|
||||
|
||||
@@ -33,15 +33,18 @@ use Espo\Entities\Email;
|
||||
use Espo\Entities\EmailFilter;
|
||||
use Espo\Core\Mail\FiltersMatcher;
|
||||
use Espo\ORM\EntityManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FiltersMatcherTest extends \PHPUnit\Framework\TestCase
|
||||
class FiltersMatcherTest extends TestCase
|
||||
{
|
||||
private $object;
|
||||
private $entityManager;
|
||||
private $emailDefs;
|
||||
private $filterDefs;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->object = new FiltersMatcher();
|
||||
|
||||
$this->entityManager = $this->createMock(EntityManager::class);
|
||||
|
||||
$this->emailDefs = [
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Mail;
|
||||
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Entities\Email;
|
||||
|
||||
use Espo\Core\Notification\AssignmentNotificator;
|
||||
|
||||
use Espo\ORM\Metadata;
|
||||
use Espo\ORM\Value\ValueAccessor;
|
||||
use Espo\ORM\Value\ValueAccessorFactory;
|
||||
use Espo\Core\FieldProcessing\Relation\LinkMultipleSaver;
|
||||
@@ -47,14 +47,23 @@ use Espo\Core\Notification\AssignmentNotificatorFactory;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Repositories\Database;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\ORM\Repository\RDBSelectBuilder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ImporterTest extends TestCase
|
||||
{
|
||||
protected $emailRepository;
|
||||
private $emailRepository;
|
||||
private $config;
|
||||
private $assignmentNotificatorFactory;
|
||||
private $parserFactory;
|
||||
private $linkMultipleSaver;
|
||||
private $parentFinder;
|
||||
private $jobSchedulerFactory;
|
||||
private $duplicateFinder;
|
||||
private $email;
|
||||
private $repositoryMap;
|
||||
private $entityManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@@ -78,38 +87,36 @@ class ImporterTest extends TestCase
|
||||
$this->parserFactory
|
||||
->expects($this->any())
|
||||
->method('create')
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function () {
|
||||
return new MailMimeParser($this->entityManager);
|
||||
}
|
||||
)
|
||||
->willReturnCallback(
|
||||
function () {
|
||||
return new MailMimeParser($this->entityManager);
|
||||
}
|
||||
);
|
||||
|
||||
$emailRepository
|
||||
->expects($this->any())
|
||||
->method('where')
|
||||
->will($this->returnValue($selectBuilder));
|
||||
->willReturn($selectBuilder);
|
||||
|
||||
$emailRepository
|
||||
->expects($this->any())
|
||||
->method('select')
|
||||
->will($this->returnValue($selectBuilder));
|
||||
->willReturn($selectBuilder);
|
||||
|
||||
$entityManager
|
||||
->expects($this->any())
|
||||
->method('getMetadata')
|
||||
->will($this->returnValue($metadata));
|
||||
->willReturn($metadata);
|
||||
|
||||
$metadata
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue(null));
|
||||
->willReturn(null);
|
||||
|
||||
$emptyRepository
|
||||
->expects($this->any())
|
||||
->method('where')
|
||||
->will($this->returnValue($selectBuilder));
|
||||
->willReturn($selectBuilder);
|
||||
|
||||
$this->emailRepository = $emailRepository;
|
||||
|
||||
@@ -131,12 +138,10 @@ class ImporterTest extends TestCase
|
||||
);
|
||||
|
||||
$emailDefs = require('tests/unit/testData/Core/Mail/email_defs.php');
|
||||
$attachmentDefs = require('tests/unit/testData/Core/Mail/attachment_defs.php');
|
||||
//$attachmentDefs = require('tests/unit/testData/Core/Mail/attachment_defs.php');
|
||||
|
||||
$this->email = new Email('Email', $emailDefs, $entityManager, $valueAccessorFactory);
|
||||
$attachment = new Attachment('Attachment', $attachmentDefs, $entityManager, $valueAccessorFactory);
|
||||
|
||||
$this->attachment = $attachment;
|
||||
//$attachment = new Attachment('Attachment', $attachmentDefs, $entityManager, $valueAccessorFactory);
|
||||
|
||||
$this->assignmentNotificatorFactory
|
||||
->expects($this->any())
|
||||
@@ -160,7 +165,7 @@ class ImporterTest extends TestCase
|
||||
$entityManager
|
||||
->expects($this->any())
|
||||
->method('getRDBRepositoryByClass')
|
||||
->will($this->returnValueMap($this->repositoryMap));
|
||||
->willReturnMap($this->repositoryMap);
|
||||
|
||||
$entityManager
|
||||
->expects($this->exactly(2))
|
||||
@@ -173,15 +178,15 @@ class ImporterTest extends TestCase
|
||||
$this->emailRepository
|
||||
->expects($this->once())
|
||||
->method('getNew')
|
||||
->will($this->returnValue($email));
|
||||
->willReturn($email);
|
||||
|
||||
$config
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['b2cMode', false]
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$contents = file_get_contents('tests/unit/testData/Core/Mail/test_email_1.eml');
|
||||
@@ -208,10 +213,6 @@ class ImporterTest extends TestCase
|
||||
|
||||
$this->assertEquals('test 3', $email->get('name'));
|
||||
|
||||
//$teamIdList = $email->getLinkMultipleIdList('teams');
|
||||
|
||||
//$this->assertTrue(in_array('teamTestId', $teamIdList));
|
||||
|
||||
$userIdList = $email->getLinkMultipleIdList('users');
|
||||
$this->assertTrue(in_array('userTestId', $userIdList));
|
||||
|
||||
|
||||
@@ -31,8 +31,9 @@ namespace tests\unit\Espo\Core\Record;
|
||||
|
||||
use Espo\Core\Record\CreateParamsFetcher;
|
||||
use Espo\Core\Api\RequestWrapper;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CreateParamsFetcherTest extends \PHPUnit\Framework\TestCase
|
||||
class CreateParamsFetcherTest extends TestCase
|
||||
{
|
||||
public function test1(): void
|
||||
{
|
||||
@@ -45,11 +46,11 @@ class CreateParamsFetcherTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$request
|
||||
->method('getHeader')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['X-Skip-Duplicate-Check', 'true'],
|
||||
['X-Duplicate-Source-Id', null],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$params = (new CreateParamsFetcher())->fetch($request);
|
||||
@@ -67,11 +68,11 @@ class CreateParamsFetcherTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$request
|
||||
->method('getHeader')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['X-Skip-Duplicate-Check', 'false'],
|
||||
['X-Duplicate-Source-Id', null],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$params = (new CreateParamsFetcher())->fetch($request);
|
||||
@@ -102,11 +103,11 @@ class CreateParamsFetcherTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$request
|
||||
->method('getHeader')
|
||||
->will(
|
||||
$this->returnValueMap([
|
||||
->willReturnMap(
|
||||
[
|
||||
['X-Skip-Duplicate-Check', 'TRUE'],
|
||||
['X-Duplicate-Source-Id', null],
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
$params = (new CreateParamsFetcher())->fetch($request);
|
||||
|
||||
@@ -35,11 +35,13 @@ use Espo\Core\Api\RequestWrapper;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Select\Text\MetadataProvider as TextMetadataProvider;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Slim\Psr7\Factory\RequestFactory;
|
||||
|
||||
class SearchParamsFetcherTest extends \PHPUnit\Framework\TestCase
|
||||
class SearchParamsFetcherTest extends TestCase
|
||||
{
|
||||
private $config;
|
||||
private $textMetadataProvider;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user