fileManager = $this->getMockBuilder('Espo\\Core\\Utils\\File\\Manager') ->disableOriginalConstructor()->getMock(); $this->metadata = $this->getMockBuilder('Espo\\Core\\Utils\\Metadata') ->disableOriginalConstructor()->getMock(); $this->user = $this->getMockBuilder('Espo\\Entities\\User') ->disableOriginalConstructor()->getMock(); $this->object = new Layout($this->fileManager, $this->metadata, $this->user); $this->reflection = new ReflectionHelper($this->object); } protected function tearDown() : void { $this->object = NULL; } function testGetLayoutPathCore() { $this->metadata ->expects($this->exactly(1)) ->method('getScopeModuleName') ->will($this->returnValue(null)); $this->assertEquals(Util::fixPath('application/Espo/Resources/layouts/User'), $this->reflection->invokeMethod('getDirPath', ['User']) ); $this->assertEquals( Util::fixPath('custom/Espo/Custom/Resources/layouts/User'), $this->reflection->invokeMethod('getDirPath', ['User', true]) ); } function testGetLayoutPathModule() { $this->metadata ->expects($this->exactly(1)) ->method('getScopeModuleName') ->will($this->returnValue('Crm')); $this->assertEquals( Util::fixPath('application/Espo/Modules/Crm/Resources/layouts/Call'), $this->reflection->invokeMethod('getDirPath', array('Call')) ); $this->assertEquals( Util::fixPath('custom/Espo/Custom/Resources/layouts/Call'), $this->reflection->invokeMethod('getDirPath', array('Call', true)) ); } function testGet() { $result = '[{"label":"Overview","rows":[[{"name":"userName"}," .' . '"{"name":"isAdmin"}],[{"name":"name"},{"name":"title"}]," .' . '"[{"name":"defaultTeam"}],[{"name":"emailAddress"},{"name":"phone"}]]}]'; $this->metadata ->expects($this->exactly(1)) ->method('getScopeModuleName') ->will($this->returnValue(null)); $this->fileManager ->expects($this->exactly(1)) ->method('getContents') ->will($this->returnValue($result)); $this->assertEquals($result, $this->object->get('Note', 'detail')); } }