@@ -3,143 +3,143 @@ discard block |
||
| 3 | 3 | class EmployeeTest extends PHPUnit_Framework_TestCase { |
| 4 | 4 | |
| 5 | 5 | |
| 6 | - public function testEmployee() { |
|
| 6 | + public function testEmployee() { |
|
| 7 | 7 | |
| 8 | - //execute the contructor and check for the Object type and attributes |
|
| 9 | - $employee = new Employee(); |
|
| 10 | - $this->assertInstanceOf('Employee',$employee); |
|
| 11 | - $this->assertInstanceOf('Person',$employee); |
|
| 12 | - $this->assertInstanceOf('SugarBean',$employee); |
|
| 8 | + //execute the contructor and check for the Object type and attributes |
|
| 9 | + $employee = new Employee(); |
|
| 10 | + $this->assertInstanceOf('Employee',$employee); |
|
| 11 | + $this->assertInstanceOf('Person',$employee); |
|
| 12 | + $this->assertInstanceOf('SugarBean',$employee); |
|
| 13 | 13 | |
| 14 | - $this->assertAttributeEquals('Employees', 'module_dir', $employee); |
|
| 15 | - $this->assertAttributeEquals('Employee', 'object_name', $employee); |
|
| 16 | - $this->assertAttributeEquals('users', 'table_name', $employee); |
|
| 17 | - $this->assertAttributeEquals(true, 'new_schema', $employee); |
|
| 14 | + $this->assertAttributeEquals('Employees', 'module_dir', $employee); |
|
| 15 | + $this->assertAttributeEquals('Employee', 'object_name', $employee); |
|
| 16 | + $this->assertAttributeEquals('users', 'table_name', $employee); |
|
| 17 | + $this->assertAttributeEquals(true, 'new_schema', $employee); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | - public function testget_summary_text() { |
|
| 22 | + public function testget_summary_text() { |
|
| 23 | 23 | |
| 24 | - error_reporting(E_ERROR | E_PARSE); |
|
| 24 | + error_reporting(E_ERROR | E_PARSE); |
|
| 25 | 25 | |
| 26 | - $employee = new Employee(); |
|
| 26 | + $employee = new Employee(); |
|
| 27 | 27 | |
| 28 | - //test without setting name |
|
| 29 | - $this->assertEquals(' ',$employee->get_summary_text()); |
|
| 28 | + //test without setting name |
|
| 29 | + $this->assertEquals(' ',$employee->get_summary_text()); |
|
| 30 | 30 | |
| 31 | - //test with name set |
|
| 32 | - $employee->retrieve(1); |
|
| 33 | - $this->assertEquals('Administrator',$employee->get_summary_text()); |
|
| 31 | + //test with name set |
|
| 32 | + $employee->retrieve(1); |
|
| 33 | + $this->assertEquals('Administrator',$employee->get_summary_text()); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - public function testfill_in_additional_list_fields() { |
|
| 39 | - |
|
| 40 | - $employee = new Employee(); |
|
| 38 | + public function testfill_in_additional_list_fields() { |
|
| 41 | 39 | |
| 42 | - //execute the method and test if it works and does not throws an exception. |
|
| 43 | - try { |
|
| 44 | - $employee->fill_in_additional_list_fields(); |
|
| 45 | - $this->assertTrue(true); |
|
| 46 | - } |
|
| 47 | - catch (Exception $e) { |
|
| 48 | - $this->fail(); |
|
| 49 | - } |
|
| 40 | + $employee = new Employee(); |
|
| 50 | 41 | |
| 51 | - } |
|
| 42 | + //execute the method and test if it works and does not throws an exception. |
|
| 43 | + try { |
|
| 44 | + $employee->fill_in_additional_list_fields(); |
|
| 45 | + $this->assertTrue(true); |
|
| 46 | + } |
|
| 47 | + catch (Exception $e) { |
|
| 48 | + $this->fail(); |
|
| 49 | + } |
|
| 52 | 50 | |
| 53 | - public function testfill_in_additional_detail_fields() |
|
| 54 | - { |
|
| 55 | - $employee = new Employee(); |
|
| 51 | + } |
|
| 56 | 52 | |
| 53 | + public function testfill_in_additional_detail_fields() |
|
| 54 | + { |
|
| 55 | + $employee = new Employee(); |
|
| 57 | 56 | |
| 58 | - //test with a empty employee bean |
|
| 59 | - $employee->fill_in_additional_detail_fields(); |
|
| 60 | - $this->assertEquals("", $employee->reports_to_name); |
|
| 61 | 57 | |
| 58 | + //test with a empty employee bean |
|
| 59 | + $employee->fill_in_additional_detail_fields(); |
|
| 60 | + $this->assertEquals("", $employee->reports_to_name); |
|
| 62 | 61 | |
| 63 | - //test with a valid employee bean |
|
| 64 | - $employee->retrieve(1); |
|
| 65 | - $employee->fill_in_additional_detail_fields(); |
|
| 66 | - $this->assertEquals("", $employee->reports_to_name); |
|
| 67 | 62 | |
| 68 | - } |
|
| 63 | + //test with a valid employee bean |
|
| 64 | + $employee->retrieve(1); |
|
| 65 | + $employee->fill_in_additional_detail_fields(); |
|
| 66 | + $this->assertEquals("", $employee->reports_to_name); |
|
| 69 | 67 | |
| 70 | - public function testretrieve_employee_id() |
|
| 71 | - { |
|
| 72 | - $employee = new Employee(); |
|
| 73 | - //$this->assertEquals('1' ,$employee->retrieve_employee_id('admin')); |
|
| 68 | + } |
|
| 74 | 69 | |
| 75 | - $this->markTestSkipped('Bug in query: employee_name parameter is wrongly used as user_name'); |
|
| 70 | + public function testretrieve_employee_id() |
|
| 71 | + { |
|
| 72 | + $employee = new Employee(); |
|
| 73 | + //$this->assertEquals('1' ,$employee->retrieve_employee_id('admin')); |
|
| 76 | 74 | |
| 77 | - } |
|
| 75 | + $this->markTestSkipped('Bug in query: employee_name parameter is wrongly used as user_name'); |
|
| 78 | 76 | |
| 77 | + } |
|
| 79 | 78 | |
| 80 | - public function testverify_data() |
|
| 81 | - { |
|
| 82 | - $employee = new Employee(); |
|
| 83 | - $this->assertEquals(true ,$employee->verify_data() ); |
|
| 84 | 79 | |
| 85 | - } |
|
| 80 | + public function testverify_data() |
|
| 81 | + { |
|
| 82 | + $employee = new Employee(); |
|
| 83 | + $this->assertEquals(true ,$employee->verify_data() ); |
|
| 86 | 84 | |
| 87 | - public function testget_list_view_data(){ |
|
| 85 | + } |
|
| 88 | 86 | |
| 89 | - $employee = new Employee(); |
|
| 87 | + public function testget_list_view_data(){ |
|
| 90 | 88 | |
| 91 | - $expected = array ( |
|
| 92 | - 'SUGAR_LOGIN' => '1', |
|
| 93 | - 'FULL_NAME' => ' ', |
|
| 94 | - 'NAME' => ' ', |
|
| 95 | - 'IS_ADMIN' => '0', |
|
| 96 | - 'EXTERNAL_AUTH_ONLY' => '0', |
|
| 97 | - 'RECEIVE_NOTIFICATIONS' => '1', |
|
| 98 | - 'DELETED' => 0, |
|
| 99 | - 'PORTAL_ONLY' => '0', |
|
| 100 | - 'SHOW_ON_EMPLOYEES' => '1', |
|
| 101 | - 'ENCODED_NAME' => ' ', |
|
| 102 | - 'EMAIL1' => '', |
|
| 103 | - 'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Employees\\u0026parent_id=\\u0026parent_name=+\\u0026to_addrs_ids=\\u0026to_addrs_names=\\u0026to_addrs_emails=\\u0026to_email_addrs=+%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Employees\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Employees","parent_id":"","parent_name":" ","to_addrs_ids":"","to_addrs_names":"","to_addrs_emails":"","to_email_addrs":" \\u003C\\u003E","return_module":"Employees","return_action":"ListView","return_id":""}});\' class=\'\'>', |
|
| 104 | - 'MESSENGER_TYPE' => '', |
|
| 105 | - 'REPORTS_TO_NAME' => NULL, |
|
| 106 | - ); |
|
| 89 | + $employee = new Employee(); |
|
| 107 | 90 | |
| 108 | - $actual = $employee->get_list_view_data(); |
|
| 109 | - $this->assertSame($expected, $actual); |
|
| 91 | + $expected = array ( |
|
| 92 | + 'SUGAR_LOGIN' => '1', |
|
| 93 | + 'FULL_NAME' => ' ', |
|
| 94 | + 'NAME' => ' ', |
|
| 95 | + 'IS_ADMIN' => '0', |
|
| 96 | + 'EXTERNAL_AUTH_ONLY' => '0', |
|
| 97 | + 'RECEIVE_NOTIFICATIONS' => '1', |
|
| 98 | + 'DELETED' => 0, |
|
| 99 | + 'PORTAL_ONLY' => '0', |
|
| 100 | + 'SHOW_ON_EMPLOYEES' => '1', |
|
| 101 | + 'ENCODED_NAME' => ' ', |
|
| 102 | + 'EMAIL1' => '', |
|
| 103 | + 'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Employees\\u0026parent_id=\\u0026parent_name=+\\u0026to_addrs_ids=\\u0026to_addrs_names=\\u0026to_addrs_emails=\\u0026to_email_addrs=+%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Employees\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Employees","parent_id":"","parent_name":" ","to_addrs_ids":"","to_addrs_names":"","to_addrs_emails":"","to_email_addrs":" \\u003C\\u003E","return_module":"Employees","return_action":"ListView","return_id":""}});\' class=\'\'>', |
|
| 104 | + 'MESSENGER_TYPE' => '', |
|
| 105 | + 'REPORTS_TO_NAME' => NULL, |
|
| 106 | + ); |
|
| 107 | + |
|
| 108 | + $actual = $employee->get_list_view_data(); |
|
| 109 | + $this->assertSame($expected, $actual); |
|
| 110 | 110 | |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - public function testlist_view_parse_additional_sections(){ |
|
| 113 | + public function testlist_view_parse_additional_sections(){ |
|
| 114 | 114 | |
| 115 | - $employee = new Employee(); |
|
| 115 | + $employee = new Employee(); |
|
| 116 | 116 | |
| 117 | - //execute the method and test if it works and does not throws an exception. |
|
| 118 | - try { |
|
| 119 | - $employee->list_view_parse_additional_sections(new Sugar_Smarty(), $xTemplateSection); |
|
| 120 | - $this->assertTrue(true); |
|
| 121 | - } |
|
| 122 | - catch (Exception $e) { |
|
| 123 | - $this->fail(); |
|
| 124 | - } |
|
| 117 | + //execute the method and test if it works and does not throws an exception. |
|
| 118 | + try { |
|
| 119 | + $employee->list_view_parse_additional_sections(new Sugar_Smarty(), $xTemplateSection); |
|
| 120 | + $this->assertTrue(true); |
|
| 121 | + } |
|
| 122 | + catch (Exception $e) { |
|
| 123 | + $this->fail(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | - public function testcreate_export_query() { |
|
| 129 | + public function testcreate_export_query() { |
|
| 130 | 130 | |
| 131 | - $employee = new Employee(); |
|
| 131 | + $employee = new Employee(); |
|
| 132 | 132 | |
| 133 | - //test with empty string params |
|
| 134 | - $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.deleted = 0 ORDER BY users.user_name"; |
|
| 135 | - $actual = $employee->create_export_query('',''); |
|
| 136 | - $this->assertSame($expected,$actual); |
|
| 133 | + //test with empty string params |
|
| 134 | + $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.deleted = 0 ORDER BY users.user_name"; |
|
| 135 | + $actual = $employee->create_export_query('',''); |
|
| 136 | + $this->assertSame($expected,$actual); |
|
| 137 | 137 | |
| 138 | 138 | |
| 139 | - //test with valid string params |
|
| 140 | - $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.user_name=\"\" AND users.deleted = 0 ORDER BY users.id"; |
|
| 141 | - $actual = $employee->create_export_query('users.id','users.user_name=""'); |
|
| 142 | - $this->assertSame($expected,$actual); |
|
| 139 | + //test with valid string params |
|
| 140 | + $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.user_name=\"\" AND users.deleted = 0 ORDER BY users.id"; |
|
| 141 | + $actual = $employee->create_export_query('users.id','users.user_name=""'); |
|
| 142 | + $this->assertSame($expected,$actual); |
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | $this->fail(); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * @todo: NEEDS FIXING! |
| 165 | 165 | */ |
| 166 | - public function testcreate_new_list_query() |
|
| 166 | + public function testcreate_new_list_query() |
|
| 167 | 167 | { |
| 168 | 168 | /* |
| 169 | 169 | $employee = new Employee(); |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | public function testhasCustomFields() |
| 187 | 187 | { |
| 188 | - $employee = new Employee(); |
|
| 189 | - $result = $employee->hasCustomFields(); |
|
| 190 | - $this->assertEquals(false,$result); |
|
| 188 | + $employee = new Employee(); |
|
| 189 | + $result = $employee->hasCustomFields(); |
|
| 190 | + $this->assertEquals(false,$result); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | } |
@@ -7,9 +7,9 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | //execute the contructor and check for the Object type and attributes |
| 9 | 9 | $employee = new Employee(); |
| 10 | - $this->assertInstanceOf('Employee',$employee); |
|
| 11 | - $this->assertInstanceOf('Person',$employee); |
|
| 12 | - $this->assertInstanceOf('SugarBean',$employee); |
|
| 10 | + $this->assertInstanceOf('Employee', $employee); |
|
| 11 | + $this->assertInstanceOf('Person', $employee); |
|
| 12 | + $this->assertInstanceOf('SugarBean', $employee); |
|
| 13 | 13 | |
| 14 | 14 | $this->assertAttributeEquals('Employees', 'module_dir', $employee); |
| 15 | 15 | $this->assertAttributeEquals('Employee', 'object_name', $employee); |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | $employee = new Employee(); |
| 27 | 27 | |
| 28 | 28 | //test without setting name |
| 29 | - $this->assertEquals(' ',$employee->get_summary_text()); |
|
| 29 | + $this->assertEquals(' ', $employee->get_summary_text()); |
|
| 30 | 30 | |
| 31 | 31 | //test with name set |
| 32 | 32 | $employee->retrieve(1); |
| 33 | - $this->assertEquals('Administrator',$employee->get_summary_text()); |
|
| 33 | + $this->assertEquals('Administrator', $employee->get_summary_text()); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | public function testverify_data() |
| 81 | 81 | { |
| 82 | 82 | $employee = new Employee(); |
| 83 | - $this->assertEquals(true ,$employee->verify_data() ); |
|
| 83 | + $this->assertEquals(true, $employee->verify_data()); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function testget_list_view_data(){ |
|
| 87 | + public function testget_list_view_data() { |
|
| 88 | 88 | |
| 89 | 89 | $employee = new Employee(); |
| 90 | 90 | |
| 91 | - $expected = array ( |
|
| 91 | + $expected = array( |
|
| 92 | 92 | 'SUGAR_LOGIN' => '1', |
| 93 | 93 | 'FULL_NAME' => ' ', |
| 94 | 94 | 'NAME' => ' ', |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function testlist_view_parse_additional_sections(){ |
|
| 113 | + public function testlist_view_parse_additional_sections() { |
|
| 114 | 114 | |
| 115 | 115 | $employee = new Employee(); |
| 116 | 116 | |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | //test with empty string params |
| 134 | 134 | $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.deleted = 0 ORDER BY users.user_name"; |
| 135 | - $actual = $employee->create_export_query('',''); |
|
| 136 | - $this->assertSame($expected,$actual); |
|
| 135 | + $actual = $employee->create_export_query('', ''); |
|
| 136 | + $this->assertSame($expected, $actual); |
|
| 137 | 137 | |
| 138 | 138 | |
| 139 | 139 | //test with valid string params |
| 140 | 140 | $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users WHERE users.user_name=\"\" AND users.deleted = 0 ORDER BY users.id"; |
| 141 | - $actual = $employee->create_export_query('users.id','users.user_name=""'); |
|
| 142 | - $this->assertSame($expected,$actual); |
|
| 141 | + $actual = $employee->create_export_query('users.id', 'users.user_name=""'); |
|
| 142 | + $this->assertSame($expected, $actual); |
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | $employee->preprocess_fields_on_save(); |
| 155 | 155 | $this->assertTrue(TRUE); |
| 156 | - } catch(Exception $e) |
|
| 156 | + }catch (Exception $e) |
|
| 157 | 157 | { |
| 158 | 158 | $this->fail(); |
| 159 | 159 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | $employee = new Employee(); |
| 189 | 189 | $result = $employee->hasCustomFields(); |
| 190 | - $this->assertEquals(false,$result); |
|
| 190 | + $this->assertEquals(false, $result); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | } |