@@ -3,183 +3,183 @@ discard block |
||
3 | 3 | class EmailTemplateTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testEmailTemplate() { |
|
6 | + public function testEmailTemplate() { |
|
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $emailTemplate = new EmailTemplate(); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $emailTemplate = new EmailTemplate(); |
|
10 | 10 | |
11 | - $this->assertInstanceOf('EmailTemplate',$emailTemplate); |
|
12 | - $this->assertInstanceOf('SugarBean',$emailTemplate); |
|
11 | + $this->assertInstanceOf('EmailTemplate',$emailTemplate); |
|
12 | + $this->assertInstanceOf('SugarBean',$emailTemplate); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('EmailTemplates', 'module_dir', $emailTemplate); |
|
15 | - $this->assertAttributeEquals('EmailTemplate', 'object_name', $emailTemplate); |
|
16 | - $this->assertAttributeEquals('email_templates', 'table_name', $emailTemplate); |
|
14 | + $this->assertAttributeEquals('EmailTemplates', 'module_dir', $emailTemplate); |
|
15 | + $this->assertAttributeEquals('EmailTemplate', 'object_name', $emailTemplate); |
|
16 | + $this->assertAttributeEquals('email_templates', 'table_name', $emailTemplate); |
|
17 | 17 | |
18 | - $this->assertAttributeEquals(true, 'new_schema', $emailTemplate); |
|
18 | + $this->assertAttributeEquals(true, 'new_schema', $emailTemplate); |
|
19 | 19 | |
20 | - } |
|
20 | + } |
|
21 | 21 | |
22 | - public function testgenerateFieldDefsJS() { |
|
22 | + public function testgenerateFieldDefsJS() { |
|
23 | 23 | |
24 | - error_reporting(E_ERROR | E_PARSE); |
|
24 | + error_reporting(E_ERROR | E_PARSE); |
|
25 | 25 | |
26 | 26 | |
27 | - $emailTemplate = new EmailTemplate(); |
|
27 | + $emailTemplate = new EmailTemplate(); |
|
28 | 28 | |
29 | - //execute the method and verify that it retunrs expected results |
|
30 | - $expected = 'var field_defs = {"Contacts":[{"name":"contact_name","value":"Name"},{"name":"contact_description","value":"Description"},{"name":"contact_salutation","value":"Salutation"},{"name":"contact_first_name","value":"First Name"},{"name":"contact_last_name","value":"Last Name"},{"name":"contact_full_name","value":"Name"},{"name":"contact_title","value":"Title"},{"name":"contact_photo","value":"Photo"},{"name":"contact_department","value":"Department"},{"name":"contact_phone_home","value":"Home"},{"name":"contact_email","value":"Any Email"},{"name":"contact_phone_mobile","value":"Mobile"},{"name":"contact_phone_work","value":"Office Phone"},{"name":"contact_phone_other","value":"Other Phone"},{"name":"contact_phone_fax","value":"Fax"},{"name":"contact_email1","value":"Email Address"},{"name":"contact_email2","value":"Other Email"},{"name":"contact_primary_address_street","value":"Primary Address Street"},{"name":"contact_primary_address_street_2","value":"Primary Address Street 2"},{"name":"contact_primary_address_street_3","value":"Primary Address Street 3"},{"name":"contact_primary_address_city","value":"Primary Address City"},{"name":"contact_primary_address_state","value":"Primary Address State"},{"name":"contact_primary_address_postalcode","value":"Primary Address Postal Code"},{"name":"contact_primary_address_country","value":"Primary Address Country"},{"name":"contact_alt_address_street","value":"Alternate Address Street"},{"name":"contact_alt_address_street_2","value":"Alternate Address Street 2"},{"name":"contact_alt_address_street_3","value":"Alternate Address Street 3"},{"name":"contact_alt_address_city","value":"Alternate Address City"},{"name":"contact_alt_address_state","value":"Alternate Address State"},{"name":"contact_alt_address_postalcode","value":"Alternate Address Postal Code"},{"name":"contact_alt_address_country","value":"Alternate Address Country"},{"name":"contact_assistant","value":"Assistant"},{"name":"contact_assistant_phone","value":"Assistant Phone"},{"name":"contact_email_addresses_non_primary","value":"Non Primary E-mails"},{"name":"contact_email_and_name1","value":"Name"},{"name":"contact_lead_source","value":"Lead Source"},{"name":"contact_birthdate","value":"Birthdate"},{"name":"contact_joomla_account_id","value":"LBL_JOOMLA_ACCOUNT_ID"},{"name":"contact_joomla_account_access","value":"LBL_JOOMLA_ACCOUNT_ACCESS"},{"name":"contact_portal_user_type","value":"Portal User Type"},{"name":"contact_event_status_name","value":"LBL_LIST_INVITE_STATUS_EVENT"},{"name":"contact_event_invite_id","value":"LBL_LIST_INVITE_STATUS"},{"name":"contact_event_accept_status","value":"LBL_LIST_ACCEPT_STATUS_EVENT"},{"name":"contact_event_status_id","value":"Accept Status"},{"name":"contact_jjwg_maps_address_c","value":""},{"name":"contact_jjwg_maps_geocode_status_c","value":""},{"name":"contact_jjwg_maps_lat_c","value":""},{"name":"contact_jjwg_maps_lng_c","value":""},{"name":"contact_refered_by","value":"Referred By"},{"name":"contact_lead_source_description","value":"Lead Source Description"},{"name":"contact_status","value":"Status"},{"name":"contact_status_description","value":"Status Description"},{"name":"contact_account_name","value":"Account Name"},{"name":"contact_account_id","value":"Account ID"},{"name":"contact_webtolead_email1","value":"Email Address"},{"name":"contact_webtolead_email2","value":"Other Email"},{"name":"contact_portal_name","value":"Portal Name"},{"name":"contact_portal_app","value":"Portal Application"},{"name":"contact_website","value":"Website"},{"name":"contact_tracker_key","value":"Tracker Key"}],"Accounts":[{"name":"account_name","value":"Name"},{"name":"account_description","value":"Description"},{"name":"account_account_type","value":"Type"},{"name":"account_industry","value":"Industry"},{"name":"account_annual_revenue","value":"Annual Revenue"},{"name":"account_phone_fax","value":"Fax"},{"name":"account_billing_address_street","value":"Billing Street"},{"name":"account_billing_address_street_2","value":"Billing Street 2"},{"name":"account_billing_address_street_3","value":"Billing Street 3"},{"name":"account_billing_address_street_4","value":"Billing Street 4"},{"name":"account_billing_address_city","value":"Billing City"},{"name":"account_billing_address_state","value":"Billing State"},{"name":"account_billing_address_postalcode","value":"Billing Postal Code"},{"name":"account_billing_address_country","value":"Billing Country"},{"name":"account_rating","value":"Rating"},{"name":"account_phone_office","value":"Office Phone"},{"name":"account_phone_alternate","value":"Alternate Phone"},{"name":"account_website","value":"Website"},{"name":"account_ownership","value":"Ownership"},{"name":"account_employees","value":"Employees"},{"name":"account_ticker_symbol","value":"Ticker Symbol"},{"name":"account_shipping_address_street","value":"Shipping Street"},{"name":"account_shipping_address_street_2","value":"Shipping Street 2"},{"name":"account_shipping_address_street_3","value":"Shipping Street 3"},{"name":"account_shipping_address_street_4","value":"Shipping Street 4"},{"name":"account_shipping_address_city","value":"Shipping City"},{"name":"account_shipping_address_state","value":"Shipping State"},{"name":"account_shipping_address_postalcode","value":"Shipping Postal Code"},{"name":"account_shipping_address_country","value":"Shipping Country"},{"name":"account_email1","value":"Email Address"},{"name":"account_email_addresses_non_primary","value":"Non Primary E-mails"},{"name":"account_parent_id","value":"Parent Account ID"},{"name":"account_sic_code","value":"SIC Code"},{"name":"account_email","value":"Any Email"},{"name":"account_jjwg_maps_address_c","value":""},{"name":"account_jjwg_maps_geocode_status_c","value":""},{"name":"account_jjwg_maps_lat_c","value":""},{"name":"account_jjwg_maps_lng_c","value":""}],"Users":[{"name":"contact_user_user_name","value":"User Name"},{"name":"contact_user_pwd_last_changed","value":"Password Last Changed"},{"name":"contact_user_first_name","value":"First Name"},{"name":"contact_user_last_name","value":"Last Name"},{"name":"contact_user_full_name","value":"Full Name"},{"name":"contact_user_name","value":"Full Name"},{"name":"contact_user_description","value":"Description"},{"name":"contact_user_title","value":"Title"},{"name":"contact_user_photo","value":"Photo"},{"name":"contact_user_department","value":"Department"},{"name":"contact_user_phone_home","value":"Home Phone"},{"name":"contact_user_phone_mobile","value":"Mobile"},{"name":"contact_user_phone_work","value":"Work Phone"},{"name":"contact_user_phone_other","value":"Other Phone"},{"name":"contact_user_phone_fax","value":"Fax"},{"name":"contact_user_status","value":"Status"},{"name":"contact_user_address_street","value":"Address Street"},{"name":"contact_user_address_city","value":"Address City"},{"name":"contact_user_address_state","value":"Address State"},{"name":"contact_user_address_country","value":"Address Country"},{"name":"contact_user_address_postalcode","value":"Address Postal Code"},{"name":"contact_user_usertype","value":"User Type"},{"name":"contact_user_employee_status","value":"Employee Status"},{"name":"contact_user_messenger_id","value":"IM Name"},{"name":"contact_user_messenger_type","value":"IM Type"},{"name":"contact_user_email1","value":"Email Address"},{"name":"contact_user_email_link_type","value":"Email Client"},{"name":"contact_user_securitygroup_noninherit_id","value":"LBL_securitygroup_noninherit_id"}]};'; |
|
31 | - $actual = $emailTemplate->generateFieldDefsJS(); |
|
32 | - //$this->assertSame($expected,$actual); |
|
29 | + //execute the method and verify that it retunrs expected results |
|
30 | + $expected = 'var field_defs = {"Contacts":[{"name":"contact_name","value":"Name"},{"name":"contact_description","value":"Description"},{"name":"contact_salutation","value":"Salutation"},{"name":"contact_first_name","value":"First Name"},{"name":"contact_last_name","value":"Last Name"},{"name":"contact_full_name","value":"Name"},{"name":"contact_title","value":"Title"},{"name":"contact_photo","value":"Photo"},{"name":"contact_department","value":"Department"},{"name":"contact_phone_home","value":"Home"},{"name":"contact_email","value":"Any Email"},{"name":"contact_phone_mobile","value":"Mobile"},{"name":"contact_phone_work","value":"Office Phone"},{"name":"contact_phone_other","value":"Other Phone"},{"name":"contact_phone_fax","value":"Fax"},{"name":"contact_email1","value":"Email Address"},{"name":"contact_email2","value":"Other Email"},{"name":"contact_primary_address_street","value":"Primary Address Street"},{"name":"contact_primary_address_street_2","value":"Primary Address Street 2"},{"name":"contact_primary_address_street_3","value":"Primary Address Street 3"},{"name":"contact_primary_address_city","value":"Primary Address City"},{"name":"contact_primary_address_state","value":"Primary Address State"},{"name":"contact_primary_address_postalcode","value":"Primary Address Postal Code"},{"name":"contact_primary_address_country","value":"Primary Address Country"},{"name":"contact_alt_address_street","value":"Alternate Address Street"},{"name":"contact_alt_address_street_2","value":"Alternate Address Street 2"},{"name":"contact_alt_address_street_3","value":"Alternate Address Street 3"},{"name":"contact_alt_address_city","value":"Alternate Address City"},{"name":"contact_alt_address_state","value":"Alternate Address State"},{"name":"contact_alt_address_postalcode","value":"Alternate Address Postal Code"},{"name":"contact_alt_address_country","value":"Alternate Address Country"},{"name":"contact_assistant","value":"Assistant"},{"name":"contact_assistant_phone","value":"Assistant Phone"},{"name":"contact_email_addresses_non_primary","value":"Non Primary E-mails"},{"name":"contact_email_and_name1","value":"Name"},{"name":"contact_lead_source","value":"Lead Source"},{"name":"contact_birthdate","value":"Birthdate"},{"name":"contact_joomla_account_id","value":"LBL_JOOMLA_ACCOUNT_ID"},{"name":"contact_joomla_account_access","value":"LBL_JOOMLA_ACCOUNT_ACCESS"},{"name":"contact_portal_user_type","value":"Portal User Type"},{"name":"contact_event_status_name","value":"LBL_LIST_INVITE_STATUS_EVENT"},{"name":"contact_event_invite_id","value":"LBL_LIST_INVITE_STATUS"},{"name":"contact_event_accept_status","value":"LBL_LIST_ACCEPT_STATUS_EVENT"},{"name":"contact_event_status_id","value":"Accept Status"},{"name":"contact_jjwg_maps_address_c","value":""},{"name":"contact_jjwg_maps_geocode_status_c","value":""},{"name":"contact_jjwg_maps_lat_c","value":""},{"name":"contact_jjwg_maps_lng_c","value":""},{"name":"contact_refered_by","value":"Referred By"},{"name":"contact_lead_source_description","value":"Lead Source Description"},{"name":"contact_status","value":"Status"},{"name":"contact_status_description","value":"Status Description"},{"name":"contact_account_name","value":"Account Name"},{"name":"contact_account_id","value":"Account ID"},{"name":"contact_webtolead_email1","value":"Email Address"},{"name":"contact_webtolead_email2","value":"Other Email"},{"name":"contact_portal_name","value":"Portal Name"},{"name":"contact_portal_app","value":"Portal Application"},{"name":"contact_website","value":"Website"},{"name":"contact_tracker_key","value":"Tracker Key"}],"Accounts":[{"name":"account_name","value":"Name"},{"name":"account_description","value":"Description"},{"name":"account_account_type","value":"Type"},{"name":"account_industry","value":"Industry"},{"name":"account_annual_revenue","value":"Annual Revenue"},{"name":"account_phone_fax","value":"Fax"},{"name":"account_billing_address_street","value":"Billing Street"},{"name":"account_billing_address_street_2","value":"Billing Street 2"},{"name":"account_billing_address_street_3","value":"Billing Street 3"},{"name":"account_billing_address_street_4","value":"Billing Street 4"},{"name":"account_billing_address_city","value":"Billing City"},{"name":"account_billing_address_state","value":"Billing State"},{"name":"account_billing_address_postalcode","value":"Billing Postal Code"},{"name":"account_billing_address_country","value":"Billing Country"},{"name":"account_rating","value":"Rating"},{"name":"account_phone_office","value":"Office Phone"},{"name":"account_phone_alternate","value":"Alternate Phone"},{"name":"account_website","value":"Website"},{"name":"account_ownership","value":"Ownership"},{"name":"account_employees","value":"Employees"},{"name":"account_ticker_symbol","value":"Ticker Symbol"},{"name":"account_shipping_address_street","value":"Shipping Street"},{"name":"account_shipping_address_street_2","value":"Shipping Street 2"},{"name":"account_shipping_address_street_3","value":"Shipping Street 3"},{"name":"account_shipping_address_street_4","value":"Shipping Street 4"},{"name":"account_shipping_address_city","value":"Shipping City"},{"name":"account_shipping_address_state","value":"Shipping State"},{"name":"account_shipping_address_postalcode","value":"Shipping Postal Code"},{"name":"account_shipping_address_country","value":"Shipping Country"},{"name":"account_email1","value":"Email Address"},{"name":"account_email_addresses_non_primary","value":"Non Primary E-mails"},{"name":"account_parent_id","value":"Parent Account ID"},{"name":"account_sic_code","value":"SIC Code"},{"name":"account_email","value":"Any Email"},{"name":"account_jjwg_maps_address_c","value":""},{"name":"account_jjwg_maps_geocode_status_c","value":""},{"name":"account_jjwg_maps_lat_c","value":""},{"name":"account_jjwg_maps_lng_c","value":""}],"Users":[{"name":"contact_user_user_name","value":"User Name"},{"name":"contact_user_pwd_last_changed","value":"Password Last Changed"},{"name":"contact_user_first_name","value":"First Name"},{"name":"contact_user_last_name","value":"Last Name"},{"name":"contact_user_full_name","value":"Full Name"},{"name":"contact_user_name","value":"Full Name"},{"name":"contact_user_description","value":"Description"},{"name":"contact_user_title","value":"Title"},{"name":"contact_user_photo","value":"Photo"},{"name":"contact_user_department","value":"Department"},{"name":"contact_user_phone_home","value":"Home Phone"},{"name":"contact_user_phone_mobile","value":"Mobile"},{"name":"contact_user_phone_work","value":"Work Phone"},{"name":"contact_user_phone_other","value":"Other Phone"},{"name":"contact_user_phone_fax","value":"Fax"},{"name":"contact_user_status","value":"Status"},{"name":"contact_user_address_street","value":"Address Street"},{"name":"contact_user_address_city","value":"Address City"},{"name":"contact_user_address_state","value":"Address State"},{"name":"contact_user_address_country","value":"Address Country"},{"name":"contact_user_address_postalcode","value":"Address Postal Code"},{"name":"contact_user_usertype","value":"User Type"},{"name":"contact_user_employee_status","value":"Employee Status"},{"name":"contact_user_messenger_id","value":"IM Name"},{"name":"contact_user_messenger_type","value":"IM Type"},{"name":"contact_user_email1","value":"Email Address"},{"name":"contact_user_email_link_type","value":"Email Client"},{"name":"contact_user_securitygroup_noninherit_id","value":"LBL_securitygroup_noninherit_id"}]};'; |
|
31 | + $actual = $emailTemplate->generateFieldDefsJS(); |
|
32 | + //$this->assertSame($expected,$actual); |
|
33 | 33 | |
34 | - $this->assertGreaterThan(0 , strlen($actual)); |
|
34 | + $this->assertGreaterThan(0 , strlen($actual)); |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | - public function testget_summary_text() { |
|
38 | + public function testget_summary_text() { |
|
39 | 39 | |
40 | - $emailTemplate = new EmailTemplate(); |
|
40 | + $emailTemplate = new EmailTemplate(); |
|
41 | 41 | |
42 | - //test without setting name |
|
43 | - $this->assertEquals(Null,$emailTemplate->get_summary_text()); |
|
42 | + //test without setting name |
|
43 | + $this->assertEquals(Null,$emailTemplate->get_summary_text()); |
|
44 | 44 | |
45 | - //test with name set |
|
46 | - $emailTemplate->name = "test"; |
|
47 | - $this->assertEquals('test',$emailTemplate->get_summary_text()); |
|
45 | + //test with name set |
|
46 | + $emailTemplate->name = "test"; |
|
47 | + $this->assertEquals('test',$emailTemplate->get_summary_text()); |
|
48 | 48 | |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - public function testcreate_export_query() { |
|
51 | + public function testcreate_export_query() { |
|
52 | 52 | |
53 | - $emailTemplate = new EmailTemplate(); |
|
53 | + $emailTemplate = new EmailTemplate(); |
|
54 | 54 | |
55 | - //test with empty string params |
|
56 | - $expected = " SELECT email_templates.* , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM email_templates LEFT JOIN users jt0 ON email_templates.assigned_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where email_templates.deleted=0"; |
|
57 | - $actual = $emailTemplate->create_export_query('',''); |
|
58 | - $this->assertSame($expected,$actual); |
|
55 | + //test with empty string params |
|
56 | + $expected = " SELECT email_templates.* , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM email_templates LEFT JOIN users jt0 ON email_templates.assigned_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where email_templates.deleted=0"; |
|
57 | + $actual = $emailTemplate->create_export_query('',''); |
|
58 | + $this->assertSame($expected,$actual); |
|
59 | 59 | |
60 | 60 | |
61 | - //test with valid string params |
|
62 | - $expected = " SELECT email_templates.* , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM email_templates LEFT JOIN users jt0 ON email_templates.assigned_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where (email_templates.name=\"\") AND email_templates.deleted=0"; |
|
63 | - $actual = $emailTemplate->create_export_query('email_templates.id','email_templates.name=""'); |
|
64 | - $this->assertSame($expected,$actual); |
|
61 | + //test with valid string params |
|
62 | + $expected = " SELECT email_templates.* , jt0.user_name assigned_user_name , jt0.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod FROM email_templates LEFT JOIN users jt0 ON email_templates.assigned_user_id=jt0.id AND jt0.deleted=0\n\n AND jt0.deleted=0 where (email_templates.name=\"\") AND email_templates.deleted=0"; |
|
63 | + $actual = $emailTemplate->create_export_query('email_templates.id','email_templates.name=""'); |
|
64 | + $this->assertSame($expected,$actual); |
|
65 | 65 | |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function testfill_in_additional_list_fields() { |
|
68 | + public function testfill_in_additional_list_fields() { |
|
69 | 69 | |
70 | - $emailTemplate = new EmailTemplate(); |
|
70 | + $emailTemplate = new EmailTemplate(); |
|
71 | 71 | |
72 | - //execute the method and test if it works and does not throws an exception. |
|
73 | - try { |
|
74 | - $emailTemplate->fill_in_additional_list_fields(); |
|
75 | - $this->assertTrue(true); |
|
76 | - } |
|
77 | - catch (Exception $e) { |
|
78 | - $this->fail(); |
|
79 | - } |
|
72 | + //execute the method and test if it works and does not throws an exception. |
|
73 | + try { |
|
74 | + $emailTemplate->fill_in_additional_list_fields(); |
|
75 | + $this->assertTrue(true); |
|
76 | + } |
|
77 | + catch (Exception $e) { |
|
78 | + $this->fail(); |
|
79 | + } |
|
80 | 80 | |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - public function testfill_in_additional_detail_fields() { |
|
83 | + public function testfill_in_additional_detail_fields() { |
|
84 | 84 | |
85 | - $emailTemplate = new EmailTemplate(); |
|
85 | + $emailTemplate = new EmailTemplate(); |
|
86 | 86 | |
87 | - //test with attributes preset and verify template variables are set accordingly |
|
87 | + //test with attributes preset and verify template variables are set accordingly |
|
88 | 88 | |
89 | - $emailTemplate->created_by = 1; |
|
90 | - $emailTemplate->modified_user_id = 1; |
|
91 | - $emailTemplate->assigned_user_id = 1; |
|
92 | - $emailTemplate->body_html = "<b>some html text</b>"; |
|
89 | + $emailTemplate->created_by = 1; |
|
90 | + $emailTemplate->modified_user_id = 1; |
|
91 | + $emailTemplate->assigned_user_id = 1; |
|
92 | + $emailTemplate->body_html = "<b>some html text</b>"; |
|
93 | 93 | |
94 | 94 | |
95 | - $emailTemplate->fill_in_additional_detail_fields(); |
|
95 | + $emailTemplate->fill_in_additional_detail_fields(); |
|
96 | 96 | |
97 | - $this->assertEquals("Administrator", $emailTemplate->created_by_name); |
|
98 | - $this->assertEquals("Administrator", $emailTemplate->modified_by_name); |
|
99 | - $this->assertEquals("Administrator", $emailTemplate->assigned_user_name); |
|
100 | - $this->assertEquals("some html text", $emailTemplate->body); |
|
97 | + $this->assertEquals("Administrator", $emailTemplate->created_by_name); |
|
98 | + $this->assertEquals("Administrator", $emailTemplate->modified_by_name); |
|
99 | + $this->assertEquals("Administrator", $emailTemplate->assigned_user_name); |
|
100 | + $this->assertEquals("some html text", $emailTemplate->body); |
|
101 | 101 | |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | - public function testfill_in_additional_parent_fields() { |
|
104 | + public function testfill_in_additional_parent_fields() { |
|
105 | 105 | |
106 | - $emailTemplate = new EmailTemplate(); |
|
106 | + $emailTemplate = new EmailTemplate(); |
|
107 | 107 | |
108 | - //execute the method and test if it works and does not throws an exception. |
|
109 | - try { |
|
110 | - $emailTemplate->fill_in_additional_parent_fields(); |
|
111 | - $this->assertTrue(true); |
|
112 | - } |
|
113 | - catch (Exception $e) { |
|
114 | - $this->fail(); |
|
115 | - } |
|
108 | + //execute the method and test if it works and does not throws an exception. |
|
109 | + try { |
|
110 | + $emailTemplate->fill_in_additional_parent_fields(); |
|
111 | + $this->assertTrue(true); |
|
112 | + } |
|
113 | + catch (Exception $e) { |
|
114 | + $this->fail(); |
|
115 | + } |
|
116 | 116 | |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | - public function testget_list_view_data() { |
|
119 | + public function testget_list_view_data() { |
|
120 | 120 | |
121 | - $emailTemplate = new EmailTemplate(); |
|
121 | + $emailTemplate = new EmailTemplate(); |
|
122 | 122 | |
123 | - //execute the method and verify that it retunrs expected results |
|
124 | - $expected = array ( |
|
125 | - 'DELETED' => 0, |
|
126 | - 'DATE_MODIFIED' => false, |
|
127 | - ); |
|
123 | + //execute the method and verify that it retunrs expected results |
|
124 | + $expected = array ( |
|
125 | + 'DELETED' => 0, |
|
126 | + 'DATE_MODIFIED' => false, |
|
127 | + ); |
|
128 | 128 | |
129 | - $actual = $emailTemplate->get_list_view_data(); |
|
130 | - $this->assertSame($expected,$actual); |
|
129 | + $actual = $emailTemplate->get_list_view_data(); |
|
130 | + $this->assertSame($expected,$actual); |
|
131 | 131 | |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | 134 | |
135 | - public function testparse_email_templateAndParse_tracker_urls() { |
|
135 | + public function testparse_email_templateAndParse_tracker_urls() { |
|
136 | 136 | |
137 | - $emailTemplate = new EmailTemplate(); |
|
137 | + $emailTemplate = new EmailTemplate(); |
|
138 | 138 | |
139 | 139 | |
140 | - //test parse_email_template |
|
141 | - $account = new Account(); |
|
142 | - $macro_nv = array(); |
|
140 | + //test parse_email_template |
|
141 | + $account = new Account(); |
|
142 | + $macro_nv = array(); |
|
143 | 143 | |
144 | - $expected = array( |
|
145 | - "subject"=> "test subject", "body_html"=>"test html", "body"=>"test body text" |
|
146 | - ); |
|
147 | - $actual = $emailTemplate->parse_email_template(array('subject'=>"test subject",'body_html'=>"test html",'body'=>"test body text"),'Accounts', $account, $macro_nv ); |
|
148 | - $this->assertSame($expected, $actual); |
|
144 | + $expected = array( |
|
145 | + "subject"=> "test subject", "body_html"=>"test html", "body"=>"test body text" |
|
146 | + ); |
|
147 | + $actual = $emailTemplate->parse_email_template(array('subject'=>"test subject",'body_html'=>"test html",'body'=>"test body text"),'Accounts', $account, $macro_nv ); |
|
148 | + $this->assertSame($expected, $actual); |
|
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | - //test Parse_tracker_urls |
|
153 | - $tracker_url_template= 'localhost/index.php?entryPoint=campaign_trackerv2&track=%s&identifier=tracker_key'; |
|
154 | - $removeme_url_template= 'localhost/index.php?entryPoint=removeme&identifier=tracker_key'; |
|
155 | - $tracker_urls = array(); |
|
152 | + //test Parse_tracker_urls |
|
153 | + $tracker_url_template= 'localhost/index.php?entryPoint=campaign_trackerv2&track=%s&identifier=tracker_key'; |
|
154 | + $removeme_url_template= 'localhost/index.php?entryPoint=removeme&identifier=tracker_key'; |
|
155 | + $tracker_urls = array(); |
|
156 | 156 | |
157 | - $result = $emailTemplate->parse_tracker_urls($actual, $tracker_url_template, $tracker_urls, $removeme_url_template); |
|
158 | - $this->assertSame($expected, $result); |
|
157 | + $result = $emailTemplate->parse_tracker_urls($actual, $tracker_url_template, $tracker_urls, $removeme_url_template); |
|
158 | + $this->assertSame($expected, $result); |
|
159 | 159 | |
160 | - } |
|
160 | + } |
|
161 | 161 | |
162 | 162 | |
163 | 163 | public function test_convertToType() { |
164 | 164 | |
165 | - $emailTemplate = new EmailTemplate(); |
|
165 | + $emailTemplate = new EmailTemplate(); |
|
166 | 166 | |
167 | - $this->assertEquals( 10 ,$emailTemplate->_convertToType('float',10)); |
|
168 | - $this->assertEquals( "test text" ,$emailTemplate->_convertToType('text',"test text")); |
|
169 | - $this->assertEquals( "$10.00" ,$emailTemplate->_convertToType('currency',10)); |
|
167 | + $this->assertEquals( 10 ,$emailTemplate->_convertToType('float',10)); |
|
168 | + $this->assertEquals( "test text" ,$emailTemplate->_convertToType('text',"test text")); |
|
169 | + $this->assertEquals( "$10.00" ,$emailTemplate->_convertToType('currency',10)); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
173 | 173 | |
174 | - public function test_parseUserValues() |
|
175 | - { |
|
176 | - $emailTemplate = new EmailTemplate(); |
|
177 | - $user = new User(1); |
|
178 | - $repl_arr = array("contact_user_name"=>""); |
|
174 | + public function test_parseUserValues() |
|
175 | + { |
|
176 | + $emailTemplate = new EmailTemplate(); |
|
177 | + $user = new User(1); |
|
178 | + $repl_arr = array("contact_user_name"=>""); |
|
179 | 179 | |
180 | - //execute the method and verify that it retunrs expected results |
|
180 | + //execute the method and verify that it retunrs expected results |
|
181 | 181 | |
182 | - $expected = array ( |
|
182 | + $expected = array ( |
|
183 | 183 | 'contact_user_name' => '', |
184 | 184 | 'contact_user_id' => '', |
185 | 185 | 'contact_user_user_name' => '', |
@@ -243,107 +243,107 @@ discard block |
||
243 | 243 | 'contact_user_securitygroup_noninherit_id' => '', |
244 | 244 | 'contact_user_securitygroup_noninheritable' => '', |
245 | 245 | 'contact_user_securitygroup_primary_group' => '', |
246 | - ); |
|
246 | + ); |
|
247 | 247 | |
248 | - $actual = $emailTemplate->_parseUserValues($repl_arr, $user); |
|
249 | - $this->assertSame($expected, $actual); |
|
248 | + $actual = $emailTemplate->_parseUserValues($repl_arr, $user); |
|
249 | + $this->assertSame($expected, $actual); |
|
250 | 250 | |
251 | - } |
|
251 | + } |
|
252 | 252 | |
253 | 253 | |
254 | - public function testparse_template_bean() |
|
255 | - { |
|
254 | + public function testparse_template_bean() |
|
255 | + { |
|
256 | 256 | |
257 | - $emailTemplate = new EmailTemplate(); |
|
258 | - $contact = new Contact(); |
|
259 | - $user = new User(1); |
|
260 | - $account = new Account(); |
|
257 | + $emailTemplate = new EmailTemplate(); |
|
258 | + $contact = new Contact(); |
|
259 | + $user = new User(1); |
|
260 | + $account = new Account(); |
|
261 | 261 | |
262 | - $contact->name = "test"; |
|
263 | - $account->name = "test"; |
|
262 | + $contact->name = "test"; |
|
263 | + $account->name = "test"; |
|
264 | 264 | |
265 | - //test with empty string |
|
266 | - $actual = $emailTemplate->parse_template_bean("", "Contacts", $contact); |
|
267 | - $this->assertEquals("", $actual); |
|
265 | + //test with empty string |
|
266 | + $actual = $emailTemplate->parse_template_bean("", "Contacts", $contact); |
|
267 | + $this->assertEquals("", $actual); |
|
268 | 268 | |
269 | - //test with valid string |
|
270 | - $actual = $emailTemplate->parse_template_bean("test", "Users", $user ); |
|
271 | - $this->assertEquals("test", $actual); |
|
269 | + //test with valid string |
|
270 | + $actual = $emailTemplate->parse_template_bean("test", "Users", $user ); |
|
271 | + $this->assertEquals("test", $actual); |
|
272 | 272 | |
273 | - //test with empty string and different module |
|
274 | - $actual = $emailTemplate->parse_template_bean("", "Accounts", $account ); |
|
275 | - $this->assertEquals("", $actual); |
|
273 | + //test with empty string and different module |
|
274 | + $actual = $emailTemplate->parse_template_bean("", "Accounts", $account ); |
|
275 | + $this->assertEquals("", $actual); |
|
276 | 276 | |
277 | - } |
|
277 | + } |
|
278 | 278 | |
279 | 279 | |
280 | - public function testparse_template() |
|
281 | - { |
|
282 | - $emailTemplate = new EmailTemplate(); |
|
283 | - $bean_arr = array("Users" => 1, "Leads" => 1); |
|
280 | + public function testparse_template() |
|
281 | + { |
|
282 | + $emailTemplate = new EmailTemplate(); |
|
283 | + $bean_arr = array("Users" => 1, "Leads" => 1); |
|
284 | 284 | |
285 | 285 | |
286 | - //test with empty string |
|
287 | - $result = $emailTemplate->parse_template("", $bean_arr); |
|
288 | - $this->assertEquals("",$result); |
|
286 | + //test with empty string |
|
287 | + $result = $emailTemplate->parse_template("", $bean_arr); |
|
288 | + $this->assertEquals("",$result); |
|
289 | 289 | |
290 | 290 | |
291 | - //test with valid string |
|
292 | - $result = $emailTemplate->parse_template("some value", $bean_arr); |
|
293 | - $this->assertEquals("some value",$result); |
|
291 | + //test with valid string |
|
292 | + $result = $emailTemplate->parse_template("some value", $bean_arr); |
|
293 | + $this->assertEquals("some value",$result); |
|
294 | 294 | |
295 | - } |
|
295 | + } |
|
296 | 296 | |
297 | - public function testbean_implements() |
|
298 | - { |
|
299 | - $emailTemplate = new EmailTemplate(); |
|
297 | + public function testbean_implements() |
|
298 | + { |
|
299 | + $emailTemplate = new EmailTemplate(); |
|
300 | 300 | |
301 | - $this->assertEquals(false, $emailTemplate->bean_implements('')); //test with blank value |
|
302 | - $this->assertEquals(false, $emailTemplate->bean_implements('test')); //test with invalid value |
|
303 | - $this->assertEquals(true, $emailTemplate->bean_implements('ACL')); //test with valid value |
|
301 | + $this->assertEquals(false, $emailTemplate->bean_implements('')); //test with blank value |
|
302 | + $this->assertEquals(false, $emailTemplate->bean_implements('test')); //test with invalid value |
|
303 | + $this->assertEquals(true, $emailTemplate->bean_implements('ACL')); //test with valid value |
|
304 | 304 | |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | 307 | public function testgetTypeOptionsForSearch() |
308 | - { |
|
309 | - //execute the method and verify that it retunrs expected results |
|
310 | - $expected = array ( |
|
311 | - '' => '', |
|
312 | - 'campaign' => 'Campaign', |
|
313 | - 'email' => 'Email', |
|
314 | - ); |
|
315 | - $actual = EmailTemplate::getTypeOptionsForSearch(); |
|
316 | - $this->assertSame($expected,$actual); |
|
308 | + { |
|
309 | + //execute the method and verify that it retunrs expected results |
|
310 | + $expected = array ( |
|
311 | + '' => '', |
|
312 | + 'campaign' => 'Campaign', |
|
313 | + 'email' => 'Email', |
|
314 | + ); |
|
315 | + $actual = EmailTemplate::getTypeOptionsForSearch(); |
|
316 | + $this->assertSame($expected,$actual); |
|
317 | 317 | |
318 | 318 | } |
319 | 319 | |
320 | - public function testis_used_by_email_marketing() |
|
321 | - { |
|
322 | - $emailTemplate = new EmailTemplate(); |
|
320 | + public function testis_used_by_email_marketing() |
|
321 | + { |
|
322 | + $emailTemplate = new EmailTemplate(); |
|
323 | 323 | |
324 | - //test without id attribute |
|
325 | - $this->assertEquals(false,$emailTemplate->is_used_by_email_marketing()); |
|
324 | + //test without id attribute |
|
325 | + $this->assertEquals(false,$emailTemplate->is_used_by_email_marketing()); |
|
326 | 326 | |
327 | 327 | |
328 | - //test with id attribute |
|
329 | - $emailTemplate->id = 1; |
|
330 | - $this->assertEquals(false,$emailTemplate->is_used_by_email_marketing()); |
|
331 | - } |
|
328 | + //test with id attribute |
|
329 | + $emailTemplate->id = 1; |
|
330 | + $this->assertEquals(false,$emailTemplate->is_used_by_email_marketing()); |
|
331 | + } |
|
332 | 332 | |
333 | 333 | public function testcleanBean() |
334 | 334 | { |
335 | 335 | |
336 | - $emailTemplate = new EmailTemplate(); |
|
336 | + $emailTemplate = new EmailTemplate(); |
|
337 | 337 | |
338 | - //test without body_html attribute |
|
339 | - $emailTemplate->cleanBean(); |
|
340 | - $this->assertEquals("",$emailTemplate->body_html); |
|
338 | + //test without body_html attribute |
|
339 | + $emailTemplate->cleanBean(); |
|
340 | + $this->assertEquals("",$emailTemplate->body_html); |
|
341 | 341 | |
342 | 342 | |
343 | - //test with body_html attribute |
|
344 | - $emailTemplate->body_html = "<h1>text</h1>"; |
|
345 | - $emailTemplate->cleanBean(); |
|
346 | - $this->assertEquals("<h1>text</h1>",$emailTemplate->body_html); |
|
343 | + //test with body_html attribute |
|
344 | + $emailTemplate->body_html = "<h1>text</h1>"; |
|
345 | + $emailTemplate->cleanBean(); |
|
346 | + $this->assertEquals("<h1>text</h1>",$emailTemplate->body_html); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 |
@@ -3,67 +3,67 @@ |
||
3 | 3 | |
4 | 4 | class AOW_ActionTest extends PHPUnit_Framework_TestCase { |
5 | 5 | |
6 | - public function testAOW_Action(){ |
|
6 | + public function testAOW_Action(){ |
|
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $aowAction = new AOW_Action(); |
|
10 | - $this->assertInstanceOf('AOW_Action',$aowAction); |
|
11 | - $this->assertInstanceOf('Basic',$aowAction); |
|
12 | - $this->assertInstanceOf('SugarBean',$aowAction); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $aowAction = new AOW_Action(); |
|
10 | + $this->assertInstanceOf('AOW_Action',$aowAction); |
|
11 | + $this->assertInstanceOf('Basic',$aowAction); |
|
12 | + $this->assertInstanceOf('SugarBean',$aowAction); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('AOW_Actions', 'module_dir', $aowAction); |
|
15 | - $this->assertAttributeEquals('AOW_Action', 'object_name', $aowAction); |
|
16 | - $this->assertAttributeEquals('aow_actions', 'table_name', $aowAction); |
|
17 | - $this->assertAttributeEquals(true, 'new_schema', $aowAction); |
|
18 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowAction); |
|
19 | - $this->assertAttributeEquals(false, 'importable', $aowAction); |
|
20 | - $this->assertAttributeEquals(false, 'tracker_visibility', $aowAction); |
|
14 | + $this->assertAttributeEquals('AOW_Actions', 'module_dir', $aowAction); |
|
15 | + $this->assertAttributeEquals('AOW_Action', 'object_name', $aowAction); |
|
16 | + $this->assertAttributeEquals('aow_actions', 'table_name', $aowAction); |
|
17 | + $this->assertAttributeEquals(true, 'new_schema', $aowAction); |
|
18 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $aowAction); |
|
19 | + $this->assertAttributeEquals(false, 'importable', $aowAction); |
|
20 | + $this->assertAttributeEquals(false, 'tracker_visibility', $aowAction); |
|
21 | 21 | |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | 24 | public function testsave_lines(){ |
25 | 25 | |
26 | - error_reporting(E_ERROR | E_PARSE); |
|
26 | + error_reporting(E_ERROR | E_PARSE); |
|
27 | 27 | |
28 | - $aowAction = new AOW_Action(); |
|
28 | + $aowAction = new AOW_Action(); |
|
29 | 29 | |
30 | - //populate required values |
|
31 | - $post_data= Array(); |
|
32 | - $post_data["name"] = Array('test1','test2'); |
|
33 | - $post_data["action"] = Array('action1','action2'); |
|
34 | - $post_data["param"] = Array(array('param1'=>'value'),array('value'=>array('param2'=>'value'))); |
|
30 | + //populate required values |
|
31 | + $post_data= Array(); |
|
32 | + $post_data["name"] = Array('test1','test2'); |
|
33 | + $post_data["action"] = Array('action1','action2'); |
|
34 | + $post_data["param"] = Array(array('param1'=>'value'),array('value'=>array('param2'=>'value'))); |
|
35 | 35 | |
36 | 36 | |
37 | - //create parent bean |
|
38 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
39 | - $aowWorkFlow->id = 1; |
|
37 | + //create parent bean |
|
38 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
39 | + $aowWorkFlow->id = 1; |
|
40 | 40 | |
41 | 41 | |
42 | - $aowAction->save_lines($post_data, $aowWorkFlow); |
|
42 | + $aowAction->save_lines($post_data, $aowWorkFlow); |
|
43 | 43 | |
44 | 44 | |
45 | - //get the linked beans and verify if records created |
|
46 | - $aow_actions = $aowWorkFlow->get_linked_beans('aow_actions', $aowWorkFlow->object_name); |
|
47 | - $this->assertEquals(count($post_data["action"]), count($aow_actions) ); |
|
45 | + //get the linked beans and verify if records created |
|
46 | + $aow_actions = $aowWorkFlow->get_linked_beans('aow_actions', $aowWorkFlow->object_name); |
|
47 | + $this->assertEquals(count($post_data["action"]), count($aow_actions) ); |
|
48 | 48 | |
49 | 49 | |
50 | - //cleanup afterwards |
|
51 | - foreach($aow_actions as $lineItem){ |
|
52 | - $lineItem->mark_deleted($lineItem->id); |
|
53 | - } |
|
50 | + //cleanup afterwards |
|
51 | + foreach($aow_actions as $lineItem){ |
|
52 | + $lineItem->mark_deleted($lineItem->id); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
57 | - public function testbean_implements(){ |
|
57 | + public function testbean_implements(){ |
|
58 | 58 | |
59 | - error_reporting(E_ERROR | E_PARSE); |
|
59 | + error_reporting(E_ERROR | E_PARSE); |
|
60 | 60 | |
61 | - $aowAction = new AOW_Action(); |
|
62 | - $this->assertEquals(false, $aowAction->bean_implements('')); //test with blank value |
|
63 | - $this->assertEquals(false, $aowAction->bean_implements('test')); //test with invalid value |
|
64 | - $this->assertEquals(false, $aowAction->bean_implements('ACL')); //test with valid value |
|
61 | + $aowAction = new AOW_Action(); |
|
62 | + $this->assertEquals(false, $aowAction->bean_implements('')); //test with blank value |
|
63 | + $this->assertEquals(false, $aowAction->bean_implements('test')); //test with invalid value |
|
64 | + $this->assertEquals(false, $aowAction->bean_implements('ACL')); //test with valid value |
|
65 | 65 | |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | ?> |
@@ -4,264 +4,264 @@ |
||
4 | 4 | class EmailManTest extends PHPUnit_Framework_TestCase{ |
5 | 5 | |
6 | 6 | |
7 | - public function testtoString(){ |
|
7 | + public function testtoString(){ |
|
8 | 8 | |
9 | - error_reporting(E_ERROR | E_PARSE); |
|
9 | + error_reporting(E_ERROR | E_PARSE); |
|
10 | 10 | |
11 | - $emailMan = new EmailMan(); |
|
11 | + $emailMan = new EmailMan(); |
|
12 | 12 | |
13 | - //execute the method without setting attributes and verify that it retunrs expected results |
|
14 | - $expected = "EmailMan:\nid = ,user_id= module = , related_id = , related_type = ,list_id = , send_date_time= \n"; |
|
15 | - $actual = $emailMan->toString(); |
|
16 | - $this->assertSame($expected,$actual); |
|
13 | + //execute the method without setting attributes and verify that it retunrs expected results |
|
14 | + $expected = "EmailMan:\nid = ,user_id= module = , related_id = , related_type = ,list_id = , send_date_time= \n"; |
|
15 | + $actual = $emailMan->toString(); |
|
16 | + $this->assertSame($expected,$actual); |
|
17 | 17 | |
18 | 18 | |
19 | - //execute the method with attributes set and verify that it retunrs expected results |
|
20 | - $emailMan->id = 1; |
|
21 | - $emailMan->user_id = 1; |
|
22 | - $emailMan->module = "test"; |
|
23 | - $emailMan->related_id = 1; |
|
24 | - $emailMan->related_type = "test"; |
|
25 | - $emailMan->list_id =1; |
|
26 | - $emailMan->send_date_time = "1/1/2015"; |
|
19 | + //execute the method with attributes set and verify that it retunrs expected results |
|
20 | + $emailMan->id = 1; |
|
21 | + $emailMan->user_id = 1; |
|
22 | + $emailMan->module = "test"; |
|
23 | + $emailMan->related_id = 1; |
|
24 | + $emailMan->related_type = "test"; |
|
25 | + $emailMan->list_id =1; |
|
26 | + $emailMan->send_date_time = "1/1/2015"; |
|
27 | 27 | |
28 | - $expected = "EmailMan:\nid = 1 ,user_id= 1 module = test , related_id = 1 , related_type = test ,list_id = 1, send_date_time= 1/1/2015\n"; |
|
29 | - $actual = $emailMan->toString(); |
|
30 | - $this->assertSame($expected,$actual); |
|
28 | + $expected = "EmailMan:\nid = 1 ,user_id= 1 module = test , related_id = 1 , related_type = test ,list_id = 1, send_date_time= 1/1/2015\n"; |
|
29 | + $actual = $emailMan->toString(); |
|
30 | + $this->assertSame($expected,$actual); |
|
31 | 31 | |
32 | 32 | |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - public function testEmailMan() { |
|
35 | + public function testEmailMan() { |
|
36 | 36 | |
37 | - //execute the contructor and check for the Object type and attributes |
|
38 | - $emailMan = new EmailMan(); |
|
39 | - $this->assertInstanceOf('EmailMan',$emailMan); |
|
40 | - $this->assertInstanceOf('SugarBean',$emailMan); |
|
37 | + //execute the contructor and check for the Object type and attributes |
|
38 | + $emailMan = new EmailMan(); |
|
39 | + $this->assertInstanceOf('EmailMan',$emailMan); |
|
40 | + $this->assertInstanceOf('SugarBean',$emailMan); |
|
41 | 41 | |
42 | - $this->assertAttributeEquals('EmailMan', 'module_dir', $emailMan); |
|
43 | - $this->assertAttributeEquals('EmailMan', 'object_name', $emailMan); |
|
44 | - $this->assertAttributeEquals('emailman', 'table_name', $emailMan); |
|
42 | + $this->assertAttributeEquals('EmailMan', 'module_dir', $emailMan); |
|
43 | + $this->assertAttributeEquals('EmailMan', 'object_name', $emailMan); |
|
44 | + $this->assertAttributeEquals('emailman', 'table_name', $emailMan); |
|
45 | 45 | |
46 | - $this->assertAttributeEquals(false, 'test', $emailMan); |
|
46 | + $this->assertAttributeEquals(false, 'test', $emailMan); |
|
47 | 47 | |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | 50 | public function testcreate_new_list_query() { |
51 | 51 | |
52 | - $emailMan = new EmailMan(); |
|
52 | + $emailMan = new EmailMan(); |
|
53 | 53 | |
54 | - //test with empty string params |
|
55 | - $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.deleted=0"; |
|
56 | - $actual = $emailMan->create_new_list_query('',''); |
|
57 | - $this->assertSame($expected,$actual); |
|
54 | + //test with empty string params |
|
55 | + $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.deleted=0"; |
|
56 | + $actual = $emailMan->create_new_list_query('',''); |
|
57 | + $this->assertSame($expected,$actual); |
|
58 | 58 | |
59 | 59 | |
60 | - //test with valid string params |
|
61 | - $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.user_id=\"\" AND emailman.deleted=0"; |
|
62 | - $actual = $emailMan->create_new_list_query('emailman.id','emailman.user_id=""'); |
|
63 | - $this->assertSame($expected,$actual); |
|
60 | + //test with valid string params |
|
61 | + $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.user_id=\"\" AND emailman.deleted=0"; |
|
62 | + $actual = $emailMan->create_new_list_query('emailman.id','emailman.user_id=""'); |
|
63 | + $this->assertSame($expected,$actual); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function testcreate_queue_items_query() { |
68 | 68 | |
69 | - $emailMan = new EmailMan(); |
|
69 | + $emailMan = new EmailMan(); |
|
70 | 70 | |
71 | - //without parameters |
|
72 | - $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.deleted=0"; |
|
73 | - $actual = $emailMan->create_queue_items_query('',''); |
|
74 | - $this->assertSame($expected,$actual); |
|
71 | + //without parameters |
|
72 | + $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id WHERE emailman.deleted=0"; |
|
73 | + $actual = $emailMan->create_queue_items_query('',''); |
|
74 | + $this->assertSame($expected,$actual); |
|
75 | 75 | |
76 | - //with parameters |
|
77 | - $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id INNER JOIN (select min(id) as id from emailman em GROUP BY em.user_id ) secondary\n on emailman.id = secondary.id WHERE emailman.user_id=\"\" AND emailman.deleted=0"; |
|
78 | - $actual = $emailMan->create_queue_items_query('emailman.id','emailman.user_id=""', array() ,array("group_by"=>"emailman.user_id")); |
|
79 | - $this->assertSame($expected,$actual); |
|
76 | + //with parameters |
|
77 | + $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id INNER JOIN (select min(id) as id from emailman em GROUP BY em.user_id ) secondary\n on emailman.id = secondary.id WHERE emailman.user_id=\"\" AND emailman.deleted=0"; |
|
78 | + $actual = $emailMan->create_queue_items_query('emailman.id','emailman.user_id=""', array() ,array("group_by"=>"emailman.user_id")); |
|
79 | + $this->assertSame($expected,$actual); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | - public function testcreate_list_query(){ |
|
83 | + public function testcreate_list_query(){ |
|
84 | 84 | |
85 | - $emailMan = new EmailMan(); |
|
85 | + $emailMan = new EmailMan(); |
|
86 | 86 | |
87 | - //test with empty string params |
|
88 | - $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id where emailman.deleted=0"; |
|
89 | - $actual = $emailMan->create_list_query('',''); |
|
90 | - $this->assertSame($expected,$actual); |
|
87 | + //test with empty string params |
|
88 | + $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id where emailman.deleted=0"; |
|
89 | + $actual = $emailMan->create_list_query('',''); |
|
90 | + $this->assertSame($expected,$actual); |
|
91 | 91 | |
92 | 92 | |
93 | - //test with valid string params |
|
94 | - $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id where emailman.user_id=\"\" AND emailman.deleted=0"; |
|
95 | - $actual = $emailMan->create_list_query('emailman.id','emailman.user_id=""'); |
|
96 | - $this->assertSame($expected,$actual); |
|
93 | + //test with valid string params |
|
94 | + $expected = "SELECT emailman.* ,\n campaigns.name as campaign_name,\n email_marketing.name as message_name,\n (CASE related_type\n WHEN 'Contacts' THEN LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,''))))\n WHEN 'Leads' THEN LTRIM(RTRIM(CONCAT(IFNULL(leads.first_name,''),' ',IFNULL(leads.last_name,''))))\n WHEN 'Accounts' THEN accounts.name\n WHEN 'Users' THEN LTRIM(RTRIM(CONCAT(IFNULL(users.first_name,''),' ',IFNULL(users.last_name,''))))\n WHEN 'Prospects' THEN LTRIM(RTRIM(CONCAT(IFNULL(prospects.first_name,''),' ',IFNULL(prospects.last_name,''))))\n END) recipient_name FROM emailman\n LEFT JOIN users ON users.id = emailman.related_id and emailman.related_type ='Users'\n LEFT JOIN contacts ON contacts.id = emailman.related_id and emailman.related_type ='Contacts'\n LEFT JOIN leads ON leads.id = emailman.related_id and emailman.related_type ='Leads'\n LEFT JOIN accounts ON accounts.id = emailman.related_id and emailman.related_type ='Accounts'\n LEFT JOIN prospects ON prospects.id = emailman.related_id and emailman.related_type ='Prospects'\n LEFT JOIN prospect_lists ON prospect_lists.id = emailman.list_id\n LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = emailman.related_id and emailman.related_type = email_addr_bean_rel.bean_module and email_addr_bean_rel.primary_address = 1 and email_addr_bean_rel.deleted=0\n LEFT JOIN campaigns ON campaigns.id = emailman.campaign_id\n LEFT JOIN email_marketing ON email_marketing.id = emailman.marketing_id where emailman.user_id=\"\" AND emailman.deleted=0"; |
|
95 | + $actual = $emailMan->create_list_query('emailman.id','emailman.user_id=""'); |
|
96 | + $this->assertSame($expected,$actual); |
|
97 | 97 | |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | public function testget_list_view_data() |
101 | 101 | { |
102 | 102 | |
103 | - $emailMan = new EmailMan(); |
|
103 | + $emailMan = new EmailMan(); |
|
104 | 104 | |
105 | - $expected = array ( |
|
106 | - 'IN_QUEUE' => '0', |
|
107 | - 'SEND_ATTEMPTS' => '0', |
|
108 | - 'DELETED' => '0', |
|
109 | - 'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=EmailMan\\u0026parent_id=\\u0026parent_name=\\u0026to_addrs_ids=\\u0026to_addrs_names=\\u0026to_addrs_emails=\\u0026to_email_addrs=%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=EmailMan\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"EmailMan","parent_id":"","parent_name":"","to_addrs_ids":"","to_addrs_names":"","to_addrs_emails":"","to_email_addrs":" \\u003C\\u003E","return_module":"EmailMan","return_action":"ListView","return_id":""}});\' class=\'\'>', |
|
110 | - ); |
|
105 | + $expected = array ( |
|
106 | + 'IN_QUEUE' => '0', |
|
107 | + 'SEND_ATTEMPTS' => '0', |
|
108 | + 'DELETED' => '0', |
|
109 | + 'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=EmailMan\\u0026parent_id=\\u0026parent_name=\\u0026to_addrs_ids=\\u0026to_addrs_names=\\u0026to_addrs_emails=\\u0026to_email_addrs=%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=EmailMan\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"EmailMan","parent_id":"","parent_name":"","to_addrs_ids":"","to_addrs_names":"","to_addrs_emails":"","to_email_addrs":" \\u003C\\u003E","return_module":"EmailMan","return_action":"ListView","return_id":""}});\' class=\'\'>', |
|
110 | + ); |
|
111 | 111 | |
112 | - $actual = $emailMan->get_list_view_data(); |
|
113 | - $this->assertSame($expected, $actual); |
|
112 | + $actual = $emailMan->get_list_view_data(); |
|
113 | + $this->assertSame($expected, $actual); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | - public function testset_as_sent() |
|
119 | - { |
|
120 | - $emailMan = new EmailMan(); |
|
118 | + public function testset_as_sent() |
|
119 | + { |
|
120 | + $emailMan = new EmailMan(); |
|
121 | 121 | |
122 | - //execute the method and test if it works and does not throws an exception. |
|
123 | - //test with delete true/default |
|
124 | - try { |
|
125 | - $emailMan->set_as_sent("[email protected]", true,null,null,'send error'); |
|
126 | - $this->assertTrue(true); |
|
127 | - } |
|
128 | - catch (Exception $e) { |
|
129 | - $this->fail(); |
|
130 | - } |
|
122 | + //execute the method and test if it works and does not throws an exception. |
|
123 | + //test with delete true/default |
|
124 | + try { |
|
125 | + $emailMan->set_as_sent("[email protected]", true,null,null,'send error'); |
|
126 | + $this->assertTrue(true); |
|
127 | + } |
|
128 | + catch (Exception $e) { |
|
129 | + $this->fail(); |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - //execute the method and test if it works and does not throws an exception. |
|
134 | - //test with delete false |
|
135 | - try { |
|
136 | - $emailMan->set_as_sent("[email protected]", false,null,null,'send error'); |
|
137 | - $this->assertTrue(true); |
|
138 | - } |
|
139 | - catch (Exception $e) { |
|
140 | - $this->fail(); |
|
141 | - } |
|
133 | + //execute the method and test if it works and does not throws an exception. |
|
134 | + //test with delete false |
|
135 | + try { |
|
136 | + $emailMan->set_as_sent("[email protected]", false,null,null,'send error'); |
|
137 | + $this->assertTrue(true); |
|
138 | + } |
|
139 | + catch (Exception $e) { |
|
140 | + $this->fail(); |
|
141 | + } |
|
142 | 142 | |
143 | 143 | |
144 | - } |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | 147 | public function testcreate_indiv_email() |
148 | 148 | { |
149 | 149 | |
150 | - $emailMan = new EmailMan(); |
|
150 | + $emailMan = new EmailMan(); |
|
151 | 151 | |
152 | - $result = $emailMan->create_indiv_email(new Contact(),new Email()); |
|
152 | + $result = $emailMan->create_indiv_email(new Contact(),new Email()); |
|
153 | 153 | |
154 | - //test for record ID to verify that record is saved |
|
155 | - $this->assertEquals(36, strlen($result)); |
|
154 | + //test for record ID to verify that record is saved |
|
155 | + $this->assertEquals(36, strlen($result)); |
|
156 | 156 | |
157 | - $email = new Email(); |
|
158 | - $email->mark_deleted($result); |
|
157 | + $email = new Email(); |
|
158 | + $email->mark_deleted($result); |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | 163 | public function testverify_campaign() |
164 | 164 | { |
165 | - $emailMan = new EmailMan(); |
|
166 | - $result = $emailMan->verify_campaign(''); |
|
167 | - $this->assertEquals(false, $result); |
|
165 | + $emailMan = new EmailMan(); |
|
166 | + $result = $emailMan->verify_campaign(''); |
|
167 | + $this->assertEquals(false, $result); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
171 | - public function testsendEmail() |
|
172 | - { |
|
173 | - $emailMan = new EmailMan(); |
|
171 | + public function testsendEmail() |
|
172 | + { |
|
173 | + $emailMan = new EmailMan(); |
|
174 | 174 | |
175 | - //test without setting any attributes |
|
176 | - $result = $emailMan->sendEmail(new Email(),1,true); |
|
177 | - $this->assertEquals(false,$result); |
|
175 | + //test without setting any attributes |
|
176 | + $result = $emailMan->sendEmail(new Email(),1,true); |
|
177 | + $this->assertEquals(false,$result); |
|
178 | 178 | |
179 | - //test with related type attribute set |
|
180 | - $emailMan->related_type = "Contacts"; |
|
181 | - $emailMan->related_id = 1; |
|
182 | - $result = $emailMan->sendEmail(new Email(),1,true); |
|
183 | - $this->assertEquals(true,$result); |
|
179 | + //test with related type attribute set |
|
180 | + $emailMan->related_type = "Contacts"; |
|
181 | + $emailMan->related_id = 1; |
|
182 | + $result = $emailMan->sendEmail(new Email(),1,true); |
|
183 | + $this->assertEquals(true,$result); |
|
184 | 184 | |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - public function testvalid_email_address() { |
|
189 | + public function testvalid_email_address() { |
|
190 | 190 | |
191 | - $emailMan = new EmailMan(); |
|
191 | + $emailMan = new EmailMan(); |
|
192 | 192 | |
193 | - $this->assertEquals(False,$emailMan->valid_email_address("")); |
|
194 | - $this->assertEquals(False,$emailMan->valid_email_address("test")); |
|
195 | - $this->assertEquals(true,$emailMan->valid_email_address("[email protected]")); |
|
193 | + $this->assertEquals(False,$emailMan->valid_email_address("")); |
|
194 | + $this->assertEquals(False,$emailMan->valid_email_address("test")); |
|
195 | + $this->assertEquals(true,$emailMan->valid_email_address("[email protected]")); |
|
196 | 196 | |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | 201 | public function testis_primary_email_address() |
202 | 202 | { |
203 | - $emailMan = new EmailMan(); |
|
203 | + $emailMan = new EmailMan(); |
|
204 | 204 | |
205 | - $bean = new Contact(); |
|
205 | + $bean = new Contact(); |
|
206 | 206 | |
207 | - //test without setting any email |
|
208 | - $this->assertEquals(False, $emailMan->is_primary_email_address($bean) ); |
|
207 | + //test without setting any email |
|
208 | + $this->assertEquals(False, $emailMan->is_primary_email_address($bean) ); |
|
209 | 209 | |
210 | - //test with a dummy email set |
|
211 | - $bean->email1 = "[email protected]"; |
|
212 | - $this->assertEquals(False, $emailMan->is_primary_email_address($bean) ); |
|
210 | + //test with a dummy email set |
|
211 | + $bean->email1 = "[email protected]"; |
|
212 | + $this->assertEquals(False, $emailMan->is_primary_email_address($bean) ); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
216 | 216 | public function testcreate_export_query() |
217 | 217 | { |
218 | 218 | |
219 | - $emailMan = new EmailMan(); |
|
219 | + $emailMan = new EmailMan(); |
|
220 | 220 | |
221 | - //test with empty string params |
|
222 | - $expected = "SELECT emailman.* FROM emailman where ( emailman.deleted IS NULL OR emailman.deleted=0 )"; |
|
223 | - $actual = $emailMan->create_export_query('',''); |
|
224 | - $this->assertSame($expected,$actual); |
|
221 | + //test with empty string params |
|
222 | + $expected = "SELECT emailman.* FROM emailman where ( emailman.deleted IS NULL OR emailman.deleted=0 )"; |
|
223 | + $actual = $emailMan->create_export_query('',''); |
|
224 | + $this->assertSame($expected,$actual); |
|
225 | 225 | |
226 | 226 | |
227 | - //test with valid string params |
|
228 | - $expected = "SELECT emailman.* FROM emailman where (emailman.user_id=\"\") AND ( emailman.deleted IS NULL OR emailman.deleted=0 )"; |
|
229 | - $actual = $emailMan->create_export_query('emailman.id','emailman.user_id=""'); |
|
230 | - $this->assertSame($expected,$actual); |
|
227 | + //test with valid string params |
|
228 | + $expected = "SELECT emailman.* FROM emailman where (emailman.user_id=\"\") AND ( emailman.deleted IS NULL OR emailman.deleted=0 )"; |
|
229 | + $actual = $emailMan->create_export_query('emailman.id','emailman.user_id=""'); |
|
230 | + $this->assertSame($expected,$actual); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | } |
234 | 234 | |
235 | 235 | public function testmark_deleted() |
236 | - { |
|
236 | + { |
|
237 | 237 | |
238 | - $emailMan = new EmailMan(); |
|
238 | + $emailMan = new EmailMan(); |
|
239 | 239 | |
240 | - //execute the method and test if it works and does not throws an exception. |
|
241 | - try { |
|
242 | - $emailMan->mark_deleted(''); |
|
243 | - $this->assertTrue(true); |
|
244 | - } |
|
245 | - catch (Exception $e) { |
|
246 | - $this->fail(); |
|
247 | - } |
|
240 | + //execute the method and test if it works and does not throws an exception. |
|
241 | + try { |
|
242 | + $emailMan->mark_deleted(''); |
|
243 | + $this->assertTrue(true); |
|
244 | + } |
|
245 | + catch (Exception $e) { |
|
246 | + $this->fail(); |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - } |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - public function testcreate_ref_email() |
|
254 | - { |
|
255 | - $emailMan = new EmailMan(); |
|
256 | - $emailMan->test = true; |
|
253 | + public function testcreate_ref_email() |
|
254 | + { |
|
255 | + $emailMan = new EmailMan(); |
|
256 | + $emailMan->test = true; |
|
257 | 257 | |
258 | - $result = $emailMan->create_ref_email(0,"test","test text","test html","test campaign","[email protected]","1","",array(),true,"test from address"); |
|
258 | + $result = $emailMan->create_ref_email(0,"test","test text","test html","test campaign","[email protected]","1","",array(),true,"test from address"); |
|
259 | 259 | |
260 | - //test for email id returned and mark delete for cleanup |
|
261 | - $this->assertEquals(36, strlen($result)); |
|
262 | - $email = new Email(); |
|
263 | - $email->mark_deleted($result); |
|
260 | + //test for email id returned and mark delete for cleanup |
|
261 | + $this->assertEquals(36, strlen($result)); |
|
262 | + $email = new Email(); |
|
263 | + $email->mark_deleted($result); |
|
264 | 264 | |
265 | - } |
|
265 | + } |
|
266 | 266 | |
267 | 267 | } |
@@ -3,167 +3,167 @@ |
||
3 | 3 | class RoleTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testRole() |
|
7 | - { |
|
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $role = new Role(); |
|
6 | + public function testRole() |
|
7 | + { |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $role = new Role(); |
|
10 | 10 | |
11 | - $this->assertInstanceOf('Role',$role); |
|
12 | - $this->assertInstanceOf('SugarBean',$role); |
|
11 | + $this->assertInstanceOf('Role',$role); |
|
12 | + $this->assertInstanceOf('SugarBean',$role); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('roles', 'table_name', $role); |
|
15 | - $this->assertAttributeEquals("roles_modules", 'rel_module_table', $role); |
|
16 | - $this->assertAttributeEquals('Roles', 'module_dir', $role); |
|
17 | - $this->assertAttributeEquals('Role', 'object_name', $role); |
|
14 | + $this->assertAttributeEquals('roles', 'table_name', $role); |
|
15 | + $this->assertAttributeEquals("roles_modules", 'rel_module_table', $role); |
|
16 | + $this->assertAttributeEquals('Roles', 'module_dir', $role); |
|
17 | + $this->assertAttributeEquals('Role', 'object_name', $role); |
|
18 | 18 | |
19 | - $this->assertAttributeEquals(true, 'new_schema', $role); |
|
20 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $role); |
|
19 | + $this->assertAttributeEquals(true, 'new_schema', $role); |
|
20 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $role); |
|
21 | 21 | |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - public function testget_summary_text() |
|
25 | - { |
|
26 | - error_reporting(E_ERROR | E_PARSE); |
|
24 | + public function testget_summary_text() |
|
25 | + { |
|
26 | + error_reporting(E_ERROR | E_PARSE); |
|
27 | 27 | |
28 | - $role = new Role(); |
|
28 | + $role = new Role(); |
|
29 | 29 | |
30 | - //test without setting name |
|
31 | - $this->assertEquals(Null,$role->get_summary_text()); |
|
30 | + //test without setting name |
|
31 | + $this->assertEquals(Null,$role->get_summary_text()); |
|
32 | 32 | |
33 | - //test with name set |
|
34 | - $role->name = "test"; |
|
35 | - $this->assertEquals('test',$role->get_summary_text()); |
|
33 | + //test with name set |
|
34 | + $role->name = "test"; |
|
35 | + $this->assertEquals('test',$role->get_summary_text()); |
|
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - public function testcreate_export_query() |
|
40 | - { |
|
39 | + public function testcreate_export_query() |
|
40 | + { |
|
41 | 41 | |
42 | - $role = new Role(); |
|
42 | + $role = new Role(); |
|
43 | 43 | |
44 | - //test with empty string params |
|
45 | - $expected = " SELECT roles.* FROM roles where roles.deleted=0"; |
|
46 | - $actual = $role->create_export_query('',''); |
|
47 | - $this->assertSame($expected,$actual); |
|
44 | + //test with empty string params |
|
45 | + $expected = " SELECT roles.* FROM roles where roles.deleted=0"; |
|
46 | + $actual = $role->create_export_query('',''); |
|
47 | + $this->assertSame($expected,$actual); |
|
48 | 48 | |
49 | 49 | |
50 | - //test with valid string params |
|
51 | - $expected = " SELECT roles.* FROM roles where (roles.name = \"\") AND roles.deleted=0"; |
|
52 | - $actual = $role->create_export_query('roles.id','roles.name = ""'); |
|
53 | - $this->assertSame($expected,$actual); |
|
50 | + //test with valid string params |
|
51 | + $expected = " SELECT roles.* FROM roles where (roles.name = \"\") AND roles.deleted=0"; |
|
52 | + $actual = $role->create_export_query('roles.id','roles.name = ""'); |
|
53 | + $this->assertSame($expected,$actual); |
|
54 | 54 | |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | - public function testSet_module_relationshipAndQuery_modules() |
|
60 | - { |
|
61 | - $role = new Role(); |
|
59 | + public function testSet_module_relationshipAndQuery_modules() |
|
60 | + { |
|
61 | + $role = new Role(); |
|
62 | 62 | |
63 | - $role->id = 1; |
|
64 | - $mod_ids = array("Accounts","Leads"); |
|
63 | + $role->id = 1; |
|
64 | + $mod_ids = array("Accounts","Leads"); |
|
65 | 65 | |
66 | 66 | |
67 | - //test set_module_relationship. |
|
68 | - //creates related records |
|
69 | - $role->set_module_relationship($role->id, $mod_ids, 1); |
|
67 | + //test set_module_relationship. |
|
68 | + //creates related records |
|
69 | + $role->set_module_relationship($role->id, $mod_ids, 1); |
|
70 | 70 | |
71 | 71 | |
72 | - //get the related records count |
|
73 | - $result = $role->query_modules(); |
|
74 | - $this->assertGreaterThanOrEqual(2, count($result)); |
|
72 | + //get the related records count |
|
73 | + $result = $role->query_modules(); |
|
74 | + $this->assertGreaterThanOrEqual(2, count($result)); |
|
75 | 75 | |
76 | 76 | |
77 | - //test clear_module_relationship method |
|
78 | - $this->clear_module_relationship($role->id); |
|
77 | + //test clear_module_relationship method |
|
78 | + $this->clear_module_relationship($role->id); |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - public function clear_module_relationship($id) |
|
83 | - { |
|
84 | - $role = new Role(); |
|
82 | + public function clear_module_relationship($id) |
|
83 | + { |
|
84 | + $role = new Role(); |
|
85 | 85 | |
86 | - $role->id = $id; |
|
87 | - $role->clear_module_relationship($id); |
|
86 | + $role->id = $id; |
|
87 | + $role->clear_module_relationship($id); |
|
88 | 88 | |
89 | - //get related records count and verify that records are removed |
|
90 | - $result = $role->query_modules(); |
|
91 | - $this->assertEquals(0, count($result)); |
|
89 | + //get related records count and verify that records are removed |
|
90 | + $result = $role->query_modules(); |
|
91 | + $this->assertEquals(0, count($result)); |
|
92 | 92 | |
93 | - } |
|
93 | + } |
|
94 | 94 | |
95 | - public function testSet_user_relationshipAndCheck_user_role_count() |
|
96 | - { |
|
97 | - $role = new Role(); |
|
95 | + public function testSet_user_relationshipAndCheck_user_role_count() |
|
96 | + { |
|
97 | + $role = new Role(); |
|
98 | 98 | |
99 | - $role->id = 1; |
|
100 | - $user_ids = array("1","2"); |
|
99 | + $role->id = 1; |
|
100 | + $user_ids = array("1","2"); |
|
101 | 101 | |
102 | 102 | |
103 | - //create related records |
|
104 | - $role->set_user_relationship($role->id, $user_ids, 1); |
|
103 | + //create related records |
|
104 | + $role->set_user_relationship($role->id, $user_ids, 1); |
|
105 | 105 | |
106 | 106 | |
107 | - //get the related records count |
|
108 | - $result = $role->check_user_role_count("1"); |
|
109 | - $this->assertGreaterThanOrEqual(1, count($result)); |
|
107 | + //get the related records count |
|
108 | + $result = $role->check_user_role_count("1"); |
|
109 | + $this->assertGreaterThanOrEqual(1, count($result)); |
|
110 | 110 | |
111 | 111 | |
112 | - //get the related records count |
|
113 | - $result = $role->check_user_role_count("2"); |
|
114 | - $this->assertGreaterThanOrEqual(1, count($result)); |
|
112 | + //get the related records count |
|
113 | + $result = $role->check_user_role_count("2"); |
|
114 | + $this->assertGreaterThanOrEqual(1, count($result)); |
|
115 | 115 | |
116 | 116 | |
117 | - //test get_users method |
|
118 | - $this->get_users($role->id); |
|
117 | + //test get_users method |
|
118 | + $this->get_users($role->id); |
|
119 | 119 | |
120 | 120 | |
121 | - //test clear_user_relationship method |
|
122 | - $this->clear_user_relationship($role->id, "1"); |
|
123 | - $this->clear_user_relationship($role->id, "2"); |
|
121 | + //test clear_user_relationship method |
|
122 | + $this->clear_user_relationship($role->id, "1"); |
|
123 | + $this->clear_user_relationship($role->id, "2"); |
|
124 | 124 | |
125 | - } |
|
125 | + } |
|
126 | 126 | |
127 | - public function get_users($id) |
|
128 | - { |
|
129 | - $role = new Role(); |
|
127 | + public function get_users($id) |
|
128 | + { |
|
129 | + $role = new Role(); |
|
130 | 130 | |
131 | - $role->id = $id; |
|
132 | - $result = $role->get_users(); |
|
131 | + $role->id = $id; |
|
132 | + $result = $role->get_users(); |
|
133 | 133 | |
134 | - $this->assertTrue(is_array($result)); |
|
135 | - } |
|
134 | + $this->assertTrue(is_array($result)); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | - public function clear_user_relationship($role_id, $user_id) |
|
139 | - { |
|
140 | - $role = new Role(); |
|
138 | + public function clear_user_relationship($role_id, $user_id) |
|
139 | + { |
|
140 | + $role = new Role(); |
|
141 | 141 | |
142 | - //get related records count and verify that records are removed |
|
143 | - $role->clear_user_relationship($role_id, $user_id); |
|
144 | - $this->assertEquals(0, count($result)); |
|
142 | + //get related records count and verify that records are removed |
|
143 | + $role->clear_user_relationship($role_id, $user_id); |
|
144 | + $this->assertEquals(0, count($result)); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - public function testquery_user_allowed_modules() |
|
149 | - { |
|
150 | - $role = new Role(); |
|
148 | + public function testquery_user_allowed_modules() |
|
149 | + { |
|
150 | + $role = new Role(); |
|
151 | 151 | |
152 | - $result = $role->query_user_allowed_modules("1"); |
|
153 | - $this->assertTrue(is_array($result)); |
|
152 | + $result = $role->query_user_allowed_modules("1"); |
|
153 | + $this->assertTrue(is_array($result)); |
|
154 | 154 | |
155 | - } |
|
155 | + } |
|
156 | 156 | |
157 | - public function testquery_user_disallowed_modules() |
|
158 | - { |
|
159 | - $role = new Role(); |
|
157 | + public function testquery_user_disallowed_modules() |
|
158 | + { |
|
159 | + $role = new Role(); |
|
160 | 160 | |
161 | - $allowed = array("Accounts"=>"Accounts","Leads"=>"Leads",); |
|
162 | - $result = $role->query_user_disallowed_modules($user_id,$allowed); |
|
161 | + $allowed = array("Accounts"=>"Accounts","Leads"=>"Leads",); |
|
162 | + $result = $role->query_user_disallowed_modules($user_id,$allowed); |
|
163 | 163 | |
164 | - $this->assertTrue(is_array($result)); |
|
164 | + $this->assertTrue(is_array($result)); |
|
165 | 165 | |
166 | - } |
|
166 | + } |
|
167 | 167 | |
168 | 168 | } |
169 | 169 |
@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | public function test__construct() |
8 | 8 | { |
9 | - //execute the contructor and check for the Object type and attributes |
|
10 | - $ical = new iCal(); |
|
11 | - $this->assertInstanceOf('iCal',$ical); |
|
12 | - $this->assertInstanceOf('vCal',$ical); |
|
13 | - $this->assertInstanceOf('SugarBean',$ical); |
|
9 | + //execute the contructor and check for the Object type and attributes |
|
10 | + $ical = new iCal(); |
|
11 | + $this->assertInstanceOf('iCal',$ical); |
|
12 | + $this->assertInstanceOf('vCal',$ical); |
|
13 | + $this->assertInstanceOf('SugarBean',$ical); |
|
14 | 14 | |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function testgetVcalIcal() |
18 | 18 | { |
19 | - error_reporting(E_ERROR | E_PARSE); |
|
19 | + error_reporting(E_ERROR | E_PARSE); |
|
20 | 20 | |
21 | - $ical = new iCal(); |
|
22 | - $user = new User(1); |
|
21 | + $ical = new iCal(); |
|
22 | + $user = new User(1); |
|
23 | 23 | |
24 | - //break the string in two pieces leaving out date part. |
|
25 | - $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nX-WR-CALNAME: (SugarCRM)\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:\r\nX-LIC-LOCATION:\r\nEND:VTIMEZONE\r\nCALSCALE:GREGORIAN"; |
|
26 | - $expectedEnd = "\r\nEND:VCALENDAR\r\n"; |
|
24 | + //break the string in two pieces leaving out date part. |
|
25 | + $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nX-WR-CALNAME: (SugarCRM)\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:\r\nX-LIC-LOCATION:\r\nEND:VTIMEZONE\r\nCALSCALE:GREGORIAN"; |
|
26 | + $expectedEnd = "\r\nEND:VCALENDAR\r\n"; |
|
27 | 27 | |
28 | - $actual = $ical->getVcalIcal($user,6); |
|
28 | + $actual = $ical->getVcalIcal($user,6); |
|
29 | 29 | |
30 | - //match the leading and trailing string parts to verify it returns expected results |
|
31 | - $this->assertStringStartsWith($expectedStart, $actual); |
|
32 | - $this->assertStringEndsWith($expectedEnd, $actual); |
|
30 | + //match the leading and trailing string parts to verify it returns expected results |
|
31 | + $this->assertStringStartsWith($expectedStart, $actual); |
|
32 | + $this->assertStringEndsWith($expectedEnd, $actual); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | } |
@@ -6,164 +6,164 @@ |
||
6 | 6 | |
7 | 7 | public function testACLRole(){ |
8 | 8 | |
9 | - //execute the contructor and check for the Object type and type attribute |
|
10 | - $aclRole = new ACLRole(); |
|
11 | - $this->assertInstanceOf('ACLRole',$aclRole); |
|
12 | - $this->assertInstanceOf('SugarBean',$aclRole); |
|
9 | + //execute the contructor and check for the Object type and type attribute |
|
10 | + $aclRole = new ACLRole(); |
|
11 | + $this->assertInstanceOf('ACLRole',$aclRole); |
|
12 | + $this->assertInstanceOf('SugarBean',$aclRole); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('ACLRoles', 'module_dir', $aclRole); |
|
15 | - $this->assertAttributeEquals('ACLRole', 'object_name', $aclRole); |
|
16 | - $this->assertAttributeEquals('acl_roles', 'table_name', $aclRole); |
|
17 | - $this->assertAttributeEquals(true, 'new_schema', $aclRole); |
|
18 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $aclRole); |
|
19 | - $this->assertAttributeEquals(true, 'disable_custom_fields', $aclRole); |
|
20 | - $this->assertAttributeEquals(array('user_id'=>'users'), 'relationship_fields', $aclRole); |
|
14 | + $this->assertAttributeEquals('ACLRoles', 'module_dir', $aclRole); |
|
15 | + $this->assertAttributeEquals('ACLRole', 'object_name', $aclRole); |
|
16 | + $this->assertAttributeEquals('acl_roles', 'table_name', $aclRole); |
|
17 | + $this->assertAttributeEquals(true, 'new_schema', $aclRole); |
|
18 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $aclRole); |
|
19 | + $this->assertAttributeEquals(true, 'disable_custom_fields', $aclRole); |
|
20 | + $this->assertAttributeEquals(array('user_id'=>'users'), 'relationship_fields', $aclRole); |
|
21 | 21 | |
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | public function testget_summary_text(){ |
26 | 26 | |
27 | - $aclRole = new ACLRole(); |
|
27 | + $aclRole = new ACLRole(); |
|
28 | 28 | |
29 | - //test with name attribute set and verify it returns expected value. |
|
30 | - //it works only if name attribute is preset, throws exception otherwise |
|
31 | - $aclRole->name = "test role"; |
|
32 | - $name = $aclRole->get_summary_text(); |
|
33 | - $this->assertEquals('test role',$name); |
|
29 | + //test with name attribute set and verify it returns expected value. |
|
30 | + //it works only if name attribute is preset, throws exception otherwise |
|
31 | + $aclRole->name = "test role"; |
|
32 | + $name = $aclRole->get_summary_text(); |
|
33 | + $this->assertEquals('test role',$name); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | - public function testsetAction(){ |
|
38 | + public function testsetAction(){ |
|
39 | 39 | |
40 | - $aclRole = new ACLRole(); |
|
40 | + $aclRole = new ACLRole(); |
|
41 | 41 | |
42 | - //take count of relationship initially and then after method execution and test if relationship count increases |
|
43 | - $initial_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
44 | - $aclRole->setAction( '1', '1', '90'); |
|
45 | - $final_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
42 | + //take count of relationship initially and then after method execution and test if relationship count increases |
|
43 | + $initial_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
44 | + $aclRole->setAction( '1', '1', '90'); |
|
45 | + $final_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
46 | 46 | |
47 | - $this->assertGreaterThan($initial_count , $final_count); |
|
47 | + $this->assertGreaterThan($initial_count , $final_count); |
|
48 | 48 | |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - public function testmark_relationships_deleted(){ |
|
52 | + public function testmark_relationships_deleted(){ |
|
53 | 53 | |
54 | - error_reporting(E_ERROR | E_PARSE); |
|
54 | + error_reporting(E_ERROR | E_PARSE); |
|
55 | 55 | |
56 | - $aclRole = new ACLRole(); |
|
56 | + $aclRole = new ACLRole(); |
|
57 | 57 | |
58 | - //take count of relationship initially and then after method execution and test if relationship count decreases |
|
59 | - $initial_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
60 | - $aclRole->mark_relationships_deleted('1'); |
|
61 | - $final_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
58 | + //take count of relationship initially and then after method execution and test if relationship count decreases |
|
59 | + $initial_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
60 | + $aclRole->mark_relationships_deleted('1'); |
|
61 | + $final_count = count($aclRole->retrieve_relationships('acl_roles_actions', array('role_id'=>'1', 'action_id'=>'1','access_override'=>'90'),'role_id')); |
|
62 | 62 | |
63 | - $this->assertLessThan($initial_count , $final_count); |
|
63 | + $this->assertLessThan($initial_count , $final_count); |
|
64 | 64 | |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - public function testgetUserRoles(){ |
|
68 | + public function testgetUserRoles(){ |
|
69 | 69 | |
70 | - error_reporting(E_ERROR | E_PARSE); |
|
70 | + error_reporting(E_ERROR | E_PARSE); |
|
71 | 71 | |
72 | - $aclRole = new ACLRole(); |
|
72 | + $aclRole = new ACLRole(); |
|
73 | 73 | |
74 | - //test with default/true getAsNameArray param value |
|
75 | - $result = $aclRole->getUserRoles('1'); |
|
76 | - $this->assertTrue(is_array($result)); |
|
74 | + //test with default/true getAsNameArray param value |
|
75 | + $result = $aclRole->getUserRoles('1'); |
|
76 | + $this->assertTrue(is_array($result)); |
|
77 | 77 | |
78 | - //test with flase getAsNameArray param value |
|
79 | - $result = $aclRole->getUserRoles('1',false); |
|
80 | - $this->assertTrue(is_array($result)); |
|
78 | + //test with flase getAsNameArray param value |
|
79 | + $result = $aclRole->getUserRoles('1',false); |
|
80 | + $this->assertTrue(is_array($result)); |
|
81 | 81 | |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - public function testgetUserRoleNames(){ |
|
85 | + public function testgetUserRoleNames(){ |
|
86 | 86 | |
87 | - $aclRole = new ACLRole(); |
|
87 | + $aclRole = new ACLRole(); |
|
88 | 88 | |
89 | - //test with empty value |
|
90 | - $result = $aclRole->getUserRoleNames(''); |
|
91 | - $this->assertTrue(is_array($result)); |
|
89 | + //test with empty value |
|
90 | + $result = $aclRole->getUserRoleNames(''); |
|
91 | + $this->assertTrue(is_array($result)); |
|
92 | 92 | |
93 | - //test with non empty but non existing role id value |
|
94 | - $result = $aclRole->getUserRoleNames('1'); |
|
95 | - $this->assertTrue(is_array($result)); |
|
93 | + //test with non empty but non existing role id value |
|
94 | + $result = $aclRole->getUserRoleNames('1'); |
|
95 | + $this->assertTrue(is_array($result)); |
|
96 | 96 | |
97 | 97 | |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | 101 | |
102 | - public function testgetAllRoles(){ |
|
102 | + public function testgetAllRoles(){ |
|
103 | 103 | |
104 | - $aclRole = new ACLRole(); |
|
104 | + $aclRole = new ACLRole(); |
|
105 | 105 | |
106 | - //test with returnAsArray default/flase |
|
107 | - $result = $aclRole->getAllRoles(); |
|
108 | - $this->assertTrue(is_array($result)); |
|
106 | + //test with returnAsArray default/flase |
|
107 | + $result = $aclRole->getAllRoles(); |
|
108 | + $this->assertTrue(is_array($result)); |
|
109 | 109 | |
110 | - //test with returnAsArray true |
|
111 | - $result = $aclRole->getAllRoles(true); |
|
112 | - $this->assertTrue(is_array($result)); |
|
110 | + //test with returnAsArray true |
|
111 | + $result = $aclRole->getAllRoles(true); |
|
112 | + $this->assertTrue(is_array($result)); |
|
113 | 113 | |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | - public function testgetRoleActions(){ |
|
117 | + public function testgetRoleActions(){ |
|
118 | 118 | |
119 | - $aclRole = new ACLRole(); |
|
119 | + $aclRole = new ACLRole(); |
|
120 | 120 | |
121 | - //test with empty value |
|
122 | - $result = $aclRole->getRoleActions(''); |
|
123 | - $this->assertTrue(is_array($result)); |
|
124 | - $this->assertEquals(51,count($result)); |
|
121 | + //test with empty value |
|
122 | + $result = $aclRole->getRoleActions(''); |
|
123 | + $this->assertTrue(is_array($result)); |
|
124 | + $this->assertEquals(51,count($result)); |
|
125 | 125 | |
126 | 126 | |
127 | - //test with non empty but non existing role id value, initially no roles exist. |
|
128 | - $result = $aclRole->getRoleActions('1'); |
|
129 | - $this->assertTrue(is_array($result)); |
|
130 | - $this->assertEquals(51,count($result)); |
|
127 | + //test with non empty but non existing role id value, initially no roles exist. |
|
128 | + $result = $aclRole->getRoleActions('1'); |
|
129 | + $this->assertTrue(is_array($result)); |
|
130 | + $this->assertEquals(51,count($result)); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | 135 | public function testtoArray(){ |
136 | 136 | |
137 | - $aclRole = new ACLRole(); |
|
137 | + $aclRole = new ACLRole(); |
|
138 | 138 | |
139 | - //wihout any fields set |
|
140 | - $expected = Array("id"=> "", "name"=> "", "description"=> ""); |
|
141 | - $actual = $aclRole->toArray(); |
|
142 | - $this->assertSame($expected,$actual); |
|
139 | + //wihout any fields set |
|
140 | + $expected = Array("id"=> "", "name"=> "", "description"=> ""); |
|
141 | + $actual = $aclRole->toArray(); |
|
142 | + $this->assertSame($expected,$actual); |
|
143 | 143 | |
144 | 144 | |
145 | - //with fileds pre populated |
|
146 | - $aclRole->id = "1"; |
|
147 | - $aclRole->name = "test"; |
|
148 | - $aclRole->description = "some description text"; |
|
145 | + //with fileds pre populated |
|
146 | + $aclRole->id = "1"; |
|
147 | + $aclRole->name = "test"; |
|
148 | + $aclRole->description = "some description text"; |
|
149 | 149 | |
150 | - $expected = Array("id"=> "1", "name"=> "test", "description"=> "some description text"); |
|
151 | - $actual = $aclRole->toArray(); |
|
152 | - $this->assertSame($expected,$actual); |
|
150 | + $expected = Array("id"=> "1", "name"=> "test", "description"=> "some description text"); |
|
151 | + $actual = $aclRole->toArray(); |
|
152 | + $this->assertSame($expected,$actual); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | 156 | public function testfromArray(){ |
157 | 157 | |
158 | - $aclRole = new ACLRole(); |
|
158 | + $aclRole = new ACLRole(); |
|
159 | 159 | |
160 | - $arr = Array("id"=> "1", "name"=> "test", "description"=> "some description text"); |
|
161 | - $aclRole->fromArray($arr); |
|
160 | + $arr = Array("id"=> "1", "name"=> "test", "description"=> "some description text"); |
|
161 | + $aclRole->fromArray($arr); |
|
162 | 162 | |
163 | - //verify that it sets the object attributes correctly |
|
164 | - $this->assertSame($aclRole->id,"1"); |
|
165 | - $this->assertSame($aclRole->name,"test"); |
|
166 | - $this->assertSame($aclRole->description,"some description text"); |
|
163 | + //verify that it sets the object attributes correctly |
|
164 | + $this->assertSame($aclRole->id,"1"); |
|
165 | + $this->assertSame($aclRole->name,"test"); |
|
166 | + $this->assertSame($aclRole->description,"some description text"); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 |
@@ -2,310 +2,310 @@ |
||
2 | 2 | |
3 | 3 | class ContactTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | - public function testContact() { |
|
5 | + public function testContact() { |
|
6 | 6 | |
7 | - //execute the contructor and check for the Object type and attributes |
|
8 | - $contact = new Contact(); |
|
9 | - $this->assertInstanceOf('Contact',$contact); |
|
10 | - $this->assertInstanceOf('Person',$contact); |
|
11 | - $this->assertInstanceOf('SugarBean',$contact); |
|
7 | + //execute the contructor and check for the Object type and attributes |
|
8 | + $contact = new Contact(); |
|
9 | + $this->assertInstanceOf('Contact',$contact); |
|
10 | + $this->assertInstanceOf('Person',$contact); |
|
11 | + $this->assertInstanceOf('SugarBean',$contact); |
|
12 | 12 | |
13 | - $this->assertAttributeEquals('Contacts', 'module_dir', $contact); |
|
14 | - $this->assertAttributeEquals('Contact', 'object_name', $contact); |
|
15 | - $this->assertAttributeEquals('contacts', 'table_name', $contact); |
|
16 | - $this->assertAttributeEquals('accounts_contacts', 'rel_account_table', $contact); |
|
17 | - $this->assertAttributeEquals('opportunities_contacts', 'rel_opportunity_table', $contact); |
|
18 | - $this->assertAttributeEquals(true, 'importable', $contact); |
|
19 | - $this->assertAttributeEquals(true, 'new_schema', $contact); |
|
13 | + $this->assertAttributeEquals('Contacts', 'module_dir', $contact); |
|
14 | + $this->assertAttributeEquals('Contact', 'object_name', $contact); |
|
15 | + $this->assertAttributeEquals('contacts', 'table_name', $contact); |
|
16 | + $this->assertAttributeEquals('accounts_contacts', 'rel_account_table', $contact); |
|
17 | + $this->assertAttributeEquals('opportunities_contacts', 'rel_opportunity_table', $contact); |
|
18 | + $this->assertAttributeEquals(true, 'importable', $contact); |
|
19 | + $this->assertAttributeEquals(true, 'new_schema', $contact); |
|
20 | 20 | |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - public function testadd_list_count_joins() |
|
24 | - { |
|
25 | - error_reporting(E_ERROR | E_PARSE); |
|
23 | + public function testadd_list_count_joins() |
|
24 | + { |
|
25 | + error_reporting(E_ERROR | E_PARSE); |
|
26 | 26 | |
27 | - $contact = new Contact(); |
|
27 | + $contact = new Contact(); |
|
28 | 28 | |
29 | - //test with empty strings |
|
30 | - $query = ""; |
|
31 | - $contact->add_list_count_joins($query, ''); |
|
32 | - $this->assertEquals("",$query); |
|
29 | + //test with empty strings |
|
30 | + $query = ""; |
|
31 | + $contact->add_list_count_joins($query, ''); |
|
32 | + $this->assertEquals("",$query); |
|
33 | 33 | |
34 | 34 | |
35 | - //test with valid string |
|
36 | - $query = ""; |
|
37 | - $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n "; |
|
38 | - $contact->add_list_count_joins($query, 'accounts.name'); |
|
39 | - $this->assertSame($expected,$query); |
|
35 | + //test with valid string |
|
36 | + $query = ""; |
|
37 | + $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n "; |
|
38 | + $contact->add_list_count_joins($query, 'accounts.name'); |
|
39 | + $this->assertSame($expected,$query); |
|
40 | 40 | |
41 | 41 | |
42 | - //test with valid string |
|
43 | - $query = ""; |
|
44 | - $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n "; |
|
45 | - $contact->add_list_count_joins($query, 'contacts.name'); |
|
46 | - $this->assertSame("",$query); |
|
42 | + //test with valid string |
|
43 | + $query = ""; |
|
44 | + $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n "; |
|
45 | + $contact->add_list_count_joins($query, 'contacts.name'); |
|
46 | + $this->assertSame("",$query); |
|
47 | 47 | |
48 | 48 | |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - public function testlistviewACLHelper() |
|
52 | - { |
|
53 | - $contact = new Contact(); |
|
51 | + public function testlistviewACLHelper() |
|
52 | + { |
|
53 | + $contact = new Contact(); |
|
54 | 54 | |
55 | - $expected = array( "MAIN"=>"a", "ACCOUNT"=>"a"); |
|
56 | - $actual = $contact->listviewACLHelper(); |
|
57 | - $this->assertSame($expected,$actual); |
|
55 | + $expected = array( "MAIN"=>"a", "ACCOUNT"=>"a"); |
|
56 | + $actual = $contact->listviewACLHelper(); |
|
57 | + $this->assertSame($expected,$actual); |
|
58 | 58 | |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - public function testcreate_new_list_query() |
|
62 | - { |
|
63 | - $contact = new Contact(); |
|
61 | + public function testcreate_new_list_query() |
|
62 | + { |
|
63 | + $contact = new Contact(); |
|
64 | 64 | |
65 | - //test without request action parameter |
|
66 | - $expected =" SELECT contacts.* , ' ' opportunity_role_fields , ' ' opportunity_id , ' ' c_accept_status_fields , ' ' call_id , ' ' e_invite_status_fields , ' ' fp_events_contactsfp_events_ida , ' ' e_accept_status_fields , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name , jt4.user_name modified_by_name , jt4.created_by modified_by_name_owner , 'Users' modified_by_name_mod , jt5.user_name created_by_name , jt5.created_by created_by_name_owner , 'Users' created_by_name_mod , jt6.user_name assigned_user_name , jt6.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as full_name, ' ' account_name , ' ' account_id , jt8.last_name report_to_name , jt8.assigned_user_id report_to_name_owner , 'Contacts' report_to_name_mod , jt9.name campaign_name , jt9.assigned_user_id campaign_name_owner , 'Campaigns' campaign_name_mod, ' ' m_accept_status_fields , ' ' meeting_id FROM contacts LEFT JOIN users jt4 ON contacts.modified_user_id=jt4.id AND jt4.deleted=0\n\n AND jt4.deleted=0 LEFT JOIN users jt5 ON contacts.created_by=jt5.id AND jt5.deleted=0\n\n AND jt5.deleted=0 LEFT JOIN users jt6 ON contacts.assigned_user_id=jt6.id AND jt6.deleted=0\n\n AND jt6.deleted=0 LEFT JOIN contacts jt8 ON contacts.reports_to_id=jt8.id AND jt8.deleted=0\n\n AND jt8.deleted=0 LEFT JOIN campaigns jt9 ON contacts.campaign_id=jt9.id AND jt9.deleted=0\n\n AND jt9.deleted=0 where (account.name is null) AND contacts.deleted=0"; |
|
67 | - $actual = $contact->create_new_list_query("account.name","account.name is null"); |
|
68 | - $this->assertSame($expected,$actual); |
|
65 | + //test without request action parameter |
|
66 | + $expected =" SELECT contacts.* , ' ' opportunity_role_fields , ' ' opportunity_id , ' ' c_accept_status_fields , ' ' call_id , ' ' e_invite_status_fields , ' ' fp_events_contactsfp_events_ida , ' ' e_accept_status_fields , LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as name , jt4.user_name modified_by_name , jt4.created_by modified_by_name_owner , 'Users' modified_by_name_mod , jt5.user_name created_by_name , jt5.created_by created_by_name_owner , 'Users' created_by_name_mod , jt6.user_name assigned_user_name , jt6.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),' ',IFNULL(contacts.last_name,'')))) as full_name, ' ' account_name , ' ' account_id , jt8.last_name report_to_name , jt8.assigned_user_id report_to_name_owner , 'Contacts' report_to_name_mod , jt9.name campaign_name , jt9.assigned_user_id campaign_name_owner , 'Campaigns' campaign_name_mod, ' ' m_accept_status_fields , ' ' meeting_id FROM contacts LEFT JOIN users jt4 ON contacts.modified_user_id=jt4.id AND jt4.deleted=0\n\n AND jt4.deleted=0 LEFT JOIN users jt5 ON contacts.created_by=jt5.id AND jt5.deleted=0\n\n AND jt5.deleted=0 LEFT JOIN users jt6 ON contacts.assigned_user_id=jt6.id AND jt6.deleted=0\n\n AND jt6.deleted=0 LEFT JOIN contacts jt8 ON contacts.reports_to_id=jt8.id AND jt8.deleted=0\n\n AND jt8.deleted=0 LEFT JOIN campaigns jt9 ON contacts.campaign_id=jt9.id AND jt9.deleted=0\n\n AND jt9.deleted=0 where (account.name is null) AND contacts.deleted=0"; |
|
67 | + $actual = $contact->create_new_list_query("account.name","account.name is null"); |
|
68 | + $this->assertSame($expected,$actual); |
|
69 | 69 | |
70 | - //test with request action parameter = ContactAddressPopup |
|
71 | - $_REQUEST['action'] = 'ContactAddressPopup'; |
|
72 | - $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name \n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) where (account.name is null) AND contacts.deleted=0 "; |
|
73 | - $actual = $contact->create_new_list_query("account.name","account.name is null"); |
|
74 | - $this->assertSame($expected,$actual); |
|
70 | + //test with request action parameter = ContactAddressPopup |
|
71 | + $_REQUEST['action'] = 'ContactAddressPopup'; |
|
72 | + $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name \n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) where (account.name is null) AND contacts.deleted=0 "; |
|
73 | + $actual = $contact->create_new_list_query("account.name","account.name is null"); |
|
74 | + $this->assertSame($expected,$actual); |
|
75 | 75 | |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - public function testaddress_popup_create_new_list_query() |
|
80 | - { |
|
79 | + public function testaddress_popup_create_new_list_query() |
|
80 | + { |
|
81 | 81 | |
82 | - $contact = new Contact(); |
|
82 | + $contact = new Contact(); |
|
83 | 83 | |
84 | - //test with empty string params |
|
85 | - $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name \n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) where contacts.deleted=0 "; |
|
86 | - $actual = $contact->address_popup_create_new_list_query('',''); |
|
87 | - $this->assertSame($expected,$actual); |
|
84 | + //test with empty string params |
|
85 | + $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name \n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) where contacts.deleted=0 "; |
|
86 | + $actual = $contact->address_popup_create_new_list_query('',''); |
|
87 | + $this->assertSame($expected,$actual); |
|
88 | 88 | |
89 | 89 | |
90 | - //test with valid string params |
|
91 | - $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name \n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) where (contacts.name=\"\") AND contacts.deleted=0 "; |
|
92 | - $actual = $contact->address_popup_create_new_list_query('contacts.id','contacts.name=""'); |
|
93 | - $this->assertSame($expected,$actual); |
|
90 | + //test with valid string params |
|
91 | + $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name \n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) where (contacts.name=\"\") AND contacts.deleted=0 "; |
|
92 | + $actual = $contact->address_popup_create_new_list_query('contacts.id','contacts.name=""'); |
|
93 | + $this->assertSame($expected,$actual); |
|
94 | 94 | |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | - public function testcreate_export_query() |
|
98 | - { |
|
99 | - $contact = new Contact(); |
|
97 | + public function testcreate_export_query() |
|
98 | + { |
|
99 | + $contact = new Contact(); |
|
100 | 100 | |
101 | - //test with empty string params |
|
102 | - $expected = "SELECT\n contacts.*,\n email_addresses.email_address email_address,\n '' email_addresses_non_primary, accounts.name as account_name,\n users.user_name as assigned_user_name FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id where ( accounts.deleted IS NULL OR accounts.deleted=0 )\n AND contacts.deleted=0 "; |
|
103 | - $actual = $contact->create_export_query('',''); |
|
104 | - $this->assertSame($expected,$actual); |
|
101 | + //test with empty string params |
|
102 | + $expected = "SELECT\n contacts.*,\n email_addresses.email_address email_address,\n '' email_addresses_non_primary, accounts.name as account_name,\n users.user_name as assigned_user_name FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id where ( accounts.deleted IS NULL OR accounts.deleted=0 )\n AND contacts.deleted=0 "; |
|
103 | + $actual = $contact->create_export_query('',''); |
|
104 | + $this->assertSame($expected,$actual); |
|
105 | 105 | |
106 | 106 | |
107 | - //test with valid string params |
|
108 | - $expected = "SELECT\n contacts.*,\n email_addresses.email_address email_address,\n '' email_addresses_non_primary, accounts.name as account_name,\n users.user_name as assigned_user_name FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id where (contacts.name=\"\") AND ( accounts.deleted IS NULL OR accounts.deleted=0 )\n AND contacts.deleted=0 "; |
|
109 | - $actual = $contact->create_export_query('contacts.id','contacts.name=""'); |
|
110 | - $this->assertSame($expected,$actual); |
|
107 | + //test with valid string params |
|
108 | + $expected = "SELECT\n contacts.*,\n email_addresses.email_address email_address,\n '' email_addresses_non_primary, accounts.name as account_name,\n users.user_name as assigned_user_name FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id where (contacts.name=\"\") AND ( accounts.deleted IS NULL OR accounts.deleted=0 )\n AND contacts.deleted=0 "; |
|
109 | + $actual = $contact->create_export_query('contacts.id','contacts.name=""'); |
|
110 | + $this->assertSame($expected,$actual); |
|
111 | 111 | |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | - public function testfill_in_additional_list_fields() { |
|
114 | + public function testfill_in_additional_list_fields() { |
|
115 | 115 | |
116 | - $contact = new Contact(); |
|
116 | + $contact = new Contact(); |
|
117 | 117 | |
118 | - //test with attributes preset and verify attributes are set accordingly |
|
119 | - $contact->first_name = "firstn"; |
|
120 | - $contact->last_name = "lastn"; |
|
121 | - $contact->email1 = "[email protected]"; |
|
122 | - $contact->email2 = "[email protected]"; |
|
118 | + //test with attributes preset and verify attributes are set accordingly |
|
119 | + $contact->first_name = "firstn"; |
|
120 | + $contact->last_name = "lastn"; |
|
121 | + $contact->email1 = "[email protected]"; |
|
122 | + $contact->email2 = "[email protected]"; |
|
123 | 123 | |
124 | 124 | |
125 | - $contact->fill_in_additional_list_fields(); |
|
125 | + $contact->fill_in_additional_list_fields(); |
|
126 | 126 | |
127 | - $this->assertEquals("firstn lastn",$contact->full_name); |
|
128 | - $this->assertEquals("firstn lastn <[email protected]>",$contact->email_and_name1); |
|
129 | - $this->assertEquals("firstn lastn <[email protected]>",$contact->email_and_name2); |
|
127 | + $this->assertEquals("firstn lastn",$contact->full_name); |
|
128 | + $this->assertEquals("firstn lastn <[email protected]>",$contact->email_and_name1); |
|
129 | + $this->assertEquals("firstn lastn <[email protected]>",$contact->email_and_name2); |
|
130 | 130 | |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - public function testfill_in_additional_detail_fields() { |
|
133 | + public function testfill_in_additional_detail_fields() { |
|
134 | 134 | |
135 | - $contact = new Contact(); |
|
135 | + $contact = new Contact(); |
|
136 | 136 | |
137 | - //test with attributes preset and verify attributes are set accordingly |
|
138 | - $contact->id = "1"; |
|
137 | + //test with attributes preset and verify attributes are set accordingly |
|
138 | + $contact->id = "1"; |
|
139 | 139 | |
140 | - $contact->fill_in_additional_detail_fields(); |
|
140 | + $contact->fill_in_additional_detail_fields(); |
|
141 | 141 | |
142 | - $this->assertEquals("",$contact->account_name); |
|
143 | - $this->assertEquals("",$contact->account_id); |
|
144 | - $this->assertEquals("",$contact->report_to_name); |
|
142 | + $this->assertEquals("",$contact->account_name); |
|
143 | + $this->assertEquals("",$contact->account_id); |
|
144 | + $this->assertEquals("",$contact->report_to_name); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | 148 | |
149 | - public function testload_contacts_users_relationship(){ |
|
149 | + public function testload_contacts_users_relationship(){ |
|
150 | 150 | |
151 | - $contact = new Contact(); |
|
151 | + $contact = new Contact(); |
|
152 | 152 | |
153 | - //execute the method and test if it works and does not throws an exception. |
|
154 | - try { |
|
155 | - $contact->load_contacts_users_relationship(); |
|
156 | - $this->assertTrue(true); |
|
157 | - } |
|
158 | - catch (Exception $e) { |
|
159 | - $this->fail(); |
|
160 | - } |
|
153 | + //execute the method and test if it works and does not throws an exception. |
|
154 | + try { |
|
155 | + $contact->load_contacts_users_relationship(); |
|
156 | + $this->assertTrue(true); |
|
157 | + } |
|
158 | + catch (Exception $e) { |
|
159 | + $this->fail(); |
|
160 | + } |
|
161 | 161 | |
162 | - } |
|
162 | + } |
|
163 | 163 | |
164 | - public function testget_list_view_data() { |
|
164 | + public function testget_list_view_data() { |
|
165 | 165 | |
166 | - $contact = new Contact(); |
|
166 | + $contact = new Contact(); |
|
167 | 167 | |
168 | - //test with attributes preset and verify attributes are set accordingly |
|
169 | - $contact->first_name = "first"; |
|
170 | - $contact->last_name = "last"; |
|
168 | + //test with attributes preset and verify attributes are set accordingly |
|
169 | + $contact->first_name = "first"; |
|
170 | + $contact->last_name = "last"; |
|
171 | 171 | |
172 | - $expected = array ( |
|
173 | - 'NAME' => 'first last', |
|
174 | - 'DELETED' => 0, |
|
175 | - 'FIRST_NAME' => 'first', |
|
176 | - 'LAST_NAME' => 'last', |
|
177 | - 'FULL_NAME' => 'first last', |
|
178 | - 'DO_NOT_CALL' => '0', |
|
179 | - 'PORTAL_USER_TYPE' => 'Single user', |
|
180 | - 'ENCODED_NAME' => 'first last', |
|
181 | - 'EMAIL1' => '', |
|
182 | - 'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Contacts\\u0026parent_id=\\u0026parent_name=first+last\\u0026to_addrs_ids=\\u0026to_addrs_names=first+last\\u0026to_addrs_emails=\\u0026to_email_addrs=first+last%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Contacts\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Contacts","parent_id":"","parent_name":"first last","to_addrs_ids":"","to_addrs_names":"first last","to_addrs_emails":"","to_email_addrs":"first last \\u003C\\u003E","return_module":"Contacts","return_action":"ListView","return_id":""}});\' class=\'\'>', |
|
183 | - 'EMAIL_AND_NAME1' => 'first last <>', |
|
184 | - ); |
|
172 | + $expected = array ( |
|
173 | + 'NAME' => 'first last', |
|
174 | + 'DELETED' => 0, |
|
175 | + 'FIRST_NAME' => 'first', |
|
176 | + 'LAST_NAME' => 'last', |
|
177 | + 'FULL_NAME' => 'first last', |
|
178 | + 'DO_NOT_CALL' => '0', |
|
179 | + 'PORTAL_USER_TYPE' => 'Single user', |
|
180 | + 'ENCODED_NAME' => 'first last', |
|
181 | + 'EMAIL1' => '', |
|
182 | + 'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Contacts\\u0026parent_id=\\u0026parent_name=first+last\\u0026to_addrs_ids=\\u0026to_addrs_names=first+last\\u0026to_addrs_emails=\\u0026to_email_addrs=first+last%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Contacts\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Contacts","parent_id":"","parent_name":"first last","to_addrs_ids":"","to_addrs_names":"first last","to_addrs_emails":"","to_email_addrs":"first last \\u003C\\u003E","return_module":"Contacts","return_action":"ListView","return_id":""}});\' class=\'\'>', |
|
183 | + 'EMAIL_AND_NAME1' => 'first last <>', |
|
184 | + ); |
|
185 | 185 | |
186 | - $actual = $contact->get_list_view_data(); |
|
187 | - //$this->assertSame($expected, $actual); |
|
188 | - $this->assertEquals($expected['NAME'], $actual['NAME']); |
|
189 | - $this->assertEquals($expected['FIRST_NAME'], $actual['FIRST_NAME']); |
|
190 | - $this->assertEquals($expected['LAST_NAME'], $actual['LAST_NAME']); |
|
191 | - $this->assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']); |
|
192 | - $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); |
|
193 | - $this->assertEquals($expected['EMAIL_AND_NAME1'], $actual['EMAIL_AND_NAME1']); |
|
186 | + $actual = $contact->get_list_view_data(); |
|
187 | + //$this->assertSame($expected, $actual); |
|
188 | + $this->assertEquals($expected['NAME'], $actual['NAME']); |
|
189 | + $this->assertEquals($expected['FIRST_NAME'], $actual['FIRST_NAME']); |
|
190 | + $this->assertEquals($expected['LAST_NAME'], $actual['LAST_NAME']); |
|
191 | + $this->assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']); |
|
192 | + $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); |
|
193 | + $this->assertEquals($expected['EMAIL_AND_NAME1'], $actual['EMAIL_AND_NAME1']); |
|
194 | 194 | |
195 | - } |
|
195 | + } |
|
196 | 196 | |
197 | 197 | |
198 | - public function testbuild_generic_where_clause () |
|
199 | - { |
|
198 | + public function testbuild_generic_where_clause () |
|
199 | + { |
|
200 | 200 | |
201 | - $contact = new Contact(); |
|
201 | + $contact = new Contact(); |
|
202 | 202 | |
203 | - //test with string |
|
204 | - $expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'"; |
|
205 | - $actual = $contact->build_generic_where_clause('test'); |
|
206 | - $this->assertSame($expected,$actual); |
|
203 | + //test with string |
|
204 | + $expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'"; |
|
205 | + $actual = $contact->build_generic_where_clause('test'); |
|
206 | + $this->assertSame($expected,$actual); |
|
207 | 207 | |
208 | 208 | |
209 | - //test with number |
|
210 | - $expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'"; |
|
211 | - $actual = $contact->build_generic_where_clause(1); |
|
212 | - $this->assertSame($expected,$actual); |
|
209 | + //test with number |
|
210 | + $expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'"; |
|
211 | + $actual = $contact->build_generic_where_clause(1); |
|
212 | + $this->assertSame($expected,$actual); |
|
213 | 213 | |
214 | - } |
|
214 | + } |
|
215 | 215 | |
216 | - public function testset_notification_body() |
|
217 | - { |
|
218 | - $contact = new Contact(); |
|
216 | + public function testset_notification_body() |
|
217 | + { |
|
218 | + $contact = new Contact(); |
|
219 | 219 | |
220 | - //test with attributes preset and verify attributes are set accordingly |
|
221 | - $contact->first_name = "first"; |
|
222 | - $contact->last_name = "last"; |
|
223 | - $contact->description = "some text"; |
|
224 | - $contact->fill_in_additional_list_fields(); |
|
220 | + //test with attributes preset and verify attributes are set accordingly |
|
221 | + $contact->first_name = "first"; |
|
222 | + $contact->last_name = "last"; |
|
223 | + $contact->description = "some text"; |
|
224 | + $contact->fill_in_additional_list_fields(); |
|
225 | 225 | |
226 | - $result = $contact->set_notification_body(new Sugar_Smarty(), $contact); |
|
226 | + $result = $contact->set_notification_body(new Sugar_Smarty(), $contact); |
|
227 | 227 | |
228 | - $this->assertEquals($contact->full_name ,$result->_tpl_vars['CONTACT_NAME']); |
|
229 | - $this->assertEquals($contact->description ,$result->_tpl_vars['CONTACT_DESCRIPTION']); |
|
228 | + $this->assertEquals($contact->full_name ,$result->_tpl_vars['CONTACT_NAME']); |
|
229 | + $this->assertEquals($contact->description ,$result->_tpl_vars['CONTACT_DESCRIPTION']); |
|
230 | 230 | |
231 | - } |
|
231 | + } |
|
232 | 232 | |
233 | - public function testget_contact_id_by_email() |
|
234 | - { |
|
235 | - $contact = new Contact(); |
|
233 | + public function testget_contact_id_by_email() |
|
234 | + { |
|
235 | + $contact = new Contact(); |
|
236 | 236 | |
237 | - $result = $contact->get_contact_id_by_email(""); |
|
238 | - $this->assertEquals(null,$result); |
|
237 | + $result = $contact->get_contact_id_by_email(""); |
|
238 | + $this->assertEquals(null,$result); |
|
239 | 239 | |
240 | 240 | |
241 | - //$result = $contact->get_contact_id_by_email("[email protected]"); |
|
242 | - //$this->assertEquals(null,$result); |
|
241 | + //$result = $contact->get_contact_id_by_email("[email protected]"); |
|
242 | + //$this->assertEquals(null,$result); |
|
243 | 243 | |
244 | - $this->markTestSkipped('Invalid Columns(email1,email2) in Query '); |
|
244 | + $this->markTestSkipped('Invalid Columns(email1,email2) in Query '); |
|
245 | 245 | |
246 | - } |
|
246 | + } |
|
247 | 247 | |
248 | - public function testsave_relationship_changes() { |
|
248 | + public function testsave_relationship_changes() { |
|
249 | 249 | |
250 | - $contact = new Contact(); |
|
250 | + $contact = new Contact(); |
|
251 | 251 | |
252 | - //execute the method and test if it works and does not throws an exception. |
|
253 | - try { |
|
254 | - $contact->save_relationship_changes(true); |
|
255 | - $contact->save_relationship_changes(false); |
|
256 | - $this->assertTrue(true); |
|
257 | - } |
|
258 | - catch (Exception $e) { |
|
259 | - $this->fail(); |
|
260 | - } |
|
252 | + //execute the method and test if it works and does not throws an exception. |
|
253 | + try { |
|
254 | + $contact->save_relationship_changes(true); |
|
255 | + $contact->save_relationship_changes(false); |
|
256 | + $this->assertTrue(true); |
|
257 | + } |
|
258 | + catch (Exception $e) { |
|
259 | + $this->fail(); |
|
260 | + } |
|
261 | 261 | |
262 | - } |
|
262 | + } |
|
263 | 263 | |
264 | - public function testbean_implements() |
|
265 | - { |
|
266 | - $contact = new Contact(); |
|
267 | - $this->assertEquals(false, $contact->bean_implements('')); //test with blank value |
|
268 | - $this->assertEquals(false, $contact->bean_implements('test')); //test with invalid value |
|
269 | - $this->assertEquals(true, $contact->bean_implements('ACL')); //test with valid value |
|
270 | - } |
|
264 | + public function testbean_implements() |
|
265 | + { |
|
266 | + $contact = new Contact(); |
|
267 | + $this->assertEquals(false, $contact->bean_implements('')); //test with blank value |
|
268 | + $this->assertEquals(false, $contact->bean_implements('test')); //test with invalid value |
|
269 | + $this->assertEquals(true, $contact->bean_implements('ACL')); //test with valid value |
|
270 | + } |
|
271 | 271 | |
272 | - public function testget_unlinked_email_query() |
|
273 | - { |
|
274 | - $contact = new Contact(); |
|
272 | + public function testget_unlinked_email_query() |
|
273 | + { |
|
274 | + $contact = new Contact(); |
|
275 | 275 | |
276 | - //execute the method and verify that it retunrs expected results |
|
277 | - $expected = "SELECT emails.id FROM emails JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Contacts' and\n eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n where eear.deleted=0 and eear.email_id not in\n (select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '')\n ) derivedemails on derivedemails.email_id = emails.id"; |
|
278 | - $actual = $contact->get_unlinked_email_query(); |
|
279 | - $this->assertSame($expected,$actual); |
|
276 | + //execute the method and verify that it retunrs expected results |
|
277 | + $expected = "SELECT emails.id FROM emails JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Contacts' and\n eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n where eear.deleted=0 and eear.email_id not in\n (select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '')\n ) derivedemails on derivedemails.email_id = emails.id"; |
|
278 | + $actual = $contact->get_unlinked_email_query(); |
|
279 | + $this->assertSame($expected,$actual); |
|
280 | 280 | |
281 | - } |
|
281 | + } |
|
282 | 282 | |
283 | 283 | |
284 | 284 | public function testprocess_sync_to_outlook() |
285 | 285 | { |
286 | - $contact = new Contact(); |
|
286 | + $contact = new Contact(); |
|
287 | 287 | |
288 | - //execute the method and test if it works and does not throws an exception. |
|
289 | - try { |
|
290 | - $contact->process_sync_to_outlook("all"); |
|
291 | - $this->assertTrue(true); |
|
292 | - } |
|
293 | - catch (Exception $e) { |
|
294 | - $this->fail(); |
|
295 | - } |
|
288 | + //execute the method and test if it works and does not throws an exception. |
|
289 | + try { |
|
290 | + $contact->process_sync_to_outlook("all"); |
|
291 | + $this->assertTrue(true); |
|
292 | + } |
|
293 | + catch (Exception $e) { |
|
294 | + $this->fail(); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | |
298 | - //execute the method and test if it works and does not throws an exception. |
|
299 | - try { |
|
300 | - $contact->process_sync_to_outlook("1"); |
|
301 | - $this->assertTrue(true); |
|
302 | - } |
|
303 | - catch (Exception $e) { |
|
304 | - $this->fail(); |
|
305 | - } |
|
298 | + //execute the method and test if it works and does not throws an exception. |
|
299 | + try { |
|
300 | + $contact->process_sync_to_outlook("1"); |
|
301 | + $this->assertTrue(true); |
|
302 | + } |
|
303 | + catch (Exception $e) { |
|
304 | + $this->fail(); |
|
305 | + } |
|
306 | 306 | |
307 | 307 | |
308 | 308 | |
309 | - } |
|
309 | + } |
|
310 | 310 | |
311 | 311 | } |
@@ -3,66 +3,66 @@ |
||
3 | 3 | class AOW_ConditionTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testAOW_Condition(){ |
|
6 | + public function testAOW_Condition(){ |
|
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $aowCondition = new AOW_Condition(); |
|
10 | - $this->assertInstanceOf('AOW_Condition',$aowCondition); |
|
11 | - $this->assertInstanceOf('Basic',$aowCondition); |
|
12 | - $this->assertInstanceOf('SugarBean',$aowCondition); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $aowCondition = new AOW_Condition(); |
|
10 | + $this->assertInstanceOf('AOW_Condition',$aowCondition); |
|
11 | + $this->assertInstanceOf('Basic',$aowCondition); |
|
12 | + $this->assertInstanceOf('SugarBean',$aowCondition); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('AOW_Conditions', 'module_dir', $aowCondition); |
|
15 | - $this->assertAttributeEquals('AOW_Condition', 'object_name', $aowCondition); |
|
16 | - $this->assertAttributeEquals('aow_conditions', 'table_name', $aowCondition); |
|
17 | - $this->assertAttributeEquals(true, 'new_schema', $aowCondition); |
|
18 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowCondition); |
|
19 | - $this->assertAttributeEquals(false, 'importable', $aowCondition); |
|
20 | - $this->assertAttributeEquals(false, 'tracker_visibility', $aowCondition); |
|
14 | + $this->assertAttributeEquals('AOW_Conditions', 'module_dir', $aowCondition); |
|
15 | + $this->assertAttributeEquals('AOW_Condition', 'object_name', $aowCondition); |
|
16 | + $this->assertAttributeEquals('aow_conditions', 'table_name', $aowCondition); |
|
17 | + $this->assertAttributeEquals(true, 'new_schema', $aowCondition); |
|
18 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $aowCondition); |
|
19 | + $this->assertAttributeEquals(false, 'importable', $aowCondition); |
|
20 | + $this->assertAttributeEquals(false, 'tracker_visibility', $aowCondition); |
|
21 | 21 | |
22 | 22 | |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | - public function testbean_implements(){ |
|
25 | + public function testbean_implements(){ |
|
26 | 26 | |
27 | - error_reporting(E_ERROR | E_PARSE); |
|
27 | + error_reporting(E_ERROR | E_PARSE); |
|
28 | 28 | |
29 | - $aowCondition = new AOW_Condition(); |
|
30 | - $this->assertEquals(false, $aowCondition->bean_implements('')); //test with blank value |
|
31 | - $this->assertEquals(false, $aowCondition->bean_implements('test')); //test with invalid value |
|
32 | - $this->assertEquals(false, $aowCondition->bean_implements('ACL')); //test with valid value |
|
29 | + $aowCondition = new AOW_Condition(); |
|
30 | + $this->assertEquals(false, $aowCondition->bean_implements('')); //test with blank value |
|
31 | + $this->assertEquals(false, $aowCondition->bean_implements('test')); //test with invalid value |
|
32 | + $this->assertEquals(false, $aowCondition->bean_implements('ACL')); //test with valid value |
|
33 | 33 | |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | 36 | public function testsave_lines(){ |
37 | 37 | |
38 | - $aowCondition = new AOW_Condition(); |
|
38 | + $aowCondition = new AOW_Condition(); |
|
39 | 39 | |
40 | - //populate required values |
|
41 | - $post_data= Array(); |
|
42 | - $post_data["name"] = Array('test1','test2'); |
|
43 | - $post_data["field"] = Array('field1','field2'); |
|
44 | - $post_data["operator"] = Array('=','!='); |
|
45 | - $post_data["value_type"] = Array('int','string'); |
|
46 | - $post_data["value"] = Array('1','abc'); |
|
40 | + //populate required values |
|
41 | + $post_data= Array(); |
|
42 | + $post_data["name"] = Array('test1','test2'); |
|
43 | + $post_data["field"] = Array('field1','field2'); |
|
44 | + $post_data["operator"] = Array('=','!='); |
|
45 | + $post_data["value_type"] = Array('int','string'); |
|
46 | + $post_data["value"] = Array('1','abc'); |
|
47 | 47 | |
48 | 48 | |
49 | - //create parent bean |
|
50 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
51 | - $aowWorkFlow->id = 1; |
|
49 | + //create parent bean |
|
50 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
51 | + $aowWorkFlow->id = 1; |
|
52 | 52 | |
53 | 53 | |
54 | - $aowCondition->save_lines($post_data, $aowWorkFlow); |
|
54 | + $aowCondition->save_lines($post_data, $aowWorkFlow); |
|
55 | 55 | |
56 | 56 | |
57 | - //get the linked beans and verify if records created |
|
58 | - $aow_conditions = $aowWorkFlow->get_linked_beans('aow_conditions', $aowWorkFlow->object_name); |
|
59 | - $this->assertEquals(count($post_data["field"]), count($aow_conditions) ); |
|
57 | + //get the linked beans and verify if records created |
|
58 | + $aow_conditions = $aowWorkFlow->get_linked_beans('aow_conditions', $aowWorkFlow->object_name); |
|
59 | + $this->assertEquals(count($post_data["field"]), count($aow_conditions) ); |
|
60 | 60 | |
61 | 61 | |
62 | - //cleanup afterwards |
|
63 | - foreach($aow_conditions as $lineItem){ |
|
64 | - $lineItem->mark_deleted($lineItem->id); |
|
65 | - } |
|
62 | + //cleanup afterwards |
|
63 | + foreach($aow_conditions as $lineItem){ |
|
64 | + $lineItem->mark_deleted($lineItem->id); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
68 | 68 |
@@ -2,23 +2,23 @@ |
||
2 | 2 | |
3 | 3 | class AOP_Case_EventsTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | - public function testAOP_Case_Events(){ |
|
5 | + public function testAOP_Case_Events(){ |
|
6 | 6 | |
7 | - //execute the contructor and check for the Object type and type attribute |
|
8 | - $aopCaseEvents = new AOP_Case_Events(); |
|
9 | - $this->assertInstanceOf('AOP_Case_Events',$aopCaseEvents); |
|
10 | - $this->assertInstanceOf('Basic',$aopCaseEvents); |
|
11 | - $this->assertInstanceOf('SugarBean',$aopCaseEvents); |
|
7 | + //execute the contructor and check for the Object type and type attribute |
|
8 | + $aopCaseEvents = new AOP_Case_Events(); |
|
9 | + $this->assertInstanceOf('AOP_Case_Events',$aopCaseEvents); |
|
10 | + $this->assertInstanceOf('Basic',$aopCaseEvents); |
|
11 | + $this->assertInstanceOf('SugarBean',$aopCaseEvents); |
|
12 | 12 | |
13 | - $this->assertAttributeEquals('AOP_Case_Events', 'module_dir', $aopCaseEvents); |
|
14 | - $this->assertAttributeEquals('AOP_Case_Events', 'object_name', $aopCaseEvents); |
|
15 | - $this->assertAttributeEquals('aop_case_events', 'table_name', $aopCaseEvents); |
|
16 | - $this->assertAttributeEquals(true, 'new_schema', $aopCaseEvents); |
|
17 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $aopCaseEvents); |
|
18 | - $this->assertAttributeEquals(false, 'importable', $aopCaseEvents); |
|
19 | - $this->assertAttributeEquals(false, 'tracker_visibility', $aopCaseEvents); |
|
13 | + $this->assertAttributeEquals('AOP_Case_Events', 'module_dir', $aopCaseEvents); |
|
14 | + $this->assertAttributeEquals('AOP_Case_Events', 'object_name', $aopCaseEvents); |
|
15 | + $this->assertAttributeEquals('aop_case_events', 'table_name', $aopCaseEvents); |
|
16 | + $this->assertAttributeEquals(true, 'new_schema', $aopCaseEvents); |
|
17 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $aopCaseEvents); |
|
18 | + $this->assertAttributeEquals(false, 'importable', $aopCaseEvents); |
|
19 | + $this->assertAttributeEquals(false, 'tracker_visibility', $aopCaseEvents); |
|
20 | 20 | |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | 23 | } |
24 | 24 | ?> |
25 | 25 | \ No newline at end of file |