callAPISuccessGetValue('Option_value', array( 'label' => 'PhoneBank', 'return' => 'value', ), 'integer'); $this->useTransaction(); $this->enableCiviCampaign(); $this->params = array( 'title' => "survey title", 'activity_type_id' => $phoneBankActivityTypeID, 'max_number_of_contacts' => 12, 'instructions' => "Call people, ask for money", ); parent::setUp(); } /** * Test create function succeeds. */ public function testCreateSurvey() { $result = $this->callAPIAndDocument('survey', 'create', $this->params, __FUNCTION__, __FILE__); $this->getAndCheck($this->params, $result['id'], $this->entity); } /** * Test get function succeeds. * * This is actually largely tested in the get * action on create. Add extra checks for any 'special' return values or * behaviours */ public function testGetSurvey() { $this->createTestEntity(); $result = $this->callAPIAndDocument('survey', 'get', $this->params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); } /** * Check the delete function succeeds. */ public function testDeleteSurvey() { $entity = $this->createTestEntity(); $result = $this->callAPIAndDocument('survey', 'delete', array('id' => $entity['id']), __FUNCTION__, __FILE__); $checkDeleted = $this->callAPISuccess($this->entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); } /** * Test & document chained delete pattern. * * Note that explanation of the pattern * is best put in the $description variable as it will then be displayed in the * test generated examples. (these are to be found in the api/examples folder). */ public function testGetSurveyChainDelete() { $description = "Demonstrates get + delete in the same call."; $subfile = 'ChainedGetDelete'; $params = array( 'title' => "survey title", 'api.survey.delete' => 1, ); $result = $this->callAPISuccess('survey', 'create', $this->params); $result = $this->callAPIAndDocument('survey', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile); $this->assertEquals(0, $this->callAPISuccess('survey', 'getcount', array()), 'In line ' . __LINE__); } }