3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
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_survey_* functions
34 * @package CiviCRM_APIv3
35 * @subpackage API_Campaign
38 require_once 'CiviTest/CiviUnitTestCase.php';
39 class api_v3_SurveyTest
extends CiviUnitTestCase
{
40 protected $_apiversion;
43 public $DBResetRequired = FALSE;
46 $this->_apiversion
= 3;
47 $phoneBankActivity = civicrm_api('Option_value', 'Get', array('label' => 'PhoneBank', 'version' => $this->_apiversion
, 'sequential' => 1));
48 $phoneBankActivityTypeID = $phoneBankActivity['values'][0]['value'];
49 $this->params
= array(
51 'title' => "survey title",
52 'activity_type_id' => $phoneBankActivityTypeID,
53 'max_number_of_contacts' => 12,
54 'instructions' => "Call people, ask for money",
59 function tearDown() {}
61 public function testCreateSurvey() {
62 $result = civicrm_api('survey', 'create', $this->params
);
63 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
64 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
65 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
66 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
69 public function testGetSurvey() {
71 $result = civicrm_api('survey', 'get', $this->params
);
72 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
73 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
74 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
75 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
76 $this->id
= $result['id'];
79 public function testDeleteSurvey() {
80 $entity = civicrm_api('survey', 'get', $this->params
);
81 $result = civicrm_api('survey', 'delete', array('version' => 3, 'id' => $entity['id']));
82 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
83 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
84 $checkDeleted = civicrm_api('survey', 'get', array(
87 $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__
);
90 public function testGetSurveyChainDelete() {
91 $description = "demonstrates get + delete in the same call";
92 $subfile = 'ChainedGetDelete';
95 'title' => "survey title",
96 'api.survey.delete' => 1,
98 $result = civicrm_api('survey', 'create', $this->params
);
99 $result = civicrm_api('survey', 'get', $params);
100 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
, $description, $subfile);
101 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
102 $this->assertEquals(0, civicrm_api('survey', 'getcount', array('version' => 3)), 'In line ' . __LINE__
);