This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/tests/Espo/Core/Utils/FieldManagerTest.php
T
2014-04-01 13:14:24 +03:00

73 lines
1.2 KiB
PHP

<?php
namespace tests\Espo\Core\Utils;
use tests\ReflectionHelper;
class FieldManagerTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected $objects;
protected $reflection;
protected function setUp()
{
$this->objects['metadata'] = $this->getMockBuilder('\Espo\Core\Utils\Metadata')->disableOriginalConstructor()->getMock();
$this->object = new \Espo\Core\Utils\FieldManager($this->objects['metadata']);
$this->reflection = new ReflectionHelper($this->object);
}
protected function tearDown()
{
$this->object = NULL;
}
public function testRead()
{
$data = array(
"type" => "varchar",
"maxLength" => "50",
"isCustom" => true,
);
$this->objects['metadata']
->expects($this->once())
->method('get')
->will($this->returnValue($data));
$this->assertEquals($data, $this->object->read('varName', 'Account'));
}
public function testNormalizeDefs()
{
$input1 = 'fielName';
$input2 = array(
"type" => "varchar",
"maxLength" => "50",
);
$result = array(
'fields' => array(
'fielName' => array(
"type" => "varchar",
"maxLength" => "50",
),
),
);
$this->assertEquals($result, $this->reflection->invokeMethod('normalizeDefs', array($input1, $input2)));
}
}
?>