Commit | Line | Data |
---|---|---|
0fe377f6 CW |
1 | <?php |
2 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
aba1cd8b EM |
3 | |
4 | /** | |
5 | * Class CRM_Utils_RestTest | |
6 | */ | |
0fe377f6 | 7 | class CRM_Utils_RestTest extends CiviUnitTestCase { |
aba1cd8b EM |
8 | /** |
9 | * @return array | |
10 | */ | |
0fe377f6 CW |
11 | function get_info() { |
12 | return array( | |
13 | 'name' => 'Rest Test', | |
14 | 'description' => 'Test Rest Interface Utilities', | |
15 | 'group' => 'CiviCRM BAO Tests', | |
16 | ); | |
17 | } | |
18 | ||
19 | function setUp() { | |
20 | parent::setUp(); | |
21 | } | |
22 | ||
23 | function testProcessMultiple() { | |
24 | $_SERVER['REQUEST_METHOD'] = 'POST'; | |
25 | $input = array( | |
26 | 'cow' => array( | |
27 | 'contact', | |
28 | 'create', | |
29 | array( | |
30 | 'contact_type' => 'Individual', | |
31 | 'first_name' => 'Cow', | |
32 | ), | |
33 | ), | |
34 | 'sheep' => array( | |
35 | 'contact', | |
36 | 'create', | |
37 | array( | |
38 | 'contact_type' => 'Individual', | |
39 | 'first_name' => 'Sheep', | |
40 | ), | |
41 | ), | |
42 | ); | |
43 | $_REQUEST['json'] = json_encode($input); | |
44 | $output = CRM_Utils_REST::processMultiple(); | |
45 | $this->assertGreaterThan(0, $output['cow']['id']); | |
46 | $this->assertGreaterThan($output['cow']['id'], $output['sheep']['id']); | |
47 | } | |
48 | ||
49 | } |