adding non-working api structure and indentation fixes
[civicrm-core.git] / tests / phpunit / api / v3 / MailingABTest.php
CommitLineData
4aef704e 1<?php
2/*
3 * File for the TestMailing class
4 *
5 * (PHP 5)
6 *
7 * @package CiviCRM
8 *
9 * This file is part of CiviCRM
10 *
11 * CiviCRM is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Affero General Public License
13 * as published by the Free Software Foundation; either version 3 of
14 * the License, or (at your option) any later version.
15 *
16 * CiviCRM is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Affero General Public License for more details.
20 *
21 * You should have received a copy of the GNU Affero General Public
22 * License along with this program. If not, see
23 * <http://www.gnu.org/licenses/>.
24 */
25
26require_once 'CiviTest/CiviUnitTestCase.php';
27
28
29/**
30 * Test APIv3 civicrm_mailingab_* functions
31 *
32 * @package CiviCRM
33 */
34class api_v3_MailingABTest extends CiviUnitTestCase {
35 protected $_mailingID_A;
36 protected $_mailingID_B;
37 protected $_mailingID_C;
38 protected $_params;
39 protected $_apiversion = 3;
40 protected $_entity = 'MailingAB';
41
42
43 /**
44 * @return array
45 */
46 function get_info() {
47 return array(
48 'name' => 'Mailer',
49 'description' => 'Test all Mailer methods.',
50 'group' => 'CiviCRM API Tests',
51 );
52 }
53
54 function setUp() {
55 parent::setUp();
56 $this->_mailingID_A = $this->createMailing();
57 $this->_mailingID_B = $this->createMailing();
58 $this->_mailingID_C = $this->createMailing();
59
60 $this->_params = array(
61 'mailing_id_a' => $this->_mailingID_A,
62 'mailing_id_b' => $this->_mailingID_B,
63 'mailing_id_c' => $this->_mailingID_C,
64 'testing_criteria_id' => 1,
65 'winner_criteria_id' => 1,
66 'declare_winning_time' => '+2 days',
67 'group_percentage' => 10,
68 );
69 }
70
71 function tearDown() {
72 $this->deleteMailing($this->_mailingID_A);
73 $this->deleteMailing($this->_mailingID_B);
74 $this->deleteMailing($this->_mailingID_C);
75 }
76
77 /**
78 * Test civicrm_mailing_create
79 */
80 public function testMailingABCreateSuccess() {
81 $result = $this->callAPIAndDocument('MailingAB', 'create', $this->_params, __FUNCTION__, __FILE__);
82 $this->assertTrue(is_numeric($result['id']), "In line " . __LINE__);
83 $this->assertEquals($this->_params['group_percentage'], $result['values'][$result['id']]['group_percentage']);
84 }
85
86 /**
87 * Test civicrm_mailing_delete
88 */
89 public function testMailerDeleteSuccess() {
90 $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
91 $this->assertAPIDeleted($this->_entity, $result['id']);
92 }
93
94}