Added support PHPUnit 8

This commit is contained in:
Taras Machyshyn
2019-08-27 14:57:31 +03:00
parent 607ee9a080
commit 1102e9f1e8
34 changed files with 100 additions and 96 deletions
+2 -2
View File
@@ -114,7 +114,7 @@ abstract class BaseTestCase extends \PHPUnit\Framework\TestCase
return $this->espoTester->sendRequest($method, $action, $data);
}
protected function setUp()
protected function setUp() : void
{
$this->beforeSetUp();
@@ -134,7 +134,7 @@ abstract class BaseTestCase extends \PHPUnit\Framework\TestCase
$this->afterStartApplication();
}
protected function tearDown()
protected function tearDown() : void
{
$this->espoTester->terminate();
$this->espoTester = NULL;
@@ -73,22 +73,20 @@ class GeneralTest extends \tests\integration\Core\BaseTestCase
return $upgradeId;
}
/**
* @expectedException \Espo\Core\Exceptions\Error
*/
public function testUninstall()
{
$this->expectException('\\Espo\\Core\\Exceptions\\Error');
$upgradeId = $this->testInstall();
$upgradeManager = new \Espo\Core\UpgradeManager($this->getContainer());
$upgradeManager->uninstall(array('id' => $upgradeId));
}
/**
* @expectedException \Espo\Core\Exceptions\Error
*/
public function testDelete()
{
$this->expectException('\\Espo\\Core\\Exceptions\\Error');
$upgradeId = $this->testInstall();
$upgradeManager = new \Espo\Core\UpgradeManager($this->getContainer());
+4 -6
View File
@@ -45,11 +45,10 @@ class AclTest extends \tests\integration\Core\BaseTestCase
$metadata->save();
}
/**
* @expectedException \Espo\Core\Exceptions\Forbidden
*/
public function testUserAccess()
{
$this->expectException('\\Espo\\Core\\Exceptions\\Forbidden');
$this->createUser('tester', array(
'assignmentPermission' => 'team',
'userPermission' => 'team',
@@ -86,11 +85,10 @@ class AclTest extends \tests\integration\Core\BaseTestCase
$result = $controllerManager->process('Account', 'create', $params, $data, $request);
}
/**
* @expectedException \Espo\Core\Exceptions\Forbidden
*/
public function testPortalUserAccess()
{
$this->expectException('\\Espo\\Core\\Exceptions\\Forbidden');
$newUser = $this->createUser(array(
'userName' => 'tester',
'lastName' => 'tester',
+2 -2
View File
@@ -39,7 +39,7 @@ class CronManagerTest extends \PHPUnit\Framework\TestCase
protected $filesPath= 'tests/unit/testData/EntryPoints';
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\\Espo\\Core\\Container')->disableOriginalConstructor()->getMock();
@@ -67,7 +67,7 @@ class CronManagerTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -40,7 +40,7 @@ class EntryPointManagerTest extends \PHPUnit\Framework\TestCase
protected $filesPath= 'tests/unit/testData/EntryPoints';
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\\Espo\\Core\\Container')->disableOriginalConstructor()->getMock();
@@ -58,7 +58,7 @@ class EntryPointManagerTest extends \PHPUnit\Framework\TestCase
));
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -33,12 +33,12 @@ use \Espo\ORM\Entity;
class EvaluatorTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp() : void
{
$this->evaluator = new \Espo\Core\Formula\Evaluator();
}
protected function tearDown()
protected function tearDown() : void
{
$this->evaluator = null;
}
@@ -102,4 +102,4 @@ class EvaluatorTest extends \PHPUnit\Framework\TestCase
$actual = $this->evaluator->process($expression);
$this->assertEquals(2.5, $actual);
}
}
}
+3 -3
View File
@@ -34,7 +34,7 @@ use \Espo\ORM\Entity;
class FormulaTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp() : void
{
$container = $this->container = $this->getMockBuilder('\\Espo\\Core\\Container')->disableOriginalConstructor()->getMock();
@@ -77,7 +77,7 @@ class FormulaTest extends \PHPUnit\Framework\TestCase
]));
}
protected function tearDown()
protected function tearDown() : void
{
$this->container = null;
$this->functionFactory = null;
@@ -2862,4 +2862,4 @@ class FormulaTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(5, $variables->counter);
$this->assertEquals('hello', $variables->test);
}
}
}
+3 -3
View File
@@ -33,12 +33,12 @@ use \Espo\ORM\Entity;
class ParserTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp() : void
{
$this->parser = new \Espo\Core\Formula\Parser();
}
protected function tearDown()
protected function tearDown() : void
{
$this->parser = null;
}
@@ -784,4 +784,4 @@ class ParserTest extends \PHPUnit\Framework\TestCase
];
$this->assertEquals($expected, $actual);
}
}
}
+3 -3
View File
@@ -39,7 +39,7 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
protected $filesPath = 'tests/unit/testData/Hooks';
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\\Espo\\Core\\Container')->disableOriginalConstructor()->getMock();
@@ -62,7 +62,7 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
$this->reflection = NULL;
@@ -437,4 +437,4 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
'\\Espo\\Hooks\\Note\\Notifications',
);
}
}
}
@@ -41,7 +41,7 @@ class HtmlizerTest extends \PHPUnit\Framework\TestCase
protected $number;
protected function setUp()
protected function setUp() : void
{
date_default_timezone_set('UTC');
@@ -77,7 +77,7 @@ class HtmlizerTest extends \PHPUnit\Framework\TestCase
$this->htmlizer = new \Espo\Core\Htmlizer\Htmlizer($this->fileManager, $this->dateTime, $this->number);
}
protected function tearDown()
protected function tearDown() : void
{
unset($this->htmlizer);
unset($this->fileManager);
@@ -170,4 +170,3 @@ class HtmlizerTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('test', $html);
}
}
@@ -35,7 +35,7 @@ class FiltersMatcherTest extends \PHPUnit\Framework\TestCase
{
protected $object;
protected function setUp()
protected function setUp() : void
{
$this->object = new \Espo\Core\Mail\FiltersMatcher();
@@ -80,7 +80,7 @@ class FiltersMatcherTest extends \PHPUnit\Framework\TestCase
);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
+20 -10
View File
@@ -34,7 +34,7 @@ use \Espo\Entities\Email;
class ImporterTest extends \PHPUnit\Framework\TestCase
{
function setUp()
function setUp() : void
{
$GLOBALS['log'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Log')->disableOriginalConstructor()->getMock();
@@ -126,13 +126,18 @@ class ImporterTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('test 3', $email->get('name'));
$teamIdList = $email->getLinkMultipleIdList('teams');
$this->assertContains('teamTestId', $teamIdList);
$this->assertTrue(in_array('teamTestId', $teamIdList));
$userIdList = $email->getLinkMultipleIdList('users');
$this->assertContains('userTestId', $userIdList);
$this->assertTrue(in_array('userTestId', $userIdList));
$this->assertContains('<br>Admin Test', $email->get('body'));
$this->assertContains('Admin Test', $email->get('bodyPlain'));
if (method_exists($this, 'assertStringContainsString')) { /* PHPUnit 7+ */
$this->assertStringContainsString('<br>Admin Test', $email->get('body'));
$this->assertStringContainsString('Admin Test', $email->get('bodyPlain'));
} else { /* PHPUnit 6 */
$this->assertContains('<br>Admin Test', $email->get('body'));
$this->assertContains('Admin Test', $email->get('bodyPlain'));
}
$this->assertEquals('<e558c4dfc2a0f0d60f5ebff474c97ffc/1466410740/1950@espo>', $email->get('messageId'));
}
@@ -182,14 +187,19 @@ class ImporterTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('test 3', $email->get('name'));
$teamIdList = $email->getLinkMultipleIdList('teams');
$this->assertContains('teamTestId', $teamIdList);
$this->assertTrue(in_array('teamTestId', $teamIdList));
$userIdList = $email->getLinkMultipleIdList('users');
$this->assertContains('userTestId', $userIdList);
$this->assertTrue(in_array('userTestId', $userIdList));
$this->assertContains('<br>Admin Test', $email->get('body'));
$this->assertContains('Admin Test', $email->get('bodyPlain'));
if (method_exists($this, 'assertStringContainsString')) { /* PHPUnit 7+ */
$this->assertStringContainsString('<br>Admin Test', $email->get('body'));
$this->assertStringContainsString('Admin Test', $email->get('bodyPlain'));
} else { /* PHPUnit 6 */
$this->assertContains('<br>Admin Test', $email->get('body'));
$this->assertContains('Admin Test', $email->get('bodyPlain'));
}
$this->assertEquals('<e558c4dfc2a0f0d60f5ebff474c97ffc/1466410740/1950@espo>', $email->get('messageId'));
}
}
}
@@ -33,7 +33,7 @@ use \tests\unit\testData\Entities\Test2;
class BaseTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp() : void
{
$entity = $this->entity = new Test2();
@@ -74,7 +74,7 @@ class BaseTest extends \PHPUnit\Framework\TestCase
$this->user->id = 'test_id';
}
protected function tearDown()
protected function tearDown() : void
{
unset($this->entity);
unset($this->acl);
@@ -54,7 +54,7 @@ class ActionManagerTest extends \PHPUnit\Framework\TestCase
),
);
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\Espo\Core\Container')->disableOriginalConstructor()->getMock();
@@ -63,7 +63,7 @@ class ActionManagerTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -56,7 +56,7 @@ class BaseTest extends \PHPUnit\Framework\TestCase
protected $currentVersion = '11.5.2';
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\Espo\Core\Container')->disableOriginalConstructor()->getMock();
$this->objects['actionManager'] = $this->getMockBuilder('\Espo\Core\Upgrades\ActionManager')->disableOriginalConstructor()->getMock();
@@ -98,7 +98,7 @@ class BaseTest extends \PHPUnit\Framework\TestCase
/* END */
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
+2 -2
View File
@@ -43,7 +43,7 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
protected $systemConfigPath = 'tests/unit/testData/Utils/Config/systemConfig.php';
protected function setUp()
protected function setUp() : void
{
$this->objects['fileManager'] = new \Espo\Core\Utils\File\Manager();
@@ -60,7 +60,7 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
$this->reflection->setProperty('systemConfigPath', $this->systemConfigPath);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -40,7 +40,7 @@ class HelperTest extends \PHPUnit\Framework\TestCase
protected $reflection;
protected function setUp()
protected function setUp() : void
{
$this->objects['config'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Config')->disableOriginalConstructor()->getMock();
@@ -58,7 +58,7 @@ class HelperTest extends \PHPUnit\Framework\TestCase
]));
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -39,7 +39,7 @@ class FieldManagerTest extends \PHPUnit\Framework\TestCase
protected $reflection;
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\\Espo\\Core\\Container')->disableOriginalConstructor()->getMock();
@@ -65,7 +65,7 @@ class FieldManagerTest extends \PHPUnit\Framework\TestCase
$this->reflection->setProperty('metadataHelper', $this->objects['metadataHelper']);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -403,4 +403,4 @@ class FieldManagerTest extends \PHPUnit\Framework\TestCase
);
$this->assertEquals($result, $this->reflection->invokeMethod('normalizeDefs', array('CustomEntity', $input1, $input2)));
}
}
}
@@ -41,7 +41,7 @@ class ClassParserTest extends \PHPUnit\Framework\TestCase
protected $reflection;
protected function setUp()
protected function setUp() : void
{
$this->objects['fileManager'] = new \Espo\Core\Utils\File\Manager();
$this->objects['config'] = $this->getMockBuilder('\Espo\Core\Utils\Config')->disableOriginalConstructor()->getMock();
@@ -52,7 +52,7 @@ class ClassParserTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -42,7 +42,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase
protected $reflection;
protected function setUp()
protected function setUp() : void
{
$this->objects['config'] = $this->getMockBuilder('\Espo\Core\Utils\Config')->disableOriginalConstructor()->getMock();
@@ -51,7 +51,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -506,4 +506,4 @@ class ManagerTest extends \PHPUnit\Framework\TestCase
}
}
}
}
@@ -41,7 +41,7 @@ class PermissionTest extends \PHPUnit\Framework\TestCase
protected $fileList;
protected function setUp()
protected function setUp() : void
{
$this->objects['fileManager'] = $this->getMockBuilder('\Espo\Core\Utils\File\Manager')->disableOriginalConstructor()->getMock();
@@ -67,7 +67,7 @@ class PermissionTest extends \PHPUnit\Framework\TestCase
);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
+3 -3
View File
@@ -33,12 +33,12 @@ use Espo\Core\Utils\Json;
class JsonTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp() : void
{
$GLOBALS['log'] = $this->getMockBuilder('\Espo\Core\Utils\Log')->disableOriginalConstructor()->getMock();
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -81,4 +81,4 @@ class JsonTest extends \PHPUnit\Framework\TestCase
}
?>
?>
+2 -2
View File
@@ -47,7 +47,7 @@ class LanguageTest extends \PHPUnit\Framework\TestCase
'customPath' => 'tests/unit/testData/Utils/I18n/Espo/Custom/Resources/i18n/{language}',
];
protected function setUp()
protected function setUp() : void
{
$this->objects['fileManager'] = new \Espo\Core\Utils\File\Manager();
@@ -69,7 +69,7 @@ class LanguageTest extends \PHPUnit\Framework\TestCase
$this->reflection->setProperty('currentLanguage', 'en_US');
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
+2 -2
View File
@@ -42,7 +42,7 @@ class LayoutTest extends \PHPUnit\Framework\TestCase
protected $filesPath= 'tests/unit/testData/FileManager';
protected function setUp()
protected function setUp() : void
{
$this->objects['fileManager'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\File\\Manager')->disableOriginalConstructor()->getMock();
$this->objects['metadata'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Metadata')->disableOriginalConstructor()->getMock();
@@ -56,7 +56,7 @@ class LayoutTest extends \PHPUnit\Framework\TestCase
) );
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
+3 -3
View File
@@ -45,7 +45,7 @@ class MetadataTest extends \PHPUnit\Framework\TestCase
protected $cacheFile = 'tests/unit/testData/cache/metadata.php';
protected $objCacheFile = 'tests/unit/testData/cache/objMetadata.php';
protected function setUp()
protected function setUp() : void
{
/*copy defaultCacheFile file to cache*/
if (!file_exists($this->cacheFile)) {
@@ -68,7 +68,7 @@ class MetadataTest extends \PHPUnit\Framework\TestCase
$this->reflection->setProperty('objCacheFile', $this->objCacheFile);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object->clearChanges();
$this->object = NULL;
@@ -350,4 +350,4 @@ class MetadataTest extends \PHPUnit\Framework\TestCase
$this->assertObjectHasAttribute('type', $this->object->getObjects('entityDefs.User.fields.name'));
}
}
}
@@ -41,7 +41,7 @@ class PasswordHashTest extends \PHPUnit\Framework\TestCase
protected $salt = 'bdaff81c7b8db54d';
protected function setUp()
protected function setUp() : void
{
$this->objects['config'] = $this->getMockBuilder('\Espo\Core\Utils\Config')->disableOriginalConstructor()->getMock();
@@ -50,7 +50,7 @@ class PasswordHashTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
+3 -3
View File
@@ -39,7 +39,7 @@ class RouteTest extends \PHPUnit\Framework\TestCase
protected $filesPath = 'tests/unit/testData/Routes';
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\\Espo\\Core\\Container')->disableOriginalConstructor()->getMock();
@@ -62,7 +62,7 @@ class RouteTest extends \PHPUnit\Framework\TestCase
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
$this->reflection = NULL;
@@ -392,4 +392,4 @@ class RouteTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($result, $this->reflection->invokeMethod('unify'));
}
}
}
@@ -46,7 +46,7 @@ class ScheduledJobTest extends \PHPUnit\Framework\TestCase
'default' => 'default command',
);
protected function setUp()
protected function setUp() : void
{
$this->objects['container'] = $this->getMockBuilder('\Espo\Core\Container')->disableOriginalConstructor()->getMock();
@@ -68,7 +68,7 @@ class ScheduledJobTest extends \PHPUnit\Framework\TestCase
$this->reflection->setProperty('cronSetup', $this->cronSetup);
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
+3 -3
View File
@@ -39,12 +39,12 @@ class SystemTest extends \PHPUnit\Framework\TestCase
protected $reflection;
protected function setUp()
protected function setUp() : void
{
$this->object = new \Espo\Core\Utils\System();
}
protected function tearDown()
protected function tearDown() : void
{
$this->object = NULL;
}
@@ -99,4 +99,4 @@ class SystemTest extends \PHPUnit\Framework\TestCase
{
$this->assertTrue( (bool) preg_match('/^[0-9\.]+$/', System::getPhpVersion()) );
}
}
}
+2 -2
View File
@@ -413,7 +413,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
);
protected function setUp()
protected function setUp() : void
{
$this->entityManager = $this->getMockBuilder('\Espo\Core\ORM\EntityManager')->disableOriginalConstructor()->getMock();
@@ -429,7 +429,7 @@ class EmailTest extends \PHPUnit\Framework\TestCase
}
protected function tearDown()
protected function tearDown() : void
{
$this->entityManager = null;
$this->repository = null;
+2 -2
View File
@@ -50,7 +50,7 @@ class DBMapperTest extends \PHPUnit\Framework\TestCase
protected $comment;
protected $entityFactory;
protected function setUp()
protected function setUp() : void
{
$this->pdo = $this->createMock('MockPDO');
$this->pdo
@@ -98,7 +98,7 @@ class DBMapperTest extends \PHPUnit\Framework\TestCase
}
protected function tearDown()
protected function tearDown() : void
{
unset($this->pdo, $this->db, $this->post, $this->comment);
}
+2 -2
View File
@@ -47,7 +47,7 @@ class QueryTest extends \PHPUnit\Framework\TestCase
protected $entityFactory;
protected function setUp()
protected function setUp() : void
{
$this->pdo = $this->createMock('MockPDO');
$this->pdo
@@ -81,7 +81,7 @@ class QueryTest extends \PHPUnit\Framework\TestCase
$this->account = new \Espo\Entities\Account();
}
protected function tearDown()
protected function tearDown() : void
{
unset($this->query);
unset($this->pdo);
+2 -2
View File
@@ -36,11 +36,11 @@ require_once 'tests/unit/testData/DB/Entities.php';
class EntityTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp() : void
{
}
protected function tearDown()
protected function tearDown() : void
{
}
+2 -3
View File
@@ -39,7 +39,7 @@ class ImportTest extends \PHPUnit\Framework\TestCase
protected $importService;
protected function setUp()
protected function setUp() : void
{
$this->objects['serviceFactory'] = $this->getMockBuilder('\Espo\Core\ServiceFactory')->disableOriginalConstructor()->getMock();
@@ -61,7 +61,7 @@ class ImportTest extends \PHPUnit\Framework\TestCase
}
protected function tearDown()
protected function tearDown() : void
{
$this->importService = NULL;
}
@@ -72,4 +72,3 @@ class ImportTest extends \PHPUnit\Framework\TestCase
$this->assertTrue(true);
}
}