-
Notifications
You must be signed in to change notification settings - Fork 2
/
FortuneTellerMockeryTest.php
100 lines (92 loc) · 2.24 KB
/
FortuneTellerMockeryTest.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php # -*- coding: utf-8 -*-
/**
* Test case for the FortuneTeller class, using Mockery.
*/
class FortuneTellerMockeryTest extends PHPUnit_Framework_TestCase {
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
/**
* Tests if the expected answer is returned.
*
* @covers FortuneTeller::answer()
* @dataProvider provide_answer_data
*
* @param string $expected The expected answer.
* @param mixed $money The money spent for the fortune teller.
* @param string $answer The answer given by the oracle.
*
* @return void
*/
public function test_return_expected_answer( $expected, $money, $answer ) {
$oracle = Mockery::mock( 'Oracle', [
'answer' => $answer,
] );
$this->assertSame(
$expected,
( new FortuneTeller( $oracle ) )->answer( $money ),
'answer() should return the expected answer.'
);
}
/**
* @return array[]
*/
public function provide_answer_data() {
$answer = 'answer';
return [
'no_money' => [
'expected' => '',
'money' => 0,
'answer' => $answer,
],
'negative_money' => [
'expected' => '',
'money' => -5,
'answer' => $answer,
],
'money_null' => [
'expected' => '',
'money' => null,
'answer' => $answer,
],
'money_true' => [
'expected' => '',
'money' => true,
'answer' => $answer,
],
'money_false' => [
'expected' => '',
'money' => false,
'answer' => $answer,
],
'money_empty_string' => [
'expected' => '',
'money' => '',
'answer' => $answer,
],
'money_array' => [
'expected' => '',
'money' => [],
'answer' => $answer,
],
'enough_money' => [
'expected' => $answer,
'money' => 5,
'answer' => $answer,
],
'enough_money_string' => [
'expected' => $answer,
'money' => '5',
'answer' => $answer,
],
'more_than_enough_money' => [
'expected' => $answer,
'money' => 100,
'answer' => $answer,
],
'more_than_enough_money_string' => [
'expected' => $answer,
'money' => '100',
'answer' => $answer,
],
];
}
}