PMC-913 All existing Unit Tests are running correctly?
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use ProcessMaker\BusinessModel\Language;
|
||||
use System;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Test the ProcessMaker\BusinessModel\Language class.
|
||||
*/
|
||||
class LanguageTest extends \WorkflowTestCase
|
||||
class LanguageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Language
|
||||
@@ -18,18 +22,35 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->setupDB();
|
||||
$this->getBaseUri();
|
||||
$this->object = new Language;
|
||||
$this->translationEnv = PATH_DATA."META-INF".PATH_SEP."translations.env";
|
||||
$this->translationEnv = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
|
||||
file_exists($this->translationEnv) ? unlink($this->translationEnv) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the unit tests.
|
||||
* Get base uri for rest applications.
|
||||
* @return string
|
||||
*/
|
||||
protected function tearDown()
|
||||
private function getBaseUri()
|
||||
{
|
||||
$this->dropDB();
|
||||
$_SERVER = $this->getServerInformation();
|
||||
$baseUri = System::getServerProtocolHost();
|
||||
|
||||
return $baseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server information.
|
||||
* @return object
|
||||
*/
|
||||
private function getServerInformation()
|
||||
{
|
||||
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
|
||||
$content = file_get_contents($pathData);
|
||||
$serverInfo = unserialize($content);
|
||||
|
||||
return $serverInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,14 +75,14 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
public function testGetLanguageListInstalled()
|
||||
{
|
||||
$this->installLanguage('es', __DIR__.'/processmaker.es.po');
|
||||
$this->installLanguage('es', __DIR__ . '/processmaker.es.po');
|
||||
$list = $this->object->getLanguageList();
|
||||
$this->assertCount(2, $list);
|
||||
$this->assertEquals('en', $list[0]['LANG_ID']);
|
||||
$this->assertEquals('English', $list[0]['LANG_NAME']);
|
||||
$this->assertEquals('es-ES', $list[1]['LANG_ID']);
|
||||
$this->assertEquals('Spanish (Spain)', $list[1]['LANG_NAME']);
|
||||
$this->uninstallLanguage('es', __DIR__.'/processmaker.es.po');
|
||||
$this->uninstallLanguage('es', __DIR__ . '/processmaker.es.po');
|
||||
$list2 = $this->object->getLanguageList();
|
||||
$this->assertCount(1, $list2);
|
||||
}
|
||||
@@ -74,7 +95,7 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
private function installLanguage($lanId, $filename)
|
||||
{
|
||||
copy($filename, PATH_CORE.'content/translations/'.basename($filename));
|
||||
copy($filename, PATH_CORE . 'content/translations/' . basename($filename));
|
||||
$language = \LanguagePeer::retrieveByPK($lanId);
|
||||
$language->setLanEnabled(1);
|
||||
$language->save();
|
||||
@@ -89,7 +110,7 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
private function uninstallLanguage($lanId, $filename)
|
||||
{
|
||||
unlink(PATH_CORE.'content/translations/'.basename($filename));
|
||||
unlink(PATH_CORE . 'content/translations/' . basename($filename));
|
||||
$language = \LanguagePeer::retrieveByPK($lanId);
|
||||
$language->setLanEnabled(0);
|
||||
$language->save();
|
||||
|
||||
Reference in New Issue
Block a user