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/AOW_Conditions/AOW_ConditionTest.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

68 lines
2.6 KiB
PHP

<?php
use SuiteCRM\Test\SuitePHPUnitFrameworkTestCase;
class AOW_ConditionTest extends SuitePHPUnitFrameworkTestCase
{
public function setUp()
{
parent::setUp();
global $current_user;
get_sugar_config_defaults();
$current_user = BeanFactory::newBean('Users');
}
public function testAOW_Condition()
{
// Execute the constructor and check for the Object type and attributes
$aowCondition = BeanFactory::newBean('AOW_Conditions');
$this->assertInstanceOf('AOW_Condition', $aowCondition);
$this->assertInstanceOf('Basic', $aowCondition);
$this->assertInstanceOf('SugarBean', $aowCondition);
$this->assertAttributeEquals('AOW_Conditions', 'module_dir', $aowCondition);
$this->assertAttributeEquals('AOW_Condition', 'object_name', $aowCondition);
$this->assertAttributeEquals('aow_conditions', 'table_name', $aowCondition);
$this->assertAttributeEquals(true, 'new_schema', $aowCondition);
$this->assertAttributeEquals(true, 'disable_row_level_security', $aowCondition);
$this->assertAttributeEquals(false, 'importable', $aowCondition);
$this->assertAttributeEquals(false, 'tracker_visibility', $aowCondition);
}
public function testbean_implements()
{
$aowCondition = BeanFactory::newBean('AOW_Conditions');
$this->assertEquals(false, $aowCondition->bean_implements('')); //test with blank value
$this->assertEquals(false, $aowCondition->bean_implements('test')); //test with invalid value
$this->assertEquals(false, $aowCondition->bean_implements('ACL')); //test with valid value
}
public function testsave_lines()
{
$aowCondition = BeanFactory::newBean('AOW_Conditions');
//populate required values
$post_data = array();
$post_data['name'] = array('test1', 'test2');
$post_data['field'] = array('field1', 'field2');
$post_data['operator'] = array('=', '!=');
$post_data['value_type'] = array('int', 'string');
$post_data['value'] = array('1', 'abc');
//create parent bean
$aowWorkFlow = BeanFactory::newBean('AOW_WorkFlow');
$aowWorkFlow->id = 1;
$aowCondition->save_lines($post_data, $aowWorkFlow);
//get the linked beans and verify if records created
$aow_conditions = $aowWorkFlow->get_linked_beans('aow_conditions', $aowWorkFlow->object_name);
$this->assertEquals(count($post_data['field']), count($aow_conditions));
//cleanup afterwards
foreach ($aow_conditions as $lineItem) {
$lineItem->mark_deleted($lineItem->id);
}
}
}