3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviUnitTestCase.php';
32 * Test APIv3 civicrm_report_instance_* functions
34 * @package CiviCRM_APIv3
35 * @subpackage API_Report
38 class api_v3_ReportTemplateTest
extends CiviUnitTestCase
{
39 protected $_apiversion;
40 public $_eNoticeCompliant = TRUE;
42 $this->_apiversion
= 3;
46 function tearDown() {}
48 public function testReportTemplate() {
49 $result = $this->callAPISuccess('ReportTemplate', 'create', array(
50 'label' => 'Example Form',
51 'description' => 'Longish description of the example form',
52 'class_name' => 'CRM_Report_Form_Examplez',
53 'report_url' => 'example/path',
54 'component' => 'CiviCase',
56 $this->assertAPISuccess($result);
57 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
58 $entityId = $result['id'];
59 $this->assertTrue(is_numeric($entityId), 'In line ' . __LINE__
);
60 $this->assertEquals(7, $result['values'][$entityId]['component_id'], 'In line ' . __LINE__
);
61 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
62 WHERE name = "CRM_Report_Form_Examplez"
63 AND option_group_id = 41 ');
64 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
65 WHERE name = "CRM_Report_Form_Examplez"');
67 // change component to null
68 $result = $this->callAPISuccess('ReportTemplate', 'create', array( 'id' => $entityId,
71 $this->assertAPISuccess($result);
72 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
73 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
74 WHERE name = "CRM_Report_Form_Examplez"
75 AND option_group_id = 41');
76 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
77 WHERE name = "CRM_Report_Form_Examplez"
78 AND component_id IS NULL');
81 $result = $this->callAPISuccess('ReportTemplate', 'create', array( 'id' => $entityId,
84 $this->assertAPISuccess($result);
85 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
86 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
87 WHERE name = "CRM_Report_Form_Examplez"
88 AND option_group_id = 41');
89 $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value
90 WHERE name = "CRM_Report_Form_Examplez"');
93 $result = $this->callAPISuccess('ReportTemplate', 'create', array( 'id' => $entityId,
96 $this->assertAPISuccess($result);
97 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
98 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
99 WHERE name = "CRM_Report_Form_Examplez"
100 AND option_group_id = 41');
101 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
102 WHERE name = "CRM_Report_Form_Examplez"');
104 $result = $this->callAPISuccess('ReportTemplate', 'delete', array( 'id' => $entityId,
106 $this->assertAPISuccess($result);
107 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
108 $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value
109 WHERE name = "CRM_Report_Form_Examplez"