Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend
This commit is contained in:
+1
-6
@@ -5,17 +5,12 @@
|
||||
/data/.backup/*
|
||||
/data/config.php
|
||||
/custom
|
||||
/application/Espo/Resources/metadata/scopes/CustomTest.json
|
||||
/application/Espo/Modules/Crm/Resources/metadata/scopes/CustomTest.json
|
||||
/application/Espo/Resources/layouts/CustomTest/*
|
||||
/application/Espo/Modules/Crm/Resources/layouts/CustomTest/*
|
||||
/application/Espo/Resources/metadata/customTest/*
|
||||
/application/Espo/Modules/Crm/Resources/metadata/customTest/*
|
||||
/build
|
||||
/node_modules
|
||||
/client
|
||||
/test.php
|
||||
/main.html
|
||||
/tests/testData/Utils/Config/config.php
|
||||
/tests/testData/*/cache/*
|
||||
composer.phar
|
||||
vendor/
|
||||
|
||||
@@ -150,7 +150,7 @@ class Config
|
||||
|
||||
$removeData = empty($this->removeData) ? null : $this->removeData;
|
||||
|
||||
$result = $this->getFileManager()->mergeContentsPHP($this->configPath, $values, 1, $removeData);
|
||||
$result = $this->getFileManager()->mergeContentsPHP($this->configPath, $values, $removeData);
|
||||
if ($result) {
|
||||
$this->changedData = array();
|
||||
$this->removeData = array();
|
||||
|
||||
@@ -164,8 +164,9 @@ class Converter
|
||||
{
|
||||
$entityDefs = $this->getEntityDefs();
|
||||
|
||||
$currentOrmMeta = $ormMeta;
|
||||
//load custom field definitions and customCodes
|
||||
foreach($ormMeta as $entityName => &$entityParams) {
|
||||
foreach($currentOrmMeta as $entityName => $entityParams) {
|
||||
foreach($entityParams['fields'] as $fieldName => $fieldParams) {
|
||||
|
||||
//load custom field definitions
|
||||
@@ -184,15 +185,15 @@ class Converter
|
||||
}
|
||||
|
||||
$ormMeta = Util::merge($ormMeta, $fieldResult);
|
||||
} //END: load custom field definitions
|
||||
|
||||
} //END: load custom field definitions
|
||||
|
||||
//todo move to separate file
|
||||
//add a field 'isFollowed' for scopes with 'stream => true'
|
||||
$scopeDefs = $this->getMetadata()->get('scopes.'.$entityName);
|
||||
if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
|
||||
if (!isset($entityParams['fields']['isFollowed'])) {
|
||||
$entityParams['fields']['isFollowed'] = array(
|
||||
$ormMeta[$entityName]['fields']['isFollowed'] = array(
|
||||
'type' => 'varchar',
|
||||
'notStorable' => true,
|
||||
);
|
||||
@@ -302,7 +303,7 @@ class Converter
|
||||
{
|
||||
/** set default type if exists */
|
||||
if (!isset($fieldParams['type']) || empty($fieldParams['type'])) {
|
||||
$GLOBALS['log']->warning('Field type does not exist for '.$entityName.':'.$fieldName.'. Use default type ['.$this->defaultFieldType.']');
|
||||
$GLOBALS['log']->debug('Field type does not exist for '.$entityName.':'.$fieldName.'. Use default type ['.$this->defaultFieldType.']');
|
||||
$fieldParams['type'] = $this->defaultFieldType;
|
||||
} /** END: set default type if exists */
|
||||
|
||||
|
||||
@@ -225,13 +225,12 @@ class Manager
|
||||
* @param string | array $path
|
||||
* @param string $content JSON string
|
||||
* @param bool $isJSON
|
||||
* @param string | array $mergeOptions
|
||||
* @param string | array $removeOptions - List of unset keys from content
|
||||
* @param bool $isReturn - Is result to be returned or stored
|
||||
*
|
||||
* @return bool | array
|
||||
*/
|
||||
public function mergeContents($path, $content, $isJSON = false, $mergeOptions = null, $removeOptions = null, $isReturn = false)
|
||||
public function mergeContents($path, $content, $isJSON = false, $removeOptions = null, $isReturn = false)
|
||||
{
|
||||
$fileContent = $this->getContents($path);
|
||||
|
||||
@@ -243,7 +242,7 @@ class Manager
|
||||
$newDataArray = Utils\Util::unsetInArray($newDataArray, $removeOptions);
|
||||
}
|
||||
|
||||
$data = Utils\Util::merge($savedDataArray, $newDataArray, $mergeOptions);
|
||||
$data = Utils\Util::merge($savedDataArray, $newDataArray);
|
||||
if ($isJSON) {
|
||||
$data = Utils\Json::encode($data, JSON_PRETTY_PRINT);
|
||||
}
|
||||
@@ -260,13 +259,12 @@ class Manager
|
||||
*
|
||||
* @param string | array $path
|
||||
* @param string $content JSON string
|
||||
* @param string | array $mergeOptions
|
||||
* @param string | array $removeOptions - List of unset keys from content
|
||||
* @return bool
|
||||
*/
|
||||
public function mergeContentsPHP($path, $content, $mergeOptions = null, $removeOptions = null)
|
||||
public function mergeContentsPHP($path, $content, $removeOptions = null)
|
||||
{
|
||||
$data = $this->mergeContents($path, $content, false, $mergeOptions, $removeOptions, true);
|
||||
$data = $this->mergeContents($path, $content, false, $removeOptions, true);
|
||||
|
||||
return $this->putContentsPHP($path, $data);
|
||||
}
|
||||
|
||||
@@ -38,24 +38,21 @@ class Unifier
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unite file content to the file
|
||||
*
|
||||
* @param [type] $name [description]
|
||||
* @param [type] $paths [description]
|
||||
* @param string $name
|
||||
* @param array $paths
|
||||
* @param boolean $recursively Note: only for first level of sub directory, other levels of sub directories will be ignored
|
||||
* @param [type] $mergeLevel - merge level, see Espo\Core\Utils\Util::merge()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function unify($name, $paths, $recursively = false, $mergeLevel = null, $mergeKeyName = null)
|
||||
public function unify($name, $paths, $recursively = false)
|
||||
{
|
||||
$content = $this->unifySingle($paths['corePath'], $name, $recursively);
|
||||
|
||||
@@ -65,19 +62,17 @@ class Unifier
|
||||
|
||||
foreach ($dirList as $dirName) {
|
||||
$curPath = str_replace('{*}', $dirName, $paths['modulePath']);
|
||||
$content = Utils\Util::merge($content, $this->unifySingle($curPath, $name, $recursively, $dirName), $mergeLevel, $mergeKeyName);
|
||||
$content = Utils\Util::merge($content, $this->unifySingle($curPath, $name, $recursively, $dirName));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($paths['customPath'])) {
|
||||
$content = Utils\Util::merge($content, $this->unifySingle($paths['customPath'], $name, $recursively), $mergeLevel, $mergeKeyName);
|
||||
$content = Utils\Util::merge($content, $this->unifySingle($paths['customPath'], $name, $recursively));
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Unite file content to the file for one directory [NOW ONLY FOR METADATA, NEED TO CHECK FOR LAYOUTS AND OTHERS]
|
||||
*
|
||||
@@ -161,7 +156,7 @@ class Unifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function loadDefaultValues($name, $type='metadata')
|
||||
protected function loadDefaultValues($name, $type = 'metadata')
|
||||
{
|
||||
$defaultPath = $this->params['defaultsPath'];
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ class Language
|
||||
$i18nCacheFile = str_replace('{*}', $i18nName, $this->cacheFile);
|
||||
|
||||
if ($i18nName != $this->defaultLanguage) {
|
||||
$i18nData = Util::merge($this->fullData[$this->defaultLanguage], $i18nData, null, null, true);
|
||||
$i18nData = Util::merge($this->fullData[$this->defaultLanguage], $i18nData);
|
||||
}
|
||||
$result &= $this->getFileManager()->putContentsPHP($i18nCacheFile, $i18nData);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class Metadata
|
||||
{
|
||||
$data = false;
|
||||
if (!file_exists($this->cacheFile) || $reload) {
|
||||
$data = $this->getUnifier()->unify($this->name, $this->paths, true, 5, 'options');
|
||||
$data = $this->getUnifier()->unify($this->name, $this->paths, true);
|
||||
|
||||
if ($data === false) {
|
||||
$GLOBALS['log']->emergency('Metadata:getMetadata() - metadata unite file cannot be created');
|
||||
@@ -246,7 +246,7 @@ class Metadata
|
||||
{
|
||||
$path = $this->paths['customPath'];
|
||||
|
||||
$result = $this->getFileManager()->mergeContents(array($path, $type, $scope.'.json'), $data, true, array(3, 'options'));
|
||||
$result = $this->getFileManager()->mergeContents(array($path, $type, $scope.'.json'), $data, true);
|
||||
if ($result === false) {
|
||||
throw new Error("Error saving metadata. See log file for details.");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class System
|
||||
|
||||
preg_match('/^(.*?)\//i', $serverSoft, $match);
|
||||
if (empty($match[1])) {
|
||||
preg_match('/^(.*?)\/?/i', $serverSoft, $match);
|
||||
preg_match('/^(.*)\/?/i', $serverSoft, $match);
|
||||
}
|
||||
$serverName = strtolower( trim($match[1]) );
|
||||
|
||||
|
||||
@@ -109,103 +109,47 @@ class Util
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge arrays (default PHP function is not suitable)
|
||||
* Merge arrays recursively (default PHP function is not suitable)
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $mainArray - chief array (priority is same as for array_merge())
|
||||
* @param array $rewriteLevel - Merge by rewrite level, level numering starts from 1. Ex.
|
||||
* array(
|
||||
* 'level1' => array(
|
||||
* 'level2' => array(
|
||||
* 'level3' => array(
|
||||
* 'key1' => 'value',
|
||||
* 'key2' => 'value',
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
* )
|
||||
* @param $rewriteKeyName string - Rewrite key name. It is ignored if $rewriteLevel is NULL.
|
||||
* @param $rewriteArrays bool - Rewrite single arrays. Examples:
|
||||
* TRUE: array is [0, 1, 2], main array is [3, 4, 5], Result is [3, 4, 5].
|
||||
* FALSE: array is [0, 1, 2], main array is [3, 4, 5], Result is [0, 1, 2, 3, 4, 5].
|
||||
* @param array $currentArray
|
||||
* @param array $newArray - chief array (priority is same as for array_merge())
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function merge($array, $mainArray, $rewriteLevel = null, $rewriteKeyName = null, $rewriteArrays = false)
|
||||
public static function merge($currentArray, $newArray)
|
||||
{
|
||||
if (is_array($array) && !is_array($mainArray)) {
|
||||
return $array;
|
||||
} else if (!is_array($array) && is_array($mainArray)) {
|
||||
return $mainArray;
|
||||
} else if (!is_array($array) && !is_array($mainArray)) {
|
||||
$mergeIdentifier = '__APPEND__';
|
||||
|
||||
if (is_array($currentArray) && (!is_array($newArray) || empty($newArray))) {
|
||||
return $currentArray;
|
||||
} else if ((!is_array($currentArray) || empty($currentArray)) && is_array($newArray)) {
|
||||
return $newArray;
|
||||
} else if ((!is_array($currentArray) || empty($currentArray)) && (!is_array($newArray) || empty($newArray))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (is_array($rewriteLevel)) {
|
||||
if (isset($rewriteLevel[1])) {
|
||||
$rewriteKeyName = $rewriteLevel[1];
|
||||
}
|
||||
if (isset($rewriteLevel[0])) {
|
||||
$rewriteLevel = $rewriteLevel[0];
|
||||
}
|
||||
}
|
||||
/** add root items from currentArray */
|
||||
foreach ($currentArray as $currentName => $currentValue) {
|
||||
|
||||
foreach($mainArray as $mainKey => $mainValue) {
|
||||
if (!isset($newArray[$currentName])) {
|
||||
|
||||
$found = false;
|
||||
foreach($array as $key => $value) {
|
||||
$newArray[$currentName] = $currentValue;
|
||||
|
||||
if ((string)$mainKey == (string)$key) {
|
||||
} else if (is_array($currentValue) && is_array($newArray[$currentName])) {
|
||||
|
||||
$found = true;
|
||||
if (is_array($mainValue) || is_array($value)) {
|
||||
|
||||
$rowRewriteLevel = $rewriteLevel;
|
||||
|
||||
/** check the $rewriteKeyName */
|
||||
if (isset($rowRewriteLevel) && $rowRewriteLevel == 1 && isset($rewriteKeyName)) {
|
||||
$rewriteKeyName = is_array($rewriteKeyName) ? $rewriteKeyName : (array) $rewriteKeyName;
|
||||
|
||||
if (!in_array((string)$key, $rewriteKeyName)) {
|
||||
$rowRewriteLevel = null;
|
||||
}
|
||||
} /** END: check the $rewriteKeyName */
|
||||
|
||||
if (!isset($rowRewriteLevel) || $rowRewriteLevel != 1) {
|
||||
$array[$mainKey] = static::merge((array) $value, (array) $mainValue, --$rowRewriteLevel, $rewriteKeyName, $rewriteArrays);
|
||||
continue;
|
||||
}
|
||||
|
||||
$mergeValue = array('mergeLevel' => (array) $value);
|
||||
$mergeMainValue = array('mergeLevel' => (array) $mainValue);
|
||||
$mergeRes = array_merge($mergeValue, $mergeMainValue);
|
||||
$array[$mainKey] = $mergeRes['mergeLevel'];
|
||||
continue;
|
||||
}
|
||||
|
||||
/** merge logic */
|
||||
if (!is_numeric($mainKey)) {
|
||||
$array[$mainKey] = $mainValue;
|
||||
}
|
||||
elseif (!in_array($mainValue, $array)) {
|
||||
if ($rewriteArrays) {
|
||||
$array[$mainKey] = $mainValue;
|
||||
} else {
|
||||
$array[] = $mainValue;
|
||||
}
|
||||
} /** END: merge logic */
|
||||
|
||||
break;
|
||||
/** check __APPEND__ identifier */
|
||||
$appendKey = array_search($mergeIdentifier, $newArray[$currentName], true);
|
||||
if ($appendKey !== false) {
|
||||
unset($newArray[$currentName][$appendKey]);
|
||||
$newArray[$currentName] = array_merge($currentValue, $newArray[$currentName]);
|
||||
} else {
|
||||
$newArray[$currentName] = static::merge($currentValue, $newArray[$currentName]);
|
||||
}
|
||||
}
|
||||
/** add an item if key not found */
|
||||
if (!$found) {
|
||||
$array[$mainKey] = $mainValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
return $newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +183,6 @@ class Util
|
||||
return $folderPath . static::getSeparator() . $filePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert array to object format recursively
|
||||
*
|
||||
@@ -255,7 +198,6 @@ class Util
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert object to array format recursively
|
||||
*
|
||||
@@ -285,7 +227,6 @@ class Util
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Naming according to prefix or postfix type
|
||||
*
|
||||
@@ -306,7 +247,6 @@ class Util
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace $search in array recursively
|
||||
*
|
||||
@@ -390,7 +330,6 @@ class Util
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get class name from the file path
|
||||
*
|
||||
@@ -407,7 +346,6 @@ class Util
|
||||
return $className;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return values of defined $key.
|
||||
*
|
||||
@@ -446,15 +384,33 @@ class Util
|
||||
public static function isEquals($var1, $var2)
|
||||
{
|
||||
if (is_array($var1)) {
|
||||
ksort($var1);
|
||||
static::ksortRecursive($var1);
|
||||
}
|
||||
if (is_array($var2)) {
|
||||
ksort($var2);
|
||||
static::ksortRecursive($var2);
|
||||
}
|
||||
|
||||
return ($var1 === $var2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort array recursively
|
||||
* @param array $array
|
||||
* @return bool
|
||||
*/
|
||||
public static function ksortRecursive(&$array)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ksort($array);
|
||||
foreach ($array as $key => $value) {
|
||||
static::ksortRecursive($array[$key]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
"Errors page title": "Errors",
|
||||
"Finish page title": "Installation is complete",
|
||||
"Congratulation! Welcome to EspoCRM": "Congratulation! EspoCRM has been successfully installed.",
|
||||
"More Information": "For more information,<br>please visit our blog: {BLOG}<br>follow us on twitter: {TWITTER}<br><br>If you have any suggestions or questions, please ask on the forum:<br>{FORUM}",
|
||||
"More Information": "For more information, please visit our {BLOG}, follow us on {TWITTER}.<br><br>If you have any suggestions or questions, please ask on the {FORUM}.",
|
||||
"share": "If you like EspoCRM, share it with your friends. Let them know about this great product.",
|
||||
"blog": "blog",
|
||||
"twitter": "twitter",
|
||||
"forum": "forum",
|
||||
"Installation Guide": "Installation Guide",
|
||||
"admin": "admin",
|
||||
"localhost": "localhost",
|
||||
|
||||
@@ -7,10 +7,22 @@
|
||||
{$langs['labels']['Congratulation! Welcome to EspoCRM']}
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="likes">
|
||||
<p>
|
||||
{$langs['labels']['share']}
|
||||
</p>
|
||||
<br>
|
||||
|
||||
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
|
||||
<div class="g-plusone" data-size="standard" data-count="true" data-href='http://www.espocrm.com'></div>
|
||||
</div>
|
||||
|
||||
<div class="more-information">
|
||||
{assign var="blogLink" value="<a target=\"_blank\" href=\"{$config['blog']}\">{$config['blog']}</a>"}
|
||||
{assign var="twitterLink" value="<a target=\"_blank\" href=\"{$config['twitter']}\">{$config['twitter']}</a>"}
|
||||
{assign var="forumLink" value="<a target=\"_blank\" href=\"{$config['forum']}\">{$config['forum']}</a>"}
|
||||
{assign var="blogLink" value="<a target=\"_blank\" href=\"{$config['blog']}\">{$langs['labels']['blog']}</a>"}
|
||||
{assign var="twitterLink" value="<a target=\"_blank\" href=\"{$config['twitter']}\">{$langs['labels']['twitter']}</a>"}
|
||||
{assign var="forumLink" value="<a target=\"_blank\" href=\"{$config['forum']}\">{$langs['labels']['forum']}</a>"}
|
||||
|
||||
{assign var="message" value="{$langs['labels']['More Information']|replace:'{BLOG}':$blogLink}"}
|
||||
{assign var="message" value="{$message|replace:'{TWITTER}':$twitterLink}"}
|
||||
|
||||
+24
-1
@@ -124,6 +124,29 @@ span.ok {
|
||||
.more-information {
|
||||
line-height: 1.5;
|
||||
font-size: 16px;
|
||||
margin-top: 100px;
|
||||
margin-top: 70px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.likes {
|
||||
border-left-color: #D7983B;
|
||||
-moz-border-bottom-colors: none;
|
||||
-moz-border-left-colors: #F1AF4E;
|
||||
-moz-border-right-colors: none;
|
||||
-moz-border-top-colors: none;
|
||||
border-color: #eee;
|
||||
border-image: none;
|
||||
border-radius: 3px;
|
||||
border-style: solid;
|
||||
border-width: 1px 1px 1px 5px;
|
||||
margin: 20px 0;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.likes p {
|
||||
color: #B56F08;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Api;
|
||||
|
||||
class FieldManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $fixture;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$config = include('tests/Api/config.php');
|
||||
if (!$config['apiTestsEnabled']) {
|
||||
$this->markTestSkipped('API tests are not enabled.');
|
||||
}
|
||||
|
||||
require_once('tests/Api/RestTesterClass.php');
|
||||
$this->fixture = new RestTesterClass();
|
||||
|
||||
/****************************************/
|
||||
$this->fixture->setUrl('/Admin/fieldManager');
|
||||
/****************************************/
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->fixture = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$this->fixture->setType('POST');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity');
|
||||
|
||||
$input = '{"name":"customField","type":"varchar","maxLength":50}';
|
||||
$result = '{"type":"varchar","maxLength":50,"isCustom":true}';
|
||||
|
||||
$this->assertEquals($result, $this->fixture->getResponse($input)['response']);
|
||||
}
|
||||
|
||||
public function testCreateSameField()
|
||||
{
|
||||
$this->fixture->setType('POST');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity');
|
||||
|
||||
$input = '{"name":"customField","type":"varchar","maxLength":50}';
|
||||
|
||||
$this->assertEquals(500, $this->fixture->getResponse($input)['code']);
|
||||
}
|
||||
|
||||
|
||||
public function testReadAfterCreate()
|
||||
{
|
||||
$this->fixture->setType('GET');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity/customField');
|
||||
$data = '{"type":"varchar","maxLength":50,"isCustom":true}';
|
||||
$this->assertEquals($data, $this->fixture->getResponse()['response']);
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->fixture->setType('PUT');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity/customField');
|
||||
|
||||
$input = '{"type":"varchar","maxLength":50,"default":"this is a test"}';
|
||||
$result = '{"type":"varchar","maxLength":50,"isCustom":true,"default":"this is a test"}';
|
||||
|
||||
$this->assertEquals($result, $this->fixture->getResponse($input)['response']);
|
||||
}
|
||||
|
||||
public function testUpdateCoreField()
|
||||
{
|
||||
$this->fixture->setType('PUT');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/Account/name');
|
||||
|
||||
$input = '{"type":"varchar","maxLength":50,"default":"this is a test"}';
|
||||
|
||||
$this->assertEquals(500, $this->fixture->getResponse($input)['code']);
|
||||
}
|
||||
|
||||
public function testReadAfterUpdate()
|
||||
{
|
||||
$this->fixture->setType('GET');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity/customField');
|
||||
$data = '{"type":"varchar","maxLength":50,"isCustom":true,"default":"this is a test"}';
|
||||
$this->assertEquals($data, $this->fixture->getResponse()['response']);
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$this->fixture->setType('DELETE');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity/customField');
|
||||
$this->assertEquals('true', $this->fixture->getResponse()['response']);
|
||||
}
|
||||
|
||||
public function testReadAfterDetele()
|
||||
{
|
||||
$this->fixture->setType('GET');
|
||||
|
||||
$this->fixture->setUrl('/Admin/fieldManager/CustomEntity/customField');
|
||||
$response= $this->fixture->getResponse();
|
||||
$this->assertEquals(404, $response['code']);
|
||||
}
|
||||
|
||||
public function testDeleteTestFile()
|
||||
{
|
||||
$file = 'custom/Espo/Custom/Resources/metadata/entityDefs/CustomEntity.json';
|
||||
if (file_exists($file)) {
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Api;
|
||||
|
||||
class LayoutTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $fixture;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$config = include('tests/Api/config.php');
|
||||
if (!$config['apiTestsEnabled']) {
|
||||
$this->markTestSkipped('API tests are not enabled.');
|
||||
}
|
||||
|
||||
require_once('tests/Api/RestTesterClass.php');
|
||||
$this->fixture = new RestTesterClass();
|
||||
|
||||
/****************************************/
|
||||
$this->fixture->setUrl('/layout');
|
||||
/****************************************/
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->fixture = NULL;
|
||||
}
|
||||
|
||||
|
||||
function testPut()
|
||||
{
|
||||
$this->fixture->setType('PUT');
|
||||
|
||||
$this->fixture->setUrl('/CustomTest/layout/testPut');
|
||||
$data= '["amount","account","closeDate","leadSource","stage","probability","assignedUser"]';
|
||||
$this->assertTrue($this->fixture->isSuccess( $data ));
|
||||
|
||||
//check if file exists
|
||||
$file = 'application/Espo/Custom/Resources/layouts/CustomTest/testPut.json';
|
||||
|
||||
$fileExists = file_exists($file);
|
||||
$this->assertTrue($fileExists);
|
||||
|
||||
if ($fileExists) {
|
||||
$content = file_get_contents($file);
|
||||
|
||||
$this->assertEquals($data, $content);
|
||||
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
function testPatch()
|
||||
{
|
||||
$this->fixture->setType('PATCH');
|
||||
|
||||
$this->fixture->setUrl('/CustomTest/layout/testPatch');
|
||||
$data= '[{"label":"MyLabel"}]';
|
||||
$this->assertTrue($this->fixture->isSuccess( $data ));
|
||||
|
||||
$data= '[{"isPathed":true}]';
|
||||
$this->assertTrue($this->fixture->isSuccess( $data ));
|
||||
|
||||
//check if file exists
|
||||
$file = 'application/Espo/Custom/Resources/layouts/CustomTest/testPatch.json';
|
||||
|
||||
$fileExists = file_exists($file);
|
||||
$this->assertTrue($fileExists);
|
||||
|
||||
if ($fileExists) {
|
||||
|
||||
$content = file_get_contents($file);
|
||||
|
||||
//$data= '[{"label":"MyLabel","isPathed":true}]';
|
||||
$data= '[{"isPathed":true}]'; //now PATCH works like PUT
|
||||
$this->assertEquals($data, $content);
|
||||
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
function testGet()
|
||||
{
|
||||
$this->fixture->setType('GET');
|
||||
|
||||
$this->fixture->setUrl('/CustomTest/layout/detail');
|
||||
$this->assertTrue($this->fixture->isSuccess( ));
|
||||
|
||||
$this->fixture->setUrl('/needToBeNotReal/layout/notReal');
|
||||
$response= $this->fixture->getResponse();
|
||||
$this->assertEquals(404, $response['code']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Api;
|
||||
|
||||
class RestTesterClass
|
||||
{
|
||||
private $apiUrl;
|
||||
private $username;
|
||||
private $password;
|
||||
|
||||
protected $type= 'PATCH';
|
||||
protected $url= '/';
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$config = include('tests/Api/config.php');
|
||||
|
||||
$this->apiUrl = $config['apiUrl'];
|
||||
$this->username = $config['username'];
|
||||
$this->password = $config['password'];
|
||||
}
|
||||
|
||||
function setType($name)
|
||||
{
|
||||
$this->type= strtoupper($name);
|
||||
}
|
||||
|
||||
function setUrl($url)
|
||||
{
|
||||
$this->url= (substr($url, 0,1)=='/') ? $this->apiUrl.$url : $this->apiUrl.'/'.$url;
|
||||
}
|
||||
|
||||
function getResponse($jsonData='', $output=false)
|
||||
{
|
||||
$ch = curl_init($this->url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password);
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Sample Code');
|
||||
|
||||
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: PUT'));
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->type);
|
||||
|
||||
if (!empty($jsonData)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($jsonData))
|
||||
);
|
||||
}
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$resultStatus = curl_getinfo($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
//echo '<pre>';
|
||||
//echo $response;
|
||||
|
||||
if($resultStatus['http_code'] == 200) {
|
||||
if ($output) {
|
||||
echo "\r\n".$response."\r\n\r\n";
|
||||
}
|
||||
} else {
|
||||
if ($output) {
|
||||
echo 'CALL FAILED: '.print_r($resultStatus, true).'<hr/ >'.$response;
|
||||
}
|
||||
}
|
||||
|
||||
return array('response'=>$response, 'code'=>$resultStatus['http_code']);
|
||||
}
|
||||
|
||||
function isSuccess($jsonData='', $output=false)
|
||||
{
|
||||
$response= $this->getResponse($jsonData, $output);
|
||||
|
||||
return ($response['code'] == 200) ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'apiTestsEnabled' => false,
|
||||
'apiUrl' => 'http://172.20.0.1/taras/espo/api/v1',
|
||||
'username' => 'admin',
|
||||
'password' => '1',
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -80,7 +80,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals( $upgradeId, $this->reflection->invokeMethod('getUpgradeId', array()) );
|
||||
}
|
||||
|
||||
|
||||
public function testCreateUpgradeId()
|
||||
{
|
||||
$upgradeId = $this->reflection->setProperty('upgradeId', null);
|
||||
@@ -97,7 +96,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->reflection->invokeMethod('getUpgradeId', array());
|
||||
}
|
||||
|
||||
|
||||
public function testGetManifestIncorrect()
|
||||
{
|
||||
$this->setExpectedException('\Espo\Core\Exceptions\Error');
|
||||
@@ -114,7 +112,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->reflection->invokeMethod('getManifest', array());
|
||||
}
|
||||
|
||||
|
||||
public function testGetManifest()
|
||||
{
|
||||
$manifest = '{
|
||||
@@ -162,7 +159,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider acceptableDataFalse
|
||||
*/
|
||||
@@ -184,7 +180,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function testGetUpgradePath()
|
||||
{
|
||||
$upgradeId = $this->reflection->invokeMethod('getUpgradeId', array());
|
||||
@@ -195,12 +190,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
$postfix = $this->reflection->getProperty('packagePostfix');
|
||||
$this->assertEquals( $upgradePath.$postfix, $this->reflection->invokeMethod('getUpgradePath', array(true)) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -11,7 +11,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected $objects;
|
||||
|
||||
protected $configPath = 'tests/testData/Utils/Config/config.php';
|
||||
protected $configPath = 'tests/testData/Utils/Config/cache/config.php';
|
||||
|
||||
protected $systemConfigPath = 'tests/testData/Utils/Config/systemConfig.php';
|
||||
|
||||
|
||||
@@ -65,14 +65,14 @@ class FieldManagerTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->exactly(3))
|
||||
->expects($this->exactly(6))
|
||||
->method('get')
|
||||
->will($this->returnValue($data));
|
||||
|
||||
$this->assertTrue($this->object->update('name', $data, 'Account'));
|
||||
}
|
||||
|
||||
public function testUpdateCustomField()
|
||||
public function testUpdateCustomFieldIsNotChanged()
|
||||
{
|
||||
$data = array(
|
||||
"type" => "varchar",
|
||||
@@ -85,11 +85,39 @@ class FieldManagerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('get')
|
||||
->will($this->returnValue($data));
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->never())
|
||||
->method('set')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->assertTrue($this->object->update('varName', $data, 'CustomEntity'));
|
||||
}
|
||||
|
||||
public function testUpdateCustomField()
|
||||
{
|
||||
$data = array(
|
||||
"type" => "varchar",
|
||||
"maxLength" => "50",
|
||||
"isCustom" => true,
|
||||
);
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->exactly(6))
|
||||
->method('get')
|
||||
->will($this->returnValue($data));
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->once())
|
||||
->method('set')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$data = array(
|
||||
"type" => "varchar",
|
||||
"maxLength" => "150",
|
||||
"required" => true,
|
||||
"isCustom" => true,
|
||||
);
|
||||
|
||||
$this->assertTrue($this->object->update('varName', $data, 'CustomEntity'));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ class SystemTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'Microsoft-IIS/8.0';
|
||||
$this->assertEquals( 'microsoft-iis', $this->object->getServerType());
|
||||
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'apache/2.4.10 (win32) openssl/1.0.1i php';
|
||||
$this->assertEquals( 'apache', $this->object->getServerType());
|
||||
}
|
||||
|
||||
|
||||
|
||||
+363
-454
@@ -4,23 +4,21 @@ namespace tests\Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
|
||||
class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
function testGetSeparator()
|
||||
public function testGetSeparator()
|
||||
{
|
||||
$this->assertEquals(DIRECTORY_SEPARATOR, Util::getSeparator());
|
||||
}
|
||||
|
||||
function testToCamelCase()
|
||||
public function testToCamelCase()
|
||||
{
|
||||
$this->assertEquals('detail', Util::toCamelCase('detail'));
|
||||
$this->assertEquals('detailView', Util::toCamelCase('detail-view'));
|
||||
$this->assertEquals('myDetailView', Util::toCamelCase('my-detail-view'));
|
||||
}
|
||||
|
||||
function testFromCamelCase()
|
||||
public function testFromCamelCase()
|
||||
{
|
||||
$this->assertEquals('detail', Util::fromCamelCase('detail'));
|
||||
$this->assertEquals('detail-view', Util::fromCamelCase('detailView'));
|
||||
@@ -61,7 +59,6 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($result, Util::merge($array1, $array2Main));
|
||||
|
||||
|
||||
|
||||
$array1= array(
|
||||
'datetime' =>
|
||||
array (
|
||||
@@ -114,436 +111,383 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($result, Util::merge($array1, $array2Main));
|
||||
}
|
||||
|
||||
public function testMergeLevel1()
|
||||
public function testMergeWithAppend()
|
||||
{
|
||||
$basicArr = array(
|
||||
'useCache' => 111,
|
||||
'useCache1' => 111,
|
||||
'sub' => array (
|
||||
'subV' => '1111',
|
||||
'subV1' => '1111',
|
||||
'subO' => array(
|
||||
'subOV' => '11111',
|
||||
'subOV1' => '11111',
|
||||
'subOT' => array(
|
||||
'subOTT' => '11111',
|
||||
'subOT1' => '11111',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$advArr = array(
|
||||
'useCache' => 222,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 1));
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, array(1)));
|
||||
}
|
||||
|
||||
|
||||
public function testMergeLevel1WithMergeKeyName()
|
||||
{
|
||||
$basicArr = array(
|
||||
'useCache' => 111,
|
||||
'useCache1' => 111,
|
||||
'sub' => array (
|
||||
'subV' => '1111',
|
||||
'subV1' => '1111',
|
||||
'subO' => array(
|
||||
'subOV' => '11111',
|
||||
'subOV1' => '11111',
|
||||
'subOT' => array(
|
||||
'subOTT' => '11111',
|
||||
'subOT1' => '11111',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$advArr = array(
|
||||
'useCache' => 222,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV1' => '1111',
|
||||
'subO' =>
|
||||
array (
|
||||
'subOV' => '22222',
|
||||
'subOV1' => '11111',
|
||||
'subOT' =>
|
||||
$currentArray = array(
|
||||
'entityDefs' =>
|
||||
array (
|
||||
'subOTT' => '22222',
|
||||
'subOT1' => '11111',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
'subOV2' => '22222',
|
||||
),
|
||||
'subV2' => '222222',
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 1, 'useCache'));
|
||||
$this->assertEquals( $result, Util::merge($basicArr, $advArr, array(1, 'useCache')) );
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 1, 'sub'));
|
||||
$this->assertEquals( $result, Util::merge($basicArr, $advArr, array(1, 'sub')) );
|
||||
}
|
||||
|
||||
public function testMergeLevel2()
|
||||
{
|
||||
$basicArr = array(
|
||||
'useCache' => 111,
|
||||
'useCache1' => 111,
|
||||
'sub' => array (
|
||||
'subV' => '1111',
|
||||
'subV1' => '1111',
|
||||
'subO' => array(
|
||||
'subOV' => '11111',
|
||||
'subOV1' => '11111',
|
||||
'subOT' => array(
|
||||
'subOTT' => '11111',
|
||||
'subOT1' => '11111',
|
||||
'Attachment' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$advArr = array(
|
||||
'useCache' => 222,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
'type' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'maxLength' => 36,
|
||||
),
|
||||
'size' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["v1", "v2", "v3"],
|
||||
),
|
||||
'sizeInt' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => [0, 1, 2],
|
||||
),
|
||||
'merged' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["v1", "v2", "v3"],
|
||||
),
|
||||
'mergedInt' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => [0, 1, 2],
|
||||
),
|
||||
),
|
||||
),
|
||||
'Contact' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => true,
|
||||
),
|
||||
'type' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'maxLength' => 36,
|
||||
),
|
||||
'size' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["v1", "v2", "v3"],
|
||||
),
|
||||
'merged' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["v1", "v2", "v3"],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV1' => '1111',
|
||||
'subO' =>
|
||||
'MyCustom' =>
|
||||
array (
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' =>
|
||||
'fields' =>
|
||||
array (
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'subV2' => '222222',
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 2));
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, array(2)));
|
||||
$newArray = array(
|
||||
'entityDefs' =>
|
||||
array (
|
||||
'Attachment' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => false,
|
||||
'NEW' => 'NEWVAL',
|
||||
),
|
||||
'type' =>
|
||||
array (
|
||||
'type' => 'NETYPE',
|
||||
),
|
||||
'size' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["B1", "B2", "B3"],
|
||||
),
|
||||
'sizeInt' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => [5, 8, 9],
|
||||
),
|
||||
'merged' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["__APPEND__", "B1", "B2", "B3"],
|
||||
),
|
||||
'mergedInt' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ['__APPEND__', 5, 8, 9],
|
||||
),
|
||||
),
|
||||
'list' =>
|
||||
array (
|
||||
'test' => 'Here',
|
||||
),
|
||||
),
|
||||
'Contact' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => false,
|
||||
'NEW' => 'NEWVAL',
|
||||
),
|
||||
'type' =>
|
||||
array (
|
||||
'type' => 'NEW',
|
||||
'maxLength' => 1000000,
|
||||
),
|
||||
'size' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["B1", "B2", "B3"],
|
||||
),
|
||||
'merged' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' => ["__APPEND__", "B1", "B2", "B3"],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$result = array (
|
||||
'entityDefs' =>
|
||||
array (
|
||||
'Attachment' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => false,
|
||||
'NEW' => 'NEWVAL',
|
||||
),
|
||||
'type' =>
|
||||
array (
|
||||
'type' => 'NETYPE',
|
||||
'maxLength' => 36,
|
||||
),
|
||||
'size' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' =>
|
||||
array (
|
||||
0 => 'B1',
|
||||
1 => 'B2',
|
||||
2 => 'B3',
|
||||
),
|
||||
),
|
||||
'sizeInt' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' =>
|
||||
array (
|
||||
0 => 5,
|
||||
1 => 8,
|
||||
2 => 9,
|
||||
),
|
||||
),
|
||||
'merged' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' =>
|
||||
array (
|
||||
0 => 'v1',
|
||||
1 => 'v2',
|
||||
2 => 'v3',
|
||||
3 => 'B1',
|
||||
4 => 'B2',
|
||||
5 => 'B3',
|
||||
),
|
||||
),
|
||||
'mergedInt' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' =>
|
||||
array (
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
4 => 8,
|
||||
5 => 9,
|
||||
),
|
||||
),
|
||||
),
|
||||
'list' =>
|
||||
array (
|
||||
'test' => 'Here',
|
||||
),
|
||||
),
|
||||
'Contact' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => false,
|
||||
'NEW' => 'NEWVAL',
|
||||
),
|
||||
'type' =>
|
||||
array (
|
||||
'type' => 'NEW',
|
||||
'maxLength' => 1000000,
|
||||
),
|
||||
'size' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' =>
|
||||
array (
|
||||
0 => 'B1',
|
||||
1 => 'B2',
|
||||
2 => 'B3',
|
||||
),
|
||||
),
|
||||
'merged' =>
|
||||
array (
|
||||
'type' => 'enum',
|
||||
'value' =>
|
||||
array (
|
||||
0 => 'v1',
|
||||
1 => 'v2',
|
||||
2 => 'v3',
|
||||
3 => 'B1',
|
||||
4 => 'B2',
|
||||
5 => 'B3',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'MyCustom' =>
|
||||
array (
|
||||
'fields' =>
|
||||
array (
|
||||
'name' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'required' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($currentArray, $newArray));
|
||||
}
|
||||
|
||||
public function testMergeLevel2WithMergeKeyName()
|
||||
public function testMergeWithBool()
|
||||
{
|
||||
$basicArr = array(
|
||||
'useCache' => 111,
|
||||
'useCache1' => 111,
|
||||
'sub' => array (
|
||||
'subV' => '1111',
|
||||
'subV1' => '1111',
|
||||
'subO' => array(
|
||||
'subOV' => '11111',
|
||||
'subOV1' => '11111',
|
||||
'subOT' => array(
|
||||
'subOTT' => '11111',
|
||||
'subOT1' => '11111',
|
||||
),
|
||||
),
|
||||
$currentArray = array (
|
||||
'fields' =>
|
||||
array (
|
||||
'accountId' =>
|
||||
array (
|
||||
'type' => 'varchar',
|
||||
'where' =>
|
||||
array (
|
||||
'=' => 'contact.id IN ({value})',
|
||||
),
|
||||
'len' => 255,
|
||||
),
|
||||
'deleted' =>
|
||||
array (
|
||||
'type' => 'bool',
|
||||
'default' => false,
|
||||
'trueValue' => true,
|
||||
),
|
||||
),
|
||||
'relations' =>
|
||||
array (
|
||||
),
|
||||
);
|
||||
|
||||
$advArr = array(
|
||||
'useCache' => 222,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
$newArray = array (
|
||||
'fields' =>
|
||||
array (
|
||||
'accountName' =>
|
||||
array (
|
||||
'type' => 'foreign',
|
||||
'relation' => 'account',
|
||||
'foreign' => 'name',
|
||||
),
|
||||
'accountId' =>
|
||||
array (
|
||||
'type' => 'foreignId',
|
||||
'index' => true,
|
||||
),
|
||||
),
|
||||
'relations' =>
|
||||
array (
|
||||
'createdBy' =>
|
||||
array (
|
||||
'type' => 'belongsTo',
|
||||
'entity' => 'User',
|
||||
'key' => 'createdById',
|
||||
'foreignKey' => 'id',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
'fields' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV1' => '1111',
|
||||
'subO' =>
|
||||
array (
|
||||
'subOV' => '22222',
|
||||
'subOV1' => '11111',
|
||||
'subOT' =>
|
||||
array (
|
||||
'subOTT' => '22222',
|
||||
'subOT1' => '11111',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
'subOV2' => '22222',
|
||||
),
|
||||
'subV2' => '222222',
|
||||
'accountName' =>
|
||||
array (
|
||||
'type' => 'foreign',
|
||||
'relation' => 'account',
|
||||
'foreign' => 'name',
|
||||
),
|
||||
'accountId' =>
|
||||
array (
|
||||
'type' => 'foreignId',
|
||||
'index' => true,
|
||||
'where' =>
|
||||
array (
|
||||
'=' => 'contact.id IN ({value})',
|
||||
),
|
||||
'len' => 255,
|
||||
),
|
||||
'deleted' =>
|
||||
array (
|
||||
'type' => 'bool',
|
||||
'default' => false,
|
||||
'trueValue' => true,
|
||||
),
|
||||
),
|
||||
'relations' =>
|
||||
array (
|
||||
'createdBy' =>
|
||||
array (
|
||||
'type' => 'belongsTo',
|
||||
'entity' => 'User',
|
||||
'key' => 'createdById',
|
||||
'foreignKey' => 'id',
|
||||
),
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 2, 'subOV'));
|
||||
$this->assertEquals( $result, Util::merge($basicArr, $advArr, array(2, 'subOV')) );
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV1' => '1111',
|
||||
'subO' =>
|
||||
array (
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' =>
|
||||
array (
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
'subV2' => '222222',
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 2, 'subO'));
|
||||
$this->assertEquals( $result, Util::merge($basicArr, $advArr, array(2, 'subO')) );
|
||||
$this->assertEquals($result, Util::merge($currentArray, $newArray));
|
||||
}
|
||||
|
||||
|
||||
public function testMergeLevel3()
|
||||
{
|
||||
$basicArr = array(
|
||||
'useCache' => 111,
|
||||
'useCache1' => 111,
|
||||
'sub' => array (
|
||||
'subV' => '1111',
|
||||
'subV1' => '1111',
|
||||
'subO' => array(
|
||||
'subOV' => '11111',
|
||||
'subOV1' => '11111',
|
||||
'subOT' => array(
|
||||
'subOTT' => '11111',
|
||||
'subOT1' => '11111',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$advArr = array(
|
||||
'useCache' => 222,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV1' => '1111',
|
||||
'subO' =>
|
||||
array (
|
||||
'subOV' => '22222',
|
||||
'subOV1' => '11111',
|
||||
'subOT' =>
|
||||
array (
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
'subOV2' => '22222',
|
||||
),
|
||||
'subV2' => '222222',
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 3));
|
||||
}
|
||||
|
||||
public function testMergeLevel4Plus()
|
||||
{
|
||||
$basicArr = array(
|
||||
'useCache' => 111,
|
||||
'useCache1' => 111,
|
||||
'sub' => array (
|
||||
'subV' => '1111',
|
||||
'subV1' => '1111',
|
||||
'subO' => array(
|
||||
'subOV' => '11111',
|
||||
'subOV1' => '11111',
|
||||
'subOT' => array(
|
||||
'subOTT' => '11111',
|
||||
'subOT1' => '11111',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$advArr = array(
|
||||
'useCache' => 222,
|
||||
'useCache2' => 222,
|
||||
'sub' => array (
|
||||
'subV' => '222222',
|
||||
'subV2' => '222222',
|
||||
'subO' => array(
|
||||
'subOV' => '22222',
|
||||
'subOV2' => '22222',
|
||||
'subOT' => array(
|
||||
'subOTT' => '22222',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$result = array (
|
||||
'useCache' => 222,
|
||||
'useCache1' => 111,
|
||||
'sub' =>
|
||||
array (
|
||||
'subV' => '222222',
|
||||
'subV1' => '1111',
|
||||
'subO' =>
|
||||
array (
|
||||
'subOV' => '22222',
|
||||
'subOV1' => '11111',
|
||||
'subOT' =>
|
||||
array (
|
||||
'subOTT' => '22222',
|
||||
'subOT1' => '11111',
|
||||
'subOT2' => '22222',
|
||||
),
|
||||
'subOV2' => '22222',
|
||||
),
|
||||
'subV2' => '222222',
|
||||
),
|
||||
'useCache2' => 222,
|
||||
);
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 4));
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 5));
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr, 6));
|
||||
|
||||
$this->assertEquals($result, Util::merge($basicArr, $advArr));
|
||||
}
|
||||
|
||||
|
||||
function testToFormat()
|
||||
public function testToFormat()
|
||||
{
|
||||
$this->assertEquals('/Espo/Core/Utils', Util::toFormat('/Espo/Core/Utils', '/'));
|
||||
$this->assertEquals('\Espo\Core\Utils', Util::toFormat('/Espo/Core/Utils', '\\'));
|
||||
@@ -552,7 +496,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('\Espo\Core\Utils', Util::toFormat('\Espo\Core\Utils', '\\'));
|
||||
}
|
||||
|
||||
function testConcatPath()
|
||||
public function testConcatPath()
|
||||
{
|
||||
$result= 'dir1/dir2/file1.json';
|
||||
$this->assertEquals($result, Util::concatPath('dir1/dir2', 'file1.json'));
|
||||
@@ -573,7 +517,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
function testArrayToObject()
|
||||
public function testArrayToObject()
|
||||
{
|
||||
$testArr= array(
|
||||
'useCache' => true,
|
||||
@@ -599,7 +543,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
function testObjectToArray()
|
||||
public function testObjectToArray()
|
||||
{
|
||||
$testObj= (object) array(
|
||||
'useCache' => true,
|
||||
@@ -624,7 +568,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($testResult, Util::objectToArray($testObj));
|
||||
}
|
||||
|
||||
function testGetNaming()
|
||||
public function testGetNaming()
|
||||
{
|
||||
$this->assertEquals('myPrefixMyName', Util::getNaming('myName', 'myPrefix', 'prefix'));
|
||||
|
||||
@@ -633,7 +577,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('myNameMyPostfix', Util::getNaming('my_name', 'my_postfix', 'postfix', '_'));
|
||||
}
|
||||
|
||||
function testReplaceInArray()
|
||||
public function testReplaceInArray()
|
||||
{
|
||||
$testArray = array(
|
||||
'option' => array(
|
||||
@@ -657,7 +601,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
function testGetClassName()
|
||||
public function testGetClassName()
|
||||
{
|
||||
$this->assertEquals('\Espo\EntryPoints\Donwload', Util::getClassName('application/Espo/EntryPoints/Donwload.php'));
|
||||
$this->assertEquals('\Espo\EntryPoints\Donwload', Util::getClassName('custom/Espo/EntryPoints/Donwload.php'));
|
||||
@@ -665,7 +609,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('\Espo\EntryPoints\Donwload', Util::getClassName('application/Espo/EntryPoints/Donwload'));
|
||||
}
|
||||
|
||||
function testUnsetInArrayNotSingle()
|
||||
public function testUnsetInArrayNotSingle()
|
||||
{
|
||||
$input = array(
|
||||
'Account' => array(
|
||||
@@ -700,7 +644,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($result, Util::unsetInArray($input, $unsets));
|
||||
}
|
||||
|
||||
function testUnsetInArraySingle()
|
||||
public function testUnsetInArraySingle()
|
||||
{
|
||||
$input = array(
|
||||
'Account' => array(
|
||||
@@ -734,7 +678,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
function testUnsetInArrayTogether()
|
||||
public function testUnsetInArrayTogether()
|
||||
{
|
||||
$input = array(
|
||||
'Account' => array(
|
||||
@@ -771,7 +715,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
function testUnsetInArray()
|
||||
public function testUnsetInArray()
|
||||
{
|
||||
$input = array(
|
||||
'Account' => array(
|
||||
@@ -826,7 +770,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($result, Util::unsetInArray($input, $unsets));
|
||||
}
|
||||
|
||||
function testGetValueByKey()
|
||||
public function testGetValueByKey()
|
||||
{
|
||||
$inputArray = array(
|
||||
'Account' => array(
|
||||
@@ -858,41 +802,6 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('customReturns', Util::getValueByKey($inputArray, 'Contact.notExists', 'customReturns'));
|
||||
$this->assertNotEquals('customReturns', Util::getValueByKey($inputArray, 'Contact.useCache', 'customReturns'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*function testGetScopeModuleName()
|
||||
{
|
||||
$this->assertEquals('Crm', $this->fixture->getScopeModuleName('Account'));
|
||||
$this->assertEquals('Crm', $this->fixture->getScopeModuleName('account'));
|
||||
$this->assertNotEquals('crm', $this->fixture->getScopeModuleName('account'));
|
||||
|
||||
$this->assertEquals('', $this->fixture->getScopeModuleName('User'));
|
||||
$this->assertEquals('', $this->fixture->getScopeModuleName('user'));
|
||||
$this->assertNotEquals('Crm', $this->fixture->getScopeModuleName('User'));
|
||||
}
|
||||
|
||||
|
||||
function testGetScopePath()
|
||||
{
|
||||
$this->assertEquals('Modules/Crm', $this->fixture->getScopePath('Account', '/'));
|
||||
$this->assertEquals('Modules\Crm', $this->fixture->getScopePath('Account', '\\'));
|
||||
$this->assertEquals('Modules\Crm', $this->fixture->getScopePath('account', '\\'));
|
||||
|
||||
$this->assertEquals('Espo', $this->fixture->getScopePath('User', '/'));
|
||||
$this->assertEquals('Espo', $this->fixture->getScopePath('User', '\\'));
|
||||
$this->assertEquals('Espo', $this->fixture->getScopePath('user', '\\'));
|
||||
}
|
||||
|
||||
|
||||
function testGetScopes()
|
||||
{
|
||||
$this->assertArrayHasKey('User', $this->fixture->getScopes() );
|
||||
} */
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+4
-3
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
return array (
|
||||
'cacheTimestamp' => 1412600573,
|
||||
'removeOption' => 'Test',
|
||||
'testOption' => 'Another Wrong Value',
|
||||
'testOption2' => 'Test2',
|
||||
'database' =>
|
||||
array (
|
||||
'driver' => 'pdo_mysql',
|
||||
@@ -102,9 +106,6 @@ return array (
|
||||
8 => 'Prospect',
|
||||
),
|
||||
'isInstalled' => true,
|
||||
'cacheTimestamp' => 1404901977,
|
||||
'testOption' => 'Another Wrong Value',
|
||||
'testOption2' => 'Test2',
|
||||
);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user