-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path04DataProvider.php
46 lines (42 loc) · 1.13 KB
/
04DataProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* This example show that how we can write functions which will act as
* a data providor for another test.
*
* The providor can send data in a array if we have to send multiple variables
* and it may send multidimentional array to feed multiple values to assert.
*/
class DataTest extends PHPUnit_Framework_TestCase
{
/**
* This function will get data from its data providor function 'providor'.
* The function name should be mentioned in the tag 'dataProvider' preceeded
* by its function name
*
* @dataProvider provider
*/
public function testAdd($a, $b, $c)
{
$this->assertEquals($c, $a + $b);
}
public function provider()
{
$return1 = array(
array(0, 0, 0),
array(0, 1, 1),
array(1, 0, 1),
array(1, 1, 3)
);
$return2 = array(
array(0, 0, 0),
array(0, 1, 1),
array(1, 0, 1),
array(1, 1, 2)
);
$return = $return1;
//$return = $return2;
//Uncommenting this line will pass this test
return $return;
}
}
?>