21
21
* actual module and an actual SAP system.
22
22
*/
23
23
if (extension_loaded ('sapnwrfc ' )) {
24
- throw new \ RuntimeException ('PHP module sapnwrfc is loaded. Cannot run tests using mockups. ' );
24
+ die ('PHP module sapnwrfc is loaded. Cannot run tests using mockups. ' );
25
25
}
26
26
27
27
/**
@@ -73,7 +73,7 @@ class Exception extends \RuntimeException
73
73
*
74
74
* @returns array|null
75
75
*/
76
- public function getErrorInfo (): array
76
+ public function getErrorInfo (): ? array
77
77
{
78
78
return $ this ->errorInfo ;
79
79
}
@@ -102,21 +102,34 @@ class FunctionCallException extends Exception
102
102
class Connection
103
103
{
104
104
/**
105
- * Disable SAP remote function call tracing.
105
+ * Off. Only severe errors are logged to the dev_rfc.log file.
106
+ * @var int
106
107
*/
107
108
public const TRACE_LEVEL_OFF = 0 ;
108
109
/**
109
- * Brief tracing of SAP remote function calls.
110
+ * Brief. All API calls (except for the setter and getter functions) and important attributes like codepages,
111
+ * RFC headers, logon parameters are traced. Trace is written to a file named rfc<pid>.trc or
112
+ * rfc<pid>_<tid>.trc, depending on whether tracing is done on a "per-process" basis or a "per-thread" basis.
113
+ * <pid> is the current process ID, <tid> the current thread ID.
114
+ * @var int
110
115
*/
111
116
public const TRACE_LEVEL_BRIEF = 1 ;
112
117
/**
113
- * Verbose tracing of SAP remote function calls.
118
+ * Verbose. In addition to 1, the values of the "scalar" RFC parameters as well as the contents of the network
119
+ * containers are traced. Scalar parameters are primitive types (CHAR, INT, FLOAT, etc) and flat structures.
120
+ * @var int
114
121
*/
115
122
public const TRACE_LEVEL_VERBOSE = 2 ;
116
123
/**
117
- * Debug-like tracing of SAP remote function calls.
124
+ * Detailed. In addition to 2 the contents of nested structures and tables and hexdumps are traced.
125
+ * @var int
118
126
*/
119
- public const TRACE_LEVEL_FULL = 3 ;
127
+ public const TRACE_LEVEL_DETAILED = 3 ;
128
+ /**
129
+ * Full. In addition to 3 all API calls of setter and getter functions and table operations are traced.
130
+ * @var int
131
+ */
132
+ public const TRACE_LEVEL_FULL = 4 ;
120
133
121
134
/**
122
135
* Connect to the system using the given parameters.
@@ -166,19 +179,41 @@ public function ping(): bool
166
179
* Lookup a RFC function and return a RemoteFunction object.
167
180
*
168
181
* @param string $functionnName Name of the function.
182
+ * @param bool $invalidateCache If true, invalidates the function desc cache.
169
183
*
170
184
* @return RemoteFunction A RemoteFunction class for the RFC function.
171
185
*
172
186
* @throws FunctionCallException if the lookup fails or an error is
173
187
* returned during parameter parsing.
174
188
*/
175
- public function getFunction (string $ functionName ): RemoteFunction
189
+ public function getFunction (string $ functionName, bool $ invalidateCache = false ): RemoteFunction
176
190
{
177
191
$ func = \phpsap \IntegrationTests \SapRfcModuleMocks::singleton ()
178
192
->get ('\SAPNWRFC\Connection:: ' . __FUNCTION__ );
179
193
return $ func ($ functionName );
180
194
}
181
195
196
+ /**
197
+ * Retrieve a SSO ticket from the connection.
198
+ *
199
+ * For this to work, the connection must be opened with parameter `GETSSO2=1`
200
+ * and the profile parameter `login/create_sso2_ticket` must be set to a value
201
+ * different from '0' in the backend.
202
+ *
203
+ * Note: To retrieve a SSO ticket from the connection, SDK version 7.50.1 or
204
+ * later is required.
205
+ *
206
+ * @return string The SSO ticket.
207
+ *
208
+ * @throws ConnectionException if no SSO ticket could be retrieved.
209
+ */
210
+ public function getSSOTicket (): string
211
+ {
212
+ $ func = \phpsap \IntegrationTests \SapRfcModuleMocks::singleton ()
213
+ ->get ('\SAPNWRFC\Connection:: ' . __FUNCTION__ );
214
+ return $ func ();
215
+ }
216
+
182
217
/**
183
218
* Close the connection.
184
219
*
@@ -234,7 +269,7 @@ public static function reloadIniFile(): bool
234
269
*
235
270
* @param string $path Path to trace directory (must exist).
236
271
*
237
- * @return bool True if path was set.
272
+ * @return true True if path was set (BC) .
238
273
*
239
274
* @throws ConnectionException if path could not be set.
240
275
*/
@@ -250,7 +285,7 @@ public static function setTraceDir(string $path): bool
250
285
*
251
286
* @param int $level Trace level.
252
287
*
253
- * @return bool True if level was set.
288
+ * @return true True if trace level was set (BC) .
254
289
*
255
290
* @throws ConnectionException if level could not be set.
256
291
*/
@@ -261,14 +296,34 @@ public static function setTraceLevel(int $level): bool
261
296
return $ func ($ level );
262
297
}
263
298
299
+ /**
300
+ * Sets the global logon timeout in seconds.
301
+ *
302
+ * Sets the timeout for how long the logon in the ABAP backend can take when opening a connection.
303
+ * The default value is 60 seconds.
304
+ *
305
+ * The timeout can also be set via <code>RFC_GLOBAL_LOGON_TIMEOUT</code> in the <code>DEFAULT</code>
306
+ * section of the <em>sapnwrfc.ini</em> file.
307
+ *
308
+ * @param int $timeout Timeout in seconds (1 - 3600).
309
+ *
310
+ * @throws ConnectionException if timeout cannot be set or is out of range.
311
+ */
312
+ public static function setGlobalLogonTimeout (int $ timeout ): void
313
+ {
314
+ $ func = \phpsap \IntegrationTests \SapRfcModuleMocks::singleton ()
315
+ ->get ('\SAPNWRFC\Connection:: ' . __FUNCTION__ );
316
+ $ func ($ timeout );
317
+ }
318
+
264
319
/**
265
320
* Get the extension version.
266
321
*
267
322
* @return string The extension version.
268
323
*/
269
324
public static function version (): string
270
325
{
271
- return 'SAPNWRFC MOCKUP 1.0 ' ;
326
+ return 'SAPNWRFC MOCKUP 2. 1.0 ' ;
272
327
}
273
328
274
329
/**
@@ -289,7 +344,8 @@ public static function rfcVersion(): string
289
344
class RemoteFunction
290
345
{
291
346
/**
292
- * RemoteFunction constructor.
347
+ * Manually inserted RemoteFunction constructor for ease of creation by
348
+ * \SAPNWRFC\Connection::getFunction()
293
349
* @param string $name function name
294
350
*/
295
351
public function __construct ($ name )
@@ -325,7 +381,7 @@ public function invoke(array $parameters = [], array $options = []): array
325
381
*
326
382
* @throws FunctionCallException if the parameter status could not be set.
327
383
*/
328
- public function setParameterActive (string $ parameterName , bool $ isActive )
384
+ public function setParameterActive (string $ parameterName , bool $ isActive ): void
329
385
{
330
386
$ func = \phpsap \IntegrationTests \SapRfcModuleMocks::singleton ()
331
387
->get ('\SAPNWRFC\RemoteFunction:: ' . __FUNCTION__ );
@@ -347,14 +403,28 @@ public function isParameterActive(string $parameterName): bool
347
403
}
348
404
349
405
/**
350
- * Return the SAP remote function API description as array.
406
+ * Get the function's parameter description.
407
+ *
408
+ * @return array The parameter descriptions, indexed by parameter name.
351
409
*
352
- * @return array
410
+ * @throws FunctionCallException if the interface description cannot be retrieved.
353
411
*/
354
412
public function getFunctionDescription (): array
355
413
{
356
414
$ func = \phpsap \IntegrationTests \SapRfcModuleMocks::singleton ()
357
415
->get ('\SAPNWRFC\RemoteFunction:: ' . __FUNCTION__ );
358
416
return $ func ();
359
417
}
418
+
419
+ /**
420
+ * Get the function's name.
421
+ *
422
+ * @return string The function name.
423
+ */
424
+ public function getName (): string
425
+ {
426
+ $ func = \phpsap \IntegrationTests \SapRfcModuleMocks::singleton ()
427
+ ->get ('\SAPNWRFC\RemoteFunction:: ' . __FUNCTION__ );
428
+ return $ func ();
429
+ }
360
430
}
0 commit comments