7
7
use RouterOS \Client ;
8
8
use RouterOS \Exceptions \ConfigException ;
9
9
use RouterOS \Exceptions \QueryException ;
10
- use RouterOS \Query ;
11
10
use RouterOS \Config ;
12
11
use RouterOS \Exceptions \ClientException ;
13
12
use RouterOS \Exceptions \ConnectException ;
@@ -40,7 +39,7 @@ public function setUp(): void
40
39
$ this ->config = [
41
40
'user ' => getenv ('ROS_USER ' ),
42
41
'pass ' => getenv ('ROS_PASS ' ),
43
- 'host ' => getenv ('ROS_HOST ' ),
42
+ 'host ' => getenv ('ROS_HOST_MODERN ' ),
44
43
'ssh_port ' => (int ) getenv ('ROS_SSH_PORT ' ),
45
44
];
46
45
@@ -66,11 +65,11 @@ public function testConstruct(): void
66
65
->set ('host ' , $ this ->config ['host ' ]);
67
66
68
67
$ obj = new Client ($ config );
69
- $ this -> assertIsObject ($ obj );
68
+ self :: assertIsObject ($ obj );
70
69
$ socket = $ obj ->getSocket ();
71
- $ this -> assertIsResource ($ socket );
70
+ self :: assertIsResource ($ socket );
72
71
} catch (Exception $ e ) {
73
- $ this -> assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
72
+ self :: assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
74
73
}
75
74
}
76
75
@@ -79,23 +78,23 @@ public function testConstruct2(): void
79
78
try {
80
79
$ config = new Config ($ this ->config );
81
80
$ obj = new Client ($ config );
82
- $ this -> assertIsObject ($ obj );
81
+ self :: assertIsObject ($ obj );
83
82
$ socket = $ obj ->getSocket ();
84
- $ this -> assertIsResource ($ socket );
83
+ self :: assertIsResource ($ socket );
85
84
} catch (Exception $ e ) {
86
- $ this -> assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
85
+ self :: assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
87
86
}
88
87
}
89
88
90
89
public function testConstruct3 (): void
91
90
{
92
91
try {
93
92
$ obj = new Client ($ this ->config );
94
- $ this -> assertIsObject ($ obj );
93
+ self :: assertIsObject ($ obj );
95
94
$ socket = $ obj ->getSocket ();
96
- $ this -> assertIsResource ($ socket );
95
+ self :: assertIsResource ($ socket );
97
96
} catch (Exception $ e ) {
98
- $ this -> assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
97
+ self :: assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
99
98
}
100
99
}
101
100
@@ -128,13 +127,13 @@ public function testConstructLegacy(): void
128
127
$ obj = new Client ([
129
128
'user ' => $ this ->config ['user ' ],
130
129
'pass ' => $ this ->config ['pass ' ],
131
- 'host ' => $ this -> config [ ' host ' ] ,
130
+ 'host ' => getenv ( ' ROS_HOST_LEGACY ' ) ,
132
131
'port ' => $ this ->port_legacy ,
133
132
'legacy ' => true ,
134
133
]);
135
- $ this -> assertIsObject ($ obj );
134
+ self :: assertIsObject ($ obj );
136
135
} catch (Exception $ e ) {
137
- $ this -> assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
136
+ self :: assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
138
137
}
139
138
}
140
139
@@ -153,9 +152,9 @@ public function testConstructLegacy2(): void
153
152
'port ' => $ this ->port_legacy ,
154
153
'legacy ' => false ,
155
154
]);
156
- $ this -> assertIsObject ($ obj );
155
+ self :: assertIsObject ($ obj );
157
156
} catch (Exception $ e ) {
158
- $ this -> assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
157
+ self :: assertStringContainsString ('Must be initialized ' , $ e ->getMessage ());
159
158
}
160
159
}
161
160
@@ -205,7 +204,7 @@ public function testPregResponse(string $line, array $result): void
205
204
{
206
205
$ matches = [];
207
206
$ this ->client ->pregResponse ($ line , $ matches );
208
- $ this -> assertEquals ($ matches , $ result );
207
+ self :: assertEquals ($ matches , $ result );
209
208
}
210
209
211
210
public function testQueryRead (): void
@@ -215,22 +214,22 @@ public function testQueryRead(): void
215
214
*/
216
215
217
216
$ read = $ this ->client ->query ('/system/package/print ' , ['name ' ])->read ();
218
- $ this -> assertNotEmpty ($ read );
217
+ self :: assertNotEmpty ($ read );
219
218
220
219
$ read = $ this ->client ->query ('/system/package/print ' , ['.id ' , '*1 ' ])->read ();
221
- $ this -> assertCount (1 , $ read );
220
+ self :: assertCount (1 , $ read );
222
221
223
222
$ read = $ this ->client ->query ('/system/package/print ' , ['.id ' , '= ' , '*1 ' ])->read ();
224
- $ this -> assertCount (1 , $ read );
223
+ self :: assertCount (1 , $ read );
225
224
226
225
$ read = $ this ->client ->query ('/system/package/print ' , [['name ' ]])->read ();
227
- $ this -> assertNotEmpty ($ read );
226
+ self :: assertNotEmpty ($ read );
228
227
229
228
$ read = $ this ->client ->query ('/system/package/print ' , [['.id ' , '*1 ' ]])->read ();
230
- $ this -> assertCount (1 , $ read );
229
+ self :: assertCount (1 , $ read );
231
230
232
231
$ read = $ this ->client ->query ('/system/package/print ' , [['.id ' , '= ' , '*1 ' ]])->read ();
233
- $ this -> assertCount (1 , $ read );
232
+ self :: assertCount (1 , $ read );
234
233
235
234
/*
236
235
* Build query with operations
@@ -240,43 +239,43 @@ public function testQueryRead(): void
240
239
['type ' , 'ether ' ],
241
240
['type ' , 'vlan ' ],
242
241
], '| ' )->read ();
243
- $ this -> assertCount (1 , $ read );
244
- $ this -> assertEquals ('*1 ' , $ read [0 ]['.id ' ]);
242
+ self :: assertCount (1 , $ read );
243
+ self :: assertEquals ('*1 ' , $ read [0 ]['.id ' ]);
245
244
246
245
/*
247
246
* Build query with tag
248
247
*/
249
248
250
249
$ read = $ this ->client ->query ('/system/package/print ' , null , null , 'zzzz ' )->read ();
251
250
252
- // $this-> assertCount(13, $read);
253
- $ this -> assertEquals ('zzzz ' , $ read [0 ]['tag ' ]);
251
+ // self:: assertCount(13, $read);
252
+ self :: assertEquals ('zzzz ' , $ read [0 ]['tag ' ]);
254
253
255
254
/*
256
255
* Build query with option count
257
256
*/
258
257
$ read = $ this ->client ->query ('/interface/monitor-traffic ' )->read (true , ['count ' => 3 ]);
259
- $ this -> assertCount (3 , $ read );
258
+ self :: assertCount (3 , $ read );
260
259
}
261
260
262
261
public function testReadAsIterator (): void
263
262
{
264
263
$ result = $ this ->client ->query ('/system/package/print ' )->readAsIterator ();
265
- $ this -> assertIsObject ($ result );
264
+ self :: assertIsObject ($ result );
266
265
}
267
266
268
267
public function testWriteReadString (): void
269
268
{
270
269
$ readTrap = $ this ->client ->query ('/interface ' )->read (false );
271
- $ this -> assertCount (3 , $ readTrap );
272
- $ this -> assertEquals ('!trap ' , $ readTrap [0 ]);
270
+ self :: assertCount (3 , $ readTrap );
271
+ self :: assertEquals ('!trap ' , $ readTrap [0 ]);
273
272
}
274
273
275
274
public function testFatal (): void
276
275
{
277
276
$ readTrap = $ this ->client ->query ('/quit ' )->read ();
278
- $ this -> assertCount (2 , $ readTrap );
279
- $ this -> assertEquals ('!fatal ' , $ readTrap [0 ]);
277
+ self :: assertCount (2 , $ readTrap );
278
+ self :: assertEquals ('!fatal ' , $ readTrap [0 ]);
280
279
}
281
280
282
281
public function queryExceptionDataProvider (): array
@@ -313,20 +312,20 @@ public function testQueryException(string $exception, $endpoint, $attributes): v
313
312
public function testExportMethod (): void
314
313
{
315
314
if (!in_array (gethostname (), ['pasha-lt ' , 'pasha-pc ' ])) {
316
- $ this -> markTestSkipped ('Travis does not allow to use SSH protocol on testing stage ' );
315
+ self :: markTestSkipped ('Travis does not allow to use SSH protocol on testing stage ' );
317
316
}
318
317
319
318
$ result = $ this ->client ->export ();
320
- $ this -> assertNotEmpty ($ result );
319
+ self :: assertNotEmpty ($ result );
321
320
}
322
321
323
322
public function testExportQuery (): void
324
323
{
325
324
if (!in_array (gethostname (), ['pasha-lt ' , 'pasha-pc ' ])) {
326
- $ this -> markTestSkipped ('Travis does not allow to use SSH protocol on testing stage ' );
325
+ self :: markTestSkipped ('Travis does not allow to use SSH protocol on testing stage ' );
327
326
}
328
327
329
328
$ result = $ this ->client ->query ('/export ' );
330
- $ this -> assertNotEmpty ($ result );
329
+ self :: assertNotEmpty ($ result );
331
330
}
332
331
}
0 commit comments