Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-04-30-12-58-23
[civicrm-core.git] / tests / phpunit / CRM / Contact / BAO / GroupTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
6a488035 5 +--------------------------------------------------------------------+
06a1bc01 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28
29require_once 'CiviTest/CiviUnitTestCase.php';
30
31/**
32 * Test class for CRM_Contact_BAO_Group BAO
33 *
34 * @package CiviCRM
35 */
36class CRM_Contact_BAO_GroupTest extends CiviUnitTestCase {
37
38 /**
39 * Sets up the fixture, for example, opens a network connection.
40 * This method is called before a test is executed.
41 *
42 * @access protected
43 */
44 protected function setUp() {
45 parent::setUp();
46 }
47
48 /**
49 * Tears down the fixture, for example, closes a network connection.
50 * This method is called after a test is executed.
51 *
52 * @access protected
53 */
54 protected function tearDown() {}
55
56 /**
57 * test case for add( )
58 */
59 function testAddSimple() {
60
61 $checkParams = $params = array(
62 'title' => 'Group Uno',
63 'description' => 'Group One',
64 'visibility' => 'User and User Admin Only',
65 'is_active' => 1,
66 );
67
68 $group = CRM_Contact_BAO_Group::create($params);
69
70 $this->assertDBCompareValues(
71 'CRM_Contact_DAO_Group',
72 array('id' => $group->id),
73 $checkParams
74 );
75 }
76
77 function testAddSmart() {
78
79 $checkParams = $params = array(
80 'title' => 'Group Dos',
81 'description' => 'Group Two',
82 'visibility' => 'User and User Admin Only',
83 'is_active' => 1,
84 'formValues' => array('sort_name' => 'Adams'),
85 );
86
87 $group = CRM_Contact_BAO_Group::createSmartGroup($params);
88
89 unset($checkParams['formValues']);
90 $this->assertDBCompareValues(
91 'CRM_Contact_DAO_Group',
92 array('id' => $group->id),
93 $checkParams
94 );
95 }
96}
97