2
2
3
3
namespace Bmatovu \Ussd \Tests ;
4
4
5
- use Bmatovu \Ussd \Parser ;
5
+ use Bmatovu \Ussd \Ussd ;
6
6
7
- class ParserTest extends TestCase
7
+ class UssdTest extends TestCase
8
8
{
9
9
public function testMissingTag ()
10
10
{
@@ -14,9 +14,9 @@ public function testMissingTag()
14
14
15
15
$ xpath = $ this ->xmlToXpath ('<dummy/> ' );
16
16
17
- $ parser = (new Parser ($ xpath , 'ussd_wScXk ' ))->entry ('/*[1] ' );
17
+ $ ussd = (new Ussd ($ xpath , 'ussd_wScXk ' ))->entry ('/*[1] ' );
18
18
19
- $ parser -> parse ();
19
+ $ ussd -> handle ();
20
20
}
21
21
22
22
public function testExceptionExit ()
@@ -27,9 +27,9 @@ public function testExceptionExit()
27
27
28
28
$ xpath = $ this ->xmlToXpath ('<response text="Bye bye."/> ' );
29
29
30
- $ parser = (new Parser ($ xpath , 'ussd_wScXk ' ))->entry ('/*[1] ' );
30
+ $ ussd = (new Ussd ($ xpath , 'ussd_wScXk ' ))->entry ('/*[1] ' );
31
31
32
- $ parser -> parse ();
32
+ $ ussd -> handle ();
33
33
}
34
34
35
35
public function testProceedQuietly ()
@@ -43,14 +43,14 @@ public function testProceedQuietly()
43
43
44
44
$ xpath = $ this ->xmlToXpath ($ xml );
45
45
46
- $ parser = new Parser ($ xpath , 'ussd_wScXk ' );
46
+ $ ussd = new Ussd ($ xpath , 'ussd_wScXk ' );
47
47
48
- $ parser ->store = $ this ->store ; // ->set('name', 'John Doe');
48
+ $ ussd ->store = $ this ->store ; // ->set('name', 'John Doe');
49
49
50
- $ output = $ parser -> parse ();
50
+ $ output = $ ussd -> handle ();
51
51
52
52
static ::assertSame ('Enter username: ' , $ output );
53
- static ::assertSame ('John Doe ' , $ parser ->store ->get ('name ' ));
53
+ static ::assertSame ('John Doe ' , $ ussd ->store ->get ('name ' ));
54
54
}
55
55
56
56
public function testReuseSession ()
@@ -67,9 +67,9 @@ public function testReuseSession()
67
67
68
68
$ xpath = $ this ->xmlToXpath ($ xml );
69
69
70
- $ parser = new Parser ($ xpath , 'ussd_wScXk ' );
70
+ $ ussd = new Ussd ($ xpath , 'ussd_wScXk ' );
71
71
72
- $ output = $ parser -> parse ();
72
+ $ output = $ ussd -> handle ();
73
73
74
74
static ::assertSame ('Enter username: ' , $ output );
75
75
static ::assertSame ('ussd_wScXk ' , $ this ->store ->get ('_session_id ' ));
@@ -95,9 +95,9 @@ public function testBreakpoints()
95
95
96
96
$ xpath = $ this ->xmlToXpath ($ xml );
97
97
98
- $ parser = new Parser ($ xpath , 'ussd_wScXk ' );
98
+ $ ussd = new Ussd ($ xpath , 'ussd_wScXk ' );
99
99
100
- $ output = $ parser -> parse ();
100
+ $ output = $ ussd -> handle ();
101
101
102
102
static ::assertSame ('Say hi: ' , $ output );
103
103
}
@@ -114,9 +114,9 @@ public function testParseLongCode()
114
114
115
115
$ xpath = $ this ->xmlToXpath ($ xml );
116
116
117
- $ parser = (new Parser ($ xpath , 'ussd_wScXk ' ));
117
+ $ ussd = (new Ussd ($ xpath , 'ussd_wScXk ' ));
118
118
119
- $ output = $ parser -> parse ('Mr*John ' );
119
+ $ output = $ ussd -> handle ('Mr*John ' );
120
120
121
121
static ::assertSame ('Enter last name: ' , $ output );
122
122
}
@@ -138,14 +138,14 @@ public function testTracksAnswers()
138
138
139
139
$ xpath = $ this ->xmlToXpath ($ xml );
140
140
141
- $ parser = (new Parser ($ xpath , 'ussd_wScXk ' ));
141
+ $ ussd = (new Ussd ($ xpath , 'ussd_wScXk ' ));
142
142
143
- $ parser ->store ->put ('title ' , 'Mr. ' );
144
- $ parser ->store ->put ('_answer ' , 'Mr. ' );
143
+ $ ussd ->store ->put ('title ' , 'Mr. ' );
144
+ $ ussd ->store ->put ('_answer ' , 'Mr. ' );
145
145
146
- $ parser -> parse ('John*Doe ' );
146
+ $ ussd -> handle ('John*Doe ' );
147
147
148
- static ::assertSame ('Mr.*John*Doe ' , $ parser ->store ->get ('_answer ' ));
148
+ static ::assertSame ('Mr.*John*Doe ' , $ ussd ->store ->get ('_answer ' ));
149
149
}
150
150
151
151
public function testPathFromFile ()
@@ -160,9 +160,9 @@ public function testPathFromFile()
160
160
161
161
file_put_contents ($ menuFile , $ xml );
162
162
163
- $ parser = (new Parser ($ menuFile , 'ussd_wScXk ' ));
163
+ $ ussd = (new Ussd ($ menuFile , 'ussd_wScXk ' ));
164
164
165
- $ output = $ parser -> parse ('' );
165
+ $ output = $ ussd -> handle ('' );
166
166
167
167
static ::assertSame ('Enter username: ' , $ output );
168
168
@@ -177,13 +177,13 @@ public function testSaveOptions()
177
177
178
178
$ rand = rand (100 , 1000 );
179
179
180
- $ parser = (new Parser ($ xpath , 'ussd_wScXk ' ))
180
+ $ ussd = (new Ussd ($ xpath , 'ussd_wScXk ' ))
181
181
->entry ('/*[1] ' )
182
182
->save (['rand ' => $ rand ])
183
183
;
184
184
185
- $ parser -> parse ();
185
+ $ ussd -> handle ();
186
186
187
- static ::assertSame ($ rand , $ parser ->store ->get ('rand ' ));
187
+ static ::assertSame ($ rand , $ ussd ->store ->get ('rand ' ));
188
188
}
189
189
}
0 commit comments