commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / tests / phpunit / CRM / Utils / RuleTest.php
1 <?php
2
3 require_once 'CiviTest/CiviUnitTestCase.php';
4
5 /**
6 * Class CRM_Utils_RuleTest
7 */
8 class CRM_Utils_RuleTest extends CiviUnitTestCase {
9
10 public function setUp() {
11 parent::setUp();
12 }
13
14 /**
15 * @dataProvider integerDataProvider
16 * @param $inputData
17 * @param $expectedResult
18 */
19 public function testInteger($inputData, $expectedResult) {
20 $this->assertEquals($expectedResult, CRM_Utils_Rule::integer($inputData));
21 }
22
23 /**
24 * @return array
25 */
26 public function integerDataProvider() {
27 return array(
28 array(10, TRUE),
29 array('145E+3', FALSE),
30 array('10', TRUE),
31 array(-10, TRUE),
32 array('-10', TRUE),
33 array('-10foo', FALSE),
34 );
35 }
36
37 /**
38 * @dataProvider positiveDataProvider
39 * @param $inputData
40 * @param $expectedResult
41 */
42 public function testPositive($inputData, $expectedResult) {
43 $this->assertEquals($expectedResult, CRM_Utils_Rule::positiveInteger($inputData));
44 }
45
46 /**
47 * @return array
48 */
49 public function positiveDataProvider() {
50 return array(
51 array(10, TRUE),
52 array('145.0E+3', FALSE),
53 array('10', TRUE),
54 array(-10, FALSE),
55 array('-10', FALSE),
56 array('-10foo', FALSE),
57 );
58 }
59
60 /**
61 * @dataProvider numericDataProvider
62 * @param $inputData
63 * @param $expectedResult
64 */
65 public function testNumeric($inputData, $expectedResult) {
66 $this->assertEquals($expectedResult, CRM_Utils_Rule::numeric($inputData));
67 }
68
69 /**
70 * @return array
71 */
72 public function numericDataProvider() {
73 return array(
74 array(10, TRUE),
75 array('145.0E+3', FALSE),
76 array('10', TRUE),
77 array(-10, TRUE),
78 array('-10', TRUE),
79 array('-10foo', FALSE),
80 );
81 }
82
83 }