2 /*********************************************************************************
3 * By installing or using this file, you are confirming on behalf of the entity
4 * subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
5 * the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
6 * http://www.sugarcrm.com/master-subscription-agreement
8 * If Company is not bound by the MSA, then by installing or using this file
9 * you are agreeing unconditionally that Company will be bound by the MSA and
10 * certifying that you have authority to bind Company accordingly.
12 * Copyright (C) 2004-2013 SugarCRM Inc. All rights reserved.
13 ********************************************************************************/
16 * Bug #61144: remove doc link in field: Related Document, if linked doc is got deleted from the system
21 require_once('modules/Documents/Document.php');
23 class Bug61144Test extends Sugar_PHPUnit_Framework_TestCase
25 protected $parent_doc;
26 protected $relate_doc;
29 * @var DocumentRevision
33 public function setUp()
35 SugarTestHelper::setUp('beanFiles');
36 SugarTestHelper::setUp('beanList');
37 SugarTestHelper::setUp('current_user');
39 $this->relate_doc = new Document();
40 $this->relate_doc->document_name = 'Relate doc';
41 $this->relate_doc->save();
43 $this->parent_doc = new Document();
44 $this->parent_doc->document_name = 'Parent doc';
45 $this->parent_doc->related_doc_id = $this->relate_doc->id;
46 $this->parent_doc->save();
48 $this->revision = new DocumentRevision();
49 $this->revision->revision = 1;
50 $this->revision->doc_id = $this->relate_doc->id;
51 $this->revision->save();
54 public function tearDown()
56 SugarTestHelper::tearDown();
57 $GLOBALS['db']->query("DELETE FROM documents WHERE id in ('{$this->relate_doc->id}', '{$this->parent_doc->id}')");
58 $GLOBALS['db']->query("DELETE FROM {$this->revision->table_name} WHERE id in ('{$this->revision->id}')");
64 public function testDeleteRelateDocument()
66 $this->relate_doc->mark_deleted($this->relate_doc->id);
67 $this->parent_doc->fill_in_additional_detail_fields();
68 $this->assertEmpty($this->parent_doc->related_doc_name);
74 public function testRealteDocumentExist()
76 $this->parent_doc->fill_in_additional_detail_fields();
77 $this->assertEquals('Relate doc', $this->parent_doc->related_doc_name);
83 public function testDeleteRelateDocumentRevision()
85 $this->revision->mark_deleted($this->revision->id);
86 $actual = $this->revision->get_document_revision_name($this->revision->id);
87 $this->assertEmpty($actual, 'Deleted data is returned');
93 public function testRealteDocumentRevision()
95 $actual = $this->revision->get_document_revision_name($this->revision->id);
96 $this->assertEquals($this->revision->revision, $actual, 'Revision is incorrect');