api_v3_LocBlockTest - useTransaction()
[civicrm-core.git] / tests / phpunit / api / v3 / ReportTemplateTest.php
index c0c33e8c11e5e483d7165523c04114dd0839c224..2fb02526511f90d98866bdc720ef0df2373cff66 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -37,14 +37,12 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 
 class api_v3_ReportTemplateTest extends CiviUnitTestCase {
   protected $_apiversion = 3;
-  public $_eNoticeCompliant = TRUE;
+
   function setUp() {
     parent::setUp();
-    $this->_sethtmlGlobals();
+    $this->useTransaction(TRUE);
   }
 
-  function tearDown() {}
-
   public function testReportTemplate() {
     $result = $this->callAPISuccess('ReportTemplate', 'create', array(
       'label' => 'Example Form',
@@ -60,7 +58,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(7, $result['values'][$entityId]['component_id'], 'In line ' . __LINE__);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"
-      AND option_group_id = 41 ');
+      AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") ');
     $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"');
 
@@ -72,7 +70,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"
-      AND option_group_id = 41');
+      AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") ');
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"
       AND component_id IS NULL');
@@ -85,7 +83,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"
-      AND option_group_id = 41');
+      AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") ');
     $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"');
 
@@ -97,7 +95,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"
-      AND option_group_id = 41');
+      AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") ');
     $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
       WHERE name = "CRM_Report_Form_Examplez"');
 
@@ -114,9 +112,12 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
    *
    */
   function testReportTemplateGetRowsContactSummary() {
-    $result = $this->callAPISuccess('report_template', 'getrows', array(
+    $description = "Retrieve rows from a report template (optionally providing the instance_id)";
+    $result = $this->callAPIAndDocument('report_template', 'getrows', array(
       'report_id' => 'contact/summary',
-    ));
+      'options' => array('metadata' => array('labels', 'title'))
+    ), __FUNCTION__, __FILE__, $description, 'Getrows', 'getrows');
+    $this->assertEquals('Contact Name', $result['metadata']['labels']['civicrm_contact_sort_name']);
 
     //the second part of this test has been commented out because it relied on the db being reset to
     // it's base state
@@ -153,9 +154,10 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     if(in_array($reportID , array('contribute/softcredit', 'contribute/bookkeeping'))) {
       $this->markTestIncomplete($reportID . " has non enotices when calling statistics fn");
     }
-    $result = $this->callAPISuccess('report_template', 'getstatistics', array(
+    $description = "Get Statistics from a report (note there isn't much data to get in the test DB :-(";
+    $result = $this->callAPIAndDocument('report_template', 'getstatistics', array(
       'report_id' => $reportID,
-    ));
+    ), __FUNCTION__, __FILE__, $description, 'Getstatistics', 'getstatistics');
   }
 
   /**
@@ -170,22 +172,17 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
                       also, type should be added to state province & others? & potentially getAddressColumns fn should be
                       used per other reports',
         'contribute/repeat' => 'Reports with important functionality in postProcess are not callable via the api. For variable setting recommend beginPostProcessCommon, for temp table creation recommend From fn',
-        'contribute/organizationSummary' => 'Failure in api call for report_template getrows:  Only variables should be assigned by reference line 381',
-        'contribute/householdSummary' => '(see contribute/repeat) Undefined property: CRM_Report_Form_Contribute_HouseholdSummary::$householdContact LINE 260, property should be declared on class, for api accessibility should be set in beginPreProcess common',
-        'contribute/topDonor' => 'construction of query in postprocess makes inaccessible ',
+        'contribute/topDonor' => 'construction of query in postProcess makes inaccessible ',
         'contribute/sybunt' => 'e notice - (ui gives fatal error at civicrm/report/contribute/sybunt&reset=1&force=1
                                 e-notice is on yid_valueContribute/Sybunt.php(214) because at the force url "yid_relative" not "yid_value" is defined',
         'contribute/lybunt' => 'same as sybunt - fatals on force url & test identifies why',
-        'event/income' => 'I do no understant why but error is Call to undefined method CRM_Report_Form_Event_Income::from() in CRM/Report/Form.php on line 2120',
+        'event/income' => 'I do no understand why but error is Call to undefined method CRM_Report_Form_Event_Income::from() in CRM/Report/Form.php on line 2120',
         'contact/relationship' => '(see contribute/repeat), property declaration issue, Undefined property: CRM_Report_Form_Contact_Relationship::$relationType in /Contact/Relationship.php(486):',
-        'case/demographics' => 'Undefined index: operatorType Case/Demographics.php(319)',
-        'activitySummary' => 'Undefined index: group_bys_freq m/ActivitySummary.php(191)',
-        'event/incomesummary' => 'Undefined index: title, Report/Form/Event/IncomeCountSummary.php(187)',
-        'logging/contact/summary' => '(likely to be test releated) probably logging off Undefined index: Form/Contact/LoggingSummary.php(231): PHP',
-        'logging/contact/detail' => '(likely to be test releated) probably logging off  DB Error: no such table',
-        'logging/contribute/summary' => '(likely to be test releated) probably logging off DB Error: no such table',
-        'logging/contribute/detail' => '(likely to be test releated) probably logging off DB Error: no such table',
-        'survey/detail' => '(likely to be test releated)  Undefined index: CiviCampaign civicrm CRM/Core/Component.php(196)',
+        'logging/contact/summary' => '(likely to be test related) probably logging off Undefined index: Form/Contact/LoggingSummary.php(231): PHP',
+        'logging/contact/detail' => '(likely to be test related) probably logging off  DB Error: no such table',
+        'logging/contribute/summary' => '(likely to be test related) probably logging off DB Error: no such table',
+        'logging/contribute/detail' => '(likely to be test related) probably logging off DB Error: no such table',
+        'survey/detail' => '(likely to be test related)  Undefined index: CiviCampaign civicrm CRM/Core/Component.php(196)',
         'contribute/history' => 'Declaration of CRM_Report_Form_Contribute_History::buildRows() should be compatible with CRM_Report_Form::buildRows($sql, &$rows)',
     );