mirror of
https://github.com/salesagility/SuiteCRM.git
synced 2025-03-16 06:13:34 +00:00
Test for get_linked_fields()
This commit is contained in:
parent
2565f41f13
commit
354e8d10cd
2 changed files with 60 additions and 1 deletions
|
@ -1834,7 +1834,9 @@ class SugarBean
|
|||
//find all definitions of type link.
|
||||
if (!empty($fieldDefs)) {
|
||||
foreach ($fieldDefs as $name => $properties) {
|
||||
if (array_search('link', $properties) === 'type') {
|
||||
if (!is_array($properties)) {
|
||||
$GLOBALS['log']->fatal('array_search() expects parameter 2 to be array, ' . gettype($properties) . ' given');
|
||||
} elseif (array_search('link', $properties) === 'type') {
|
||||
$linked_fields[$name] = $properties;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2011,9 +2011,66 @@ class SugarBeanTest extends PHPUnit_Framework_TestCase
|
|||
self::assertEquals('bar', $bean->foo);
|
||||
/** @noinspection UnSafeIsSetOverArrayInspection */
|
||||
self::assertNotTrue(isset($clone->foo));
|
||||
unset($bean->foo);
|
||||
self::assertEquals($bean, $clone);
|
||||
self::assertCount(2, $GLOBALS['log']->calls['fatal']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for load_relationships()
|
||||
*/
|
||||
public function testLoadRelationships()
|
||||
{
|
||||
|
||||
// $this->markTestIncomplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for get_linked_fields()
|
||||
*/
|
||||
public function testGetLinkedFields()
|
||||
{
|
||||
|
||||
// test
|
||||
$GLOBALS['log']->reset();
|
||||
$GLOBALS['log']->fatal('test');
|
||||
$bean = new Contact();
|
||||
$results = $bean->get_linked_fields();
|
||||
self::assertEquals(array(), $results);
|
||||
self::assertCount(2, $GLOBALS['log']->calls['fatal']);
|
||||
|
||||
// test
|
||||
$GLOBALS['log']->reset();
|
||||
$GLOBALS['log']->fatal('test');
|
||||
$bean = new Contact();
|
||||
$bean->field_defs = array(1);
|
||||
$results = $bean->get_linked_fields();
|
||||
self::assertEquals(array(), $results);
|
||||
self::assertCount(3, $GLOBALS['log']->calls['fatal']);
|
||||
|
||||
// test
|
||||
$GLOBALS['log']->reset();
|
||||
$GLOBALS['log']->fatal('test');
|
||||
$bean = new Contact();
|
||||
$bean->field_defs = array(array(1));
|
||||
$results = $bean->get_linked_fields();
|
||||
self::assertEquals(array(), $results);
|
||||
self::assertCount(1, $GLOBALS['log']->calls['fatal']);
|
||||
|
||||
// test
|
||||
$GLOBALS['log']->reset();
|
||||
$GLOBALS['log']->fatal('test');
|
||||
$bean = new Contact();
|
||||
$bean->field_defs = array(array('type' => 'link'));
|
||||
$results = $bean->get_linked_fields();
|
||||
self::assertEquals(array(
|
||||
0 => array(
|
||||
'type' => 'link',
|
||||
),
|
||||
), $results);
|
||||
self::assertCount(1, $GLOBALS['log']->calls['fatal']);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue