EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
fix tests
Yuri Kuznetsovd29ef9d99842
diff --git a/tests/unit/Espo/Core/Utils/File/ClassMapTest.php b/tests/unit/Espo/Core/Utils/File/ClassMapTest.phpindex eebccac1da..9e7e839464 100644--- a/tests/unit/Espo/Core/Utils/File/ClassMapTest.php+++ b/tests/unit/Espo/Core/Utils/File/ClassMapTest.php@@ -104,7 +104,7 @@ class ClassMapTest extends TestCase{$expected = ['Download' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\Download',- 'Test' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\Test',+ 'TestEntry' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\TestEntry','InModule' => 'tests\unit\testData\EntryPoints\Espo\Modules\Crm\EntryPoints\InModule'];@@ -135,7 +135,7 @@ class ClassMapTest extends TestCase$result = ['Download' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\Download',- 'Test' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\Test',+ 'TestEntry' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\TestEntry','InModule' => 'tests\unit\testData\EntryPoints\Espo\Modules\Crm\EntryPoints\InModule',];@@ -195,7 +195,7 @@ class ClassMapTest extends TestCase$result = ['Download' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\Download',- 'Test' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\Test',+ 'TestEntry' => 'tests\unit\testData\EntryPoints\Espo\EntryPoints\TestEntry','InModule' => 'tests\unit\testData\EntryPoints\Espo\Modules\Crm\EntryPoints\InModule',];diff --git a/tests/unit/Espo/Entities/EmailTest.php b/tests/unit/Espo/Entities/EmailTest.phpindex 94fb765ff0..6a0a69c892 100644--- a/tests/unit/Espo/Entities/EmailTest.php+++ b/tests/unit/Espo/Entities/EmailTest.php@@ -29,26 +29,19 @@namespace tests\unit\Espo\Entities;+use Espo\Core\Repositories\Database;use Espo\Entities\Attachment;use Espo\Entities\Email;use Espo\ORM\EntityManager;use Espo\ORM\Repository\RDBRepository;+use PHPUnit\Framework\TestCase;-class EmailTest extends \PHPUnit\Framework\TestCase+class EmailTest extends TestCase{- /**- * @var Email- */+ /** @var Email */private $email;- /**- * @var EntityManager- */- private $entityManager;-- /**- * @var RDBRepository- */+ /** @var RDBRepository */private $attachmentRepository;// TODO defs test helper@@ -437,29 +430,28 @@ class EmailTest extends \PHPUnit\Framework\TestCaseprotected function setUp() : void{- $this->entityManager = $this->createMock(EntityManager::class);+ $entityManager = $this->createMock(EntityManager::class);$this->attachmentRepository = $this->createMock(RDBRepository::class);- $this->entityManager+ $entityManager->expects($this->any())->method('getRDBRepositoryByClass')->willReturnMap([[Attachment::class, $this->attachmentRepository],]);- $this->repository =- $this->getMockBuilder('Espo\Core\ORM\Repositories\Database')->disableOriginalConstructor()->getMock();+ $repository = $this->createMock(Database::class);- $this->entityManager+ $entityManager->expects($this->any())->method('getRepository')- ->will($this->returnValue($this->repository));+ ->willReturn($repository);$this->email = new Email(entityType: 'Email',defs: $this->defs,- entityManager: $this->entityManager,+ entityManager: $entityManager,);}diff --git a/tests/unit/Espo/ORM/Repository/UtilTest.php b/tests/unit/Espo/ORM/Repository/UtilTest.phpindex ff16dcee63..336245faa9 100644--- a/tests/unit/Espo/ORM/Repository/UtilTest.php+++ b/tests/unit/Espo/ORM/Repository/UtilTest.php@@ -32,17 +32,18 @@ namespace tests\unit\Espo\ORM\Repository;use Espo\Modules\Crm\Entities\CaseObj;use Espo\Modules\Crm\Entities\Lead;-use tests\unit\testData\Entities\Test;+use PHPUnit\Framework\TestCase;+use tests\unit\testData\Entities\TestEntity;use Espo\ORM\Repository\Util;-class UtilTest extends \PHPUnit\Framework\TestCase+class UtilTest extends TestCase{public function testGetRDBRepositoryByClass(): void{$this->assertEquals('Lead', Util::getEntityTypeByClass(Lead::class));$this->assertEquals('Case', Util::getEntityTypeByClass(CaseObj::class));- $this->assertEquals('Test', Util::getEntityTypeByClass(Test::class));+ $this->assertEquals('TestEntity', Util::getEntityTypeByClass(TestEntity::class));}public function testGetRDBRepositoryByClassException(): voiddiff --git a/tests/unit/Espo/Tools/FieldManagerTest.php b/tests/unit/Espo/Tools/FieldManagerTest.phpindex 910156cfc4..14da5d9a7d 100644--- a/tests/unit/Espo/Tools/FieldManagerTest.php+++ b/tests/unit/Espo/Tools/FieldManagerTest.php@@ -206,7 +206,7 @@ class FieldManagerTest extends TestCase$this->metadataHelper->expects($this->once())->method('getFieldDefsByType')- ->will($this->returnValue(json_decode('{+ ->willReturn(json_decode('{"params":[{"name":"required",@@ -243,22 +243,22 @@ class FieldManagerTest extends TestCase"personalData": true,"textFilter": true,"fullTextSearch": true- }', true)));+ }', true));$this->metadata->expects($this->any())->method('get')- ->will($this->returnValueMap($map));+ ->willReturnMap($map);$this->metadata->expects($this->exactly(2))->method('getObjects')- ->will($this->returnValue((object) $data));+ ->willReturn((object) $data);$this->metadata->expects($this->exactly(1))->method('getCustom')- ->will($this->returnValue((object) []));+ ->willReturn((object) []);$this->metadata->expects($this->never())@@ -286,22 +286,21 @@ class FieldManagerTest extends TestCase$this->metadata->expects($this->any())->method('get')- ->will($this->returnValueMap($map));+ ->willReturnMap($map);$this->metadata->expects($this->exactly(2))->method('getObjects')- ->will($this->returnValue((object) $data));+ ->willReturn((object) $data);$this->metadata->expects($this->once())- ->method('saveCustom')- ->will($this->returnValue(true));+ ->method('saveCustom');$this->metadataHelper->expects($this->once())->method('getFieldDefsByType')- ->will($this->returnValue(json_decode('{+ ->willReturn(json_decode('{"params":[{"name":"required",@@ -338,7 +337,7 @@ class FieldManagerTest extends TestCase"personalData": true,"textFilter": true,"fullTextSearch": true- }', true)));+ }', true));$data = ["type" => "varchar",@@ -367,12 +366,12 @@ class FieldManagerTest extends TestCase$this->metadata->expects($this->once())->method('getObjects')- ->will($this->returnValue((object) $data));+ ->willReturn((object) $data);$this->language->expects($this->once())->method('translate')- ->will($this->returnValue('Var Name'));+ ->willReturn('Var Name');$this->assertEquals($data, $this->fieldManager->read('Account', 'varName'));}diff --git a/tests/unit/Espo/Tools/MassUpdate/ValueMapPreparatorTest.php b/tests/unit/Espo/Tools/MassUpdate/ValueMapPreparatorTest.phpindex 2288fb7ba7..ae3581a326 100644--- a/tests/unit/Espo/Tools/MassUpdate/ValueMapPreparatorTest.php+++ b/tests/unit/Espo/Tools/MassUpdate/ValueMapPreparatorTest.php@@ -36,12 +36,13 @@ use Espo\Tools\MassUpdate\Action;use Espo\ORM\Entity;use Espo\ORM\Defs as OrmDefs;+use PHPUnit\Framework\TestCase;-class ValueMapPreparatorTest extends \PHPUnit\Framework\TestCase+class ValueMapPreparatorTest extends TestCase{public function testPrepare1(): void{- $preprator = new ValueMapPreparator(+ $preparator = new ValueMapPreparator($this->createMock(OrmDefs::class));@@ -70,8 +71,7 @@ class ValueMapPreparatorTest extends \PHPUnit\Framework\TestCase$entity->expects($this->any())->method('get')- ->will(- $this->returnCallback(+ ->willReturnCallback(function ($attribute) {$map = ['a1' => ['0'],@@ -88,10 +88,9 @@ class ValueMapPreparatorTest extends \PHPUnit\Framework\TestCasereturn $map[$attribute] ?? null;}- ));- $values = $preprator->prepare($entity, $data);+ $values = $preparator->prepare($entity, $data);$this->assertEquals(['0', '1', '2'], $values->a1);$this->assertEquals(['0'], $values->a2);diff --git a/tests/unit/testData/Entities/Test.php b/tests/unit/testData/Entities/TestEntity.phpsimilarity index 56%rename from tests/unit/testData/Entities/Test.phprename to tests/unit/testData/Entities/TestEntity.phpindex 9b22be6755..e22d679f9d 100644--- a/tests/unit/testData/Entities/Test.php+++ b/tests/unit/testData/Entities/TestEntity.php@@ -2,10 +2,7 @@namespace tests\unit\testData\Entities;-use Espo\ORM\Entity;use Espo\ORM\BaseEntity;-class Test extends BaseEntity-{-}-+class TestEntity extends BaseEntity+{}diff --git a/tests/unit/testData/EntryPoints/Espo/EntryPoints/Test.php b/tests/unit/testData/EntryPoints/Espo/EntryPoints/TestEntry.phpsimilarity index 83%rename from tests/unit/testData/EntryPoints/Espo/EntryPoints/Test.phprename to tests/unit/testData/EntryPoints/Espo/EntryPoints/TestEntry.phpindex 05757dc9e9..abd0557ef6 100644--- a/tests/unit/testData/EntryPoints/Espo/EntryPoints/Test.php+++ b/tests/unit/testData/EntryPoints/Espo/EntryPoints/TestEntry.php@@ -2,15 +2,11 @@namespace tests\unit\testData\EntryPoints\Espo\EntryPoints;--class Test+class TestEntry{protected $authRequired = true;public function run()- {--- }+ {}}