0
0
Fork 0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2025-02-21 20:56:08 +00:00
salesagility_SuiteCRM/tests/unit/phpunit/modules/DocumentRevisions/DocumentRevisionTest.php
j.dang cfa1f7cc28 Replace explicit bean instantiations in files 151 - 160
- File: '... /tests/unit/phpunit/modules/Groups/GroupTest.php'

   - Replaced 3 occurrence(s) of 'new Group()'

   - Replaced 1 occurrence(s) of 'new User()'

- File: '... /tests/unit/phpunit/modules/AOS_Product_Categories/AOS_Product_CategoriesTest.php'

   - Replaced 1 occurrence(s) of 'new User()'

   - Replaced 2 occurrence(s) of 'new AOS_Product_Categories()'

- File: '... /tests/unit/phpunit/modules/AOD_IndexEvent/AOD_IndexEventTest.php'

   - Replaced 1 occurrence(s) of 'new AOD_IndexEvent()'

- File: '... /tests/unit/phpunit/modules/AOP_Case_Updates/AOP_Case_UpdatesTest.php'

   - Replaced 1 occurrence(s) of 'new User()'

   - Replaced 7 occurrence(s) of 'new AOP_Case_Updates()'

- File: '... /tests/unit/phpunit/modules/Campaigns/CampaignTest.php'

   - Replaced 1 occurrence(s) of 'new Lead()'

   - Replaced 3 occurrence(s) of 'new ProspectList()'

   - Replaced 20 occurrence(s) of 'new Campaign()'

   - Replaced 1 occurrence(s) of 'new User()'

- File: '... /tests/unit/phpunit/modules/DocumentRevisions/DocumentRevisionTest.php'

   - Replaced 1 occurrence(s) of 'new User()'

   - Replaced 13 occurrence(s) of 'new DocumentRevision()'

- File: '... /tests/unit/phpunit/modules/AOW_WorkFlow/AOW_WorkFlowTest.php'

   - Replaced 4 occurrence(s) of 'new Call()'

   - Replaced 1 occurrence(s) of 'new User()'

   - Replaced 3 occurrence(s) of 'new AOS_Quotes()'

   - Replaced 16 occurrence(s) of 'new AOW_WorkFlow()'

   - Replaced 1 occurrence(s) of 'new AOW_Processed()'

   - Replaced 2 occurrence(s) of 'new AOW_Condition()'

- File: '... /tests/unit/phpunit/modules/EmailAddresses/EmailAddressTest.php'

   - Replaced 2 occurrence(s) of 'new EmailAddress()'

- File: '... /tests/unit/phpunit/modules/AOW_Conditions/AOW_ConditionTest.php'

   - Replaced 1 occurrence(s) of 'new User()'

   - Replaced 1 occurrence(s) of 'new AOW_WorkFlow()'

   - Replaced 3 occurrence(s) of 'new AOW_Condition()'

- File: '... /tests/unit/phpunit/modules/Calls/CallTest.php'

   - Replaced 18 occurrence(s) of 'new Call()'

   - Replaced 2 occurrence(s) of 'new User()'
2020-01-22 13:51:02 +00:00

181 lines
6.6 KiB
PHP

<?php
use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
class DocumentRevisionTest extends SuitePHPUnitFrameworkTestCase
{
public function setUp()
{
parent::setUp();
global $current_user;
get_sugar_config_defaults();
$current_user = BeanFactory::newBean('Users');
}
public function testDocumentRevision()
{
// Execute the constructor and check for the Object type and attributes
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$this->assertInstanceOf('DocumentRevision', $documentRevision);
$this->assertInstanceOf('SugarBean', $documentRevision);
$this->assertAttributeEquals('DocumentRevisions', 'module_dir', $documentRevision);
$this->assertAttributeEquals('DocumentRevision', 'object_name', $documentRevision);
$this->assertAttributeEquals('document_revisions', 'table_name', $documentRevision);
$this->assertAttributeEquals(true, 'new_schema', $documentRevision);
}
public function testSaveAndRetrieve()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$documentRevision->document_id = '1';
$documentRevision->doc_id = '1';
$documentRevision->doc_type = 'text';
$documentRevision->filename = 'test';
$documentRevision->file_ext = 'ext';
$documentRevision->save();
//test for record ID to verify that record is saved
$this->assertTrue(isset($documentRevision->id));
$this->assertEquals(36, strlen($documentRevision->id));
//test document retrieve method
$docRev = $documentRevision->retrieve($documentRevision->id);
$this->assertEquals('1', $docRev->document_id);
$this->assertEquals('1', $docRev->doc_id);
$this->assertEquals('text', $docRev->doc_type);
$this->assertEquals('test', $docRev->filename);
$this->assertEquals('ext', $docRev->file_ext);
//mark the record as deleted and verify that this record cannot be retrieved anymore.
$docRev->mark_deleted($docRev->id);
$result = $docRev->retrieve($docRev->id);
$this->assertEquals(null, $result);
}
public function testget_summary_text()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
//test without setting name
$this->assertEquals(null, $documentRevision->get_summary_text());
//test with name set
$documentRevision->filename = 'test';
$this->assertEquals('test', $documentRevision->get_summary_text());
}
public function testis_authenticated()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
//test wihout setting attributes
$this->assertEquals(null, $documentRevision->is_authenticated());
//test with attributes preset
$documentRevision->authenticated = true;
$this->assertEquals(true, $documentRevision->is_authenticated());
}
public function testfill_in_additional_list_fields()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
// Execute the method and test that it works and doesn't throw an exception.
try {
$documentRevision->fill_in_additional_list_fields();
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString());
}
}
public function testfill_in_additional_detail_fields()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
// Execute the method and test that it works and doesn't throw an exception.
try {
$documentRevision->fill_in_additional_detail_fields();
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString());
}
}
public function testgetDocumentRevisionNameForDisplay()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
//test wihout setting attributes
$result = $documentRevision->getDocumentRevisionNameForDisplay();
$this->assertEquals('.', $result);
//test with attributes preset
$documentRevision->filename = 'test.ext';
$documentRevision->revision = 1;
$result = $documentRevision->getDocumentRevisionNameForDisplay();
$this->assertEquals('-Revision_1.ext', $result);
}
public function testfill_document_name_revision()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
// Execute the method and test that it works and doesn't throw an exception.
try {
$documentRevision->fill_document_name_revision('dummy_id');
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString());
}
}
public function testlist_view_parse_additional_sections()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$xTemplateSection = null;
// Execute the method and test that it works and doesn't throw an exception.
try {
$ss = new Sugar_Smarty();
$documentRevision->list_view_parse_additional_sections($ss, $xTemplateSection);
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail($e->getMessage() . "\nTrace:\n" . $e->getTraceAsString());
}
}
public function testget_list_view_data()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$result = $documentRevision->get_list_view_data();
$this->assertEquals(array('DELETED' => 0), $result);
}
public function testget_document_revision_name()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$result = $documentRevision->get_document_revision_name(1);
$this->assertEquals(null, $result);
}
public function testget_document_revisions()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$results = $documentRevision->get_document_revisions(1);
$this->assertTrue(is_array($results));
}
public function testbean_implements()
{
$documentRevision = BeanFactory::newBean('DocumentRevisions');
$this->assertEquals(false, $documentRevision->bean_implements('')); //test with blank value
$this->assertEquals(false, $documentRevision->bean_implements('test')); //test with invalid value
$this->assertEquals(true, $documentRevision->bean_implements('FILE')); //test with valid value
}
}