Test fixes
This commit is contained in:
@@ -91,10 +91,17 @@ class FieldManagerTest extends \PHPUnit_Framework_TestCase
|
||||
"label" => "Name",
|
||||
);
|
||||
|
||||
$map = array(
|
||||
['entityDefs.Account.fields.name', null, $data],
|
||||
[['entityDefs', 'Account', 'fields', 'name', 'type'], null, $data['type']],
|
||||
['fields.varchar', null, null],
|
||||
[['fields', 'varchar', 'hookClassName'], null, null],
|
||||
);
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->exactly(6))
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue($data));
|
||||
->will($this->returnValueMap($map));
|
||||
|
||||
$this->object->update('name', $data, 'Account');
|
||||
}
|
||||
@@ -107,10 +114,18 @@ class FieldManagerTest extends \PHPUnit_Framework_TestCase
|
||||
"isCustom" => true,
|
||||
);
|
||||
|
||||
$map = array(
|
||||
['entityDefs.CustomEntity.fields.varName', null, $data],
|
||||
['entityDefs.CustomEntity.fields.varName.type', null, $data['type']],
|
||||
[['entityDefs', 'CustomEntity', 'fields', 'varName'], null, $data],
|
||||
['fields.varchar', null, null],
|
||||
[['fields', 'varchar', 'hookClassName'], null, null],
|
||||
);
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->exactly(3))
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue($data));
|
||||
->will($this->returnValueMap($map));
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->never())
|
||||
@@ -128,10 +143,18 @@ class FieldManagerTest extends \PHPUnit_Framework_TestCase
|
||||
"isCustom" => true,
|
||||
);
|
||||
|
||||
$map = array(
|
||||
['entityDefs.CustomEntity.fields.varName', null, $data],
|
||||
['entityDefs.CustomEntity.fields.varName.type', null, $data['type']],
|
||||
[['entityDefs', 'CustomEntity', 'fields', 'varName'], null, $data],
|
||||
['fields.varchar', null, null],
|
||||
[['fields', 'varchar', 'hookClassName'], null, null],
|
||||
);
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->exactly(6))
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue($data));
|
||||
->will($this->returnValueMap($map));
|
||||
|
||||
$this->objects['metadata']
|
||||
->expects($this->once())
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
@@ -46,8 +46,9 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->objects['fileManager'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\File\\Manager')->disableOriginalConstructor()->getMock();
|
||||
$this->objects['metadata'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Metadata')->disableOriginalConstructor()->getMock();
|
||||
$this->objects['user'] = $this->getMockBuilder('\\Espo\\Entities\\User')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->object = new \Espo\Core\Utils\Layout($this->objects['fileManager'], $this->objects['metadata']);
|
||||
$this->object = new \Espo\Core\Utils\Layout($this->objects['fileManager'], $this->objects['metadata'], $this->objects['user']);
|
||||
|
||||
$this->reflection = new ReflectionHelper($this->object);
|
||||
$this->reflection->setProperty('params', array(
|
||||
|
||||
@@ -51,9 +51,12 @@ class MetadataTest extends \PHPUnit_Framework_TestCase
|
||||
copy($this->defaultCacheFile, $this->cacheFile);
|
||||
}
|
||||
|
||||
$this->objects['config'] = $this->getMockBuilder('\Espo\Core\Utils\Config')->disableOriginalConstructor()->getMock();
|
||||
$this->objects['config'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Config')->disableOriginalConstructor()->getMock();
|
||||
$this->objects['fileManager'] = new \Espo\Core\Utils\File\Manager();
|
||||
$this->objects['Unifier'] = $this->getMockBuilder('\Espo\Core\Utils\File\Unifier')->disableOriginalConstructor()->getMock();
|
||||
$this->objects['Unifier'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\File\\Unifier')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->objects['log'] = $this->getMockBuilder('\\Espo\\Core\\Utils\\Log')->disableOriginalConstructor()->getMock();
|
||||
$GLOBALS['log'] = $this->objects['log'];
|
||||
|
||||
//set to use cache
|
||||
$this->objects['config']
|
||||
|
||||
@@ -120,6 +120,7 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
'test' => [],
|
||||
'hello' => 'world',
|
||||
'man' => array(
|
||||
'test' => [
|
||||
@@ -129,7 +130,8 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
]
|
||||
)
|
||||
);
|
||||
$result = Util::merge($d3, Util::merge($d2, $d1));
|
||||
|
||||
$result = Util::merge(Util::merge($d2, $d1), $d3);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
@@ -1381,6 +1383,46 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotEquals('customReturns', Util::getValueByKey($inputArray, 'Contact.useCache', 'customReturns'));
|
||||
}
|
||||
|
||||
public function testGetValueByKey2()
|
||||
{
|
||||
$inputArray = array(
|
||||
'fields' => array(
|
||||
'varchar' => array (
|
||||
'params' =>
|
||||
array (
|
||||
array (
|
||||
'name' => 'required',
|
||||
'type' => 'bool',
|
||||
'default' => false,
|
||||
),
|
||||
array (
|
||||
'name' => 'default',
|
||||
'type' => 'varchar',
|
||||
),
|
||||
array (
|
||||
'name' => 'maxLength',
|
||||
'type' => 'int',
|
||||
),
|
||||
array (
|
||||
'name' => 'trim',
|
||||
'type' => 'bool',
|
||||
'default' => true,
|
||||
),
|
||||
array (
|
||||
'name' => 'audited',
|
||||
'type' => 'bool',
|
||||
),
|
||||
),
|
||||
'filter' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNull(Util::getValueByKey($inputArray, 'fields.varchar.hookClassName'));
|
||||
$this->assertNull(Util::getValueByKey($inputArray, ['fields', 'varchar', 'hookClassName']));
|
||||
$this->assertEquals('customReturns', Util::getValueByKey($inputArray, 'Contact.notExists', 'customReturns'));
|
||||
}
|
||||
|
||||
public function testUnsetInArrayByValue()
|
||||
{
|
||||
$newArray = json_decode('[
|
||||
|
||||
Reference in New Issue
Block a user