objOneToOneRelationship = $this->getMockBuilder('OneToOneRelationship') ->disableOriginalConstructor() ->setMethods(array('getDefinition')) ->getMock(); $this->objOneToOneRelationship->expects($this->any()) ->method('getDefinition') ->will($this->returnValue(array( 'lhs_module' => 'lhs_module', 'rhs_module' => 'rhs_module' ))); } public function tearDown() { SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); unset($GLOBALS['current_user']); unset($GLOBALS['beanFiles']); unset($GLOBALS['beanList']); unset($this->objOneToOneRelationship); } /** * @group 49024 */ public function testDeployedRelationshipsUniqName() { $objDeployedRelationships = $this->getMockBuilder('DeployedRelationshipsBug49024Test') ->disableOriginalConstructor() ->setMethods(array('load', 'getRelationshipList')) ->getMock(); $objDeployedRelationships->expects($this->any()) ->method('getRelationshipList') ->will($this->returnValue(array())); $name = $objDeployedRelationships->getUniqueNameBug49024Test($this->objOneToOneRelationship); $this->assertEquals('lhs_module_rhs_module_1', $name); } /** * @group 49024 */ public function testDeployedRelationshipsUniqName2() { $objDeployedRelationships = $this->getMockBuilder('DeployedRelationshipsBug49024Test') ->disableOriginalConstructor() ->setMethods(array('load', 'getRelationshipList')) ->getMock(); $objDeployedRelationships->expects($this->any()) ->method('getRelationshipList') ->will($this->returnValue(array( 'lhs_module_rhs_module_1' => true, 'lhs_module_rhs_module_2' => true ))); $name = $objDeployedRelationships->getUniqueNameBug49024Test($this->objOneToOneRelationship); $this->assertEquals('lhs_module_rhs_module_3', $name); } /** * @group 49024 */ public function testUndeployedRelationshipsUniqName() { $objUndeployedRelationships = $this->getMockBuilder('UndeployedRelationshipsBug49024Test') ->disableOriginalConstructor() ->setMethods(array('load', 'getRelationshipList')) ->getMock(); $objUndeployedRelationships->expects($this->any()) ->method('getRelationshipList') ->will($this->returnValue(array())); $name = $objUndeployedRelationships->getUniqueNameBug49024Test($this->objOneToOneRelationship); $this->assertEquals('lhs_module_rhs_module', $name); } /** * @group 49024 */ public function testUndeployedRelationshipsUniqName2() { $objUndeployedRelationships = $this->getMockBuilder('UndeployedRelationshipsBug49024Test') ->disableOriginalConstructor() ->setMethods(array('load', 'getRelationshipList')) ->getMock(); $objUndeployedRelationships->expects($this->any()) ->method('getRelationshipList') ->will($this->returnValue(array( 'lhs_module_rhs_module' => true, 'lhs_module_rhs_module_1' => true, 'lhs_module_rhs_module_2' => true ))); $name = $objUndeployedRelationships->getUniqueNameBug49024Test($this->objOneToOneRelationship); $this->assertEquals('lhs_module_rhs_module_3', $name); } } class DeployedRelationshipsBug49024Test extends DeployedRelationships { public function getUniqueNameBug49024Test ($relationship) { return $this->getUniqueName($relationship); } } class UndeployedRelationshipsBug49024Test extends UndeployedRelationships { public function getUniqueNameBug49024Test ($relationship) { return $this->getUniqueName($relationship); } }