remove incorrectly added (duplicate) test (only just added)
[civicrm-core.git] / tests / phpunit / CRM / Utils / RuleTest.php
CommitLineData
f942c321
DL
1<?php
2
3require_once 'CiviTest/CiviUnitTestCase.php';
4
aba1cd8b
EM
5/**
6 * Class CRM_Utils_RuleTest
7 */
f942c321
DL
8class CRM_Utils_RuleTest extends CiviUnitTestCase {
9
aba1cd8b
EM
10 /**
11 * @return array
12 */
f942c321
DL
13 function get_info() {
14 return array(
a0631214 15 'name' => 'Rule Test',
f942c321 16 'description' => 'Test the validation rules',
a0631214 17 'group' => 'CiviCRM BAO Tests',
f942c321
DL
18 );
19 }
20
21 function setUp() {
22 parent::setUp();
23 }
24
25 /**
26 * @dataProvider integerDataProvider
27 */
28 function testInteger($inputData, $expectedResult) {
29 $this->assertEquals($expectedResult, CRM_Utils_Rule::integer($inputData));
30 }
31
e9479dcf
EM
32 /**
33 * @return array
34 */
f942c321
DL
35 function integerDataProvider() {
36 return array(
a0631214
TO
37 array(10, TRUE),
38 array('145E+3', FALSE),
39 array('10', TRUE),
40 array(-10, TRUE),
41 array('-10', TRUE),
42 array('-10foo', FALSE),
f942c321
DL
43 );
44 }
45
46 /**
47 * @dataProvider positiveDataProvider
48 */
49 function testPositive($inputData, $expectedResult) {
69244ea1 50 $this->assertEquals($expectedResult, CRM_Utils_Rule::positiveInteger($inputData));
f942c321
DL
51 }
52
4cbe18b8
EM
53 /**
54 * @return array
55 */
f942c321
DL
56 function positiveDataProvider() {
57 return array(
a0631214
TO
58 array(10, TRUE),
59 array('145.0E+3', FALSE),
60 array('10', TRUE),
61 array(-10, FALSE),
62 array('-10', FALSE),
63 array('-10foo', FALSE),
f942c321
DL
64 );
65 }
66
67 /**
68 * @dataProvider numericDataProvider
69 */
70 function testNumeric($inputData, $expectedResult) {
69244ea1 71 $this->assertEquals($expectedResult, CRM_Utils_Rule::numeric($inputData));
f942c321
DL
72 }
73
4cbe18b8
EM
74 /**
75 * @return array
76 */
f942c321
DL
77 function numericDataProvider() {
78 return array(
a0631214
TO
79 array(10, TRUE),
80 array('145.0E+3', FALSE),
81 array('10', TRUE),
82 array(-10, TRUE),
83 array('-10', TRUE),
84 array('-10foo', FALSE),
f942c321
DL
85 );
86 }
87
f942c321 88}