Skip to content

Commit cf201d9

Browse files
committed
implement package specific functions for abstract remote function call class
1 parent 368d05e commit cf201d9

File tree

3 files changed

+170
-0
lines changed

3 files changed

+170
-0
lines changed

src/AbstractRemoteFunctionCall.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* File src/AbstractRemoteFunctionCall.php
4+
*
5+
* PHP/SAP proxy class for SAP remote function calls.
6+
*
7+
* @package saprfc-harding
8+
* @author Gregor J.
9+
* @license MIT
10+
*/
11+
12+
namespace phpsap\saprfc;
13+
14+
use phpsap\interfaces\IConfig;
15+
16+
/**
17+
* Class phpsap\saprfc\AbstractRemoteFunctionCall
18+
*
19+
* Abstract class handling a PHP/SAP connection and remote function.
20+
*
21+
* @package phpsap\saprfc
22+
* @author Gregor J.
23+
* @license MIT
24+
*/
25+
abstract class AbstractRemoteFunctionCall extends \phpsap\classes\AbstractRemoteFunctionCall
26+
{
27+
/**
28+
* Create a connection instance using the given config.
29+
* @param \phpsap\interfaces\IConfig $config
30+
* @return \phpsap\interfaces\IConnection|\phpsap\saprfc\SapRfcConnection
31+
* @throws \phpsap\interfaces\exceptions\IIncompleteConfigException
32+
*/
33+
protected function createConnectionInstance(IConfig $config)
34+
{
35+
return new SapRfcConnection($config);
36+
}
37+
38+
/**
39+
* Get the typecast of the expected return values.
40+
* @return \kbATeam\TypeCast\ITypeCast|null
41+
*/
42+
protected function getReturnTypecast()
43+
{
44+
return null;
45+
}
46+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* File src/AbstractRemoteFunctionCallTest.php
4+
*
5+
* Test the abstract remote function call.
6+
*
7+
* @package saprfc-harding
8+
* @author Gregor J.
9+
* @license MIT
10+
*/
11+
12+
namespace tests\phpsap\saprfc;
13+
14+
use phpsap\saprfc\SapRfcConfigA;
15+
use phpsap\saprfc\SapRfcConnection;
16+
use tests\phpsap\saprfc\helper\RemoteFunctionCall;
17+
18+
/**
19+
* Class tests\phpsap\saprfc\AbstractRemoteFunctionCallTest
20+
*
21+
* Test the abstract remote function call.
22+
*
23+
* @package tests\phpsap\saprfc
24+
* @author Gregor J.
25+
* @license MIT
26+
*/
27+
class AbstractRemoteFunctionCallTest extends \PHPUnit_Framework_TestCase
28+
{
29+
/**
30+
* Test test creating a package specific connection instance.
31+
*/
32+
public function testCreateConnectionInstance()
33+
{
34+
$config = new SapRfcConfigA([
35+
'ashost' => 'sap.example.com',
36+
'sysnr' => '001',
37+
'client' => '002',
38+
'user' => 'username',
39+
'passwd' => 'password'
40+
]);
41+
$rfc = new RemoteFunctionCall($config);
42+
$connection = $rfc->createConnectionInstance($config);
43+
static::assertInstanceOf(SapRfcConnection::class, $connection);
44+
}
45+
46+
/**
47+
* Test getting an empty return typecast.
48+
*/
49+
public function testGetReturnTypecast()
50+
{
51+
$config = new SapRfcConfigA([
52+
'ashost' => 'sap.example.com',
53+
'sysnr' => '001',
54+
'client' => '002',
55+
'user' => 'username',
56+
'passwd' => 'password'
57+
]);
58+
$rfc = new RemoteFunctionCall($config);
59+
static::assertNull($rfc->getReturnTypecast());
60+
}
61+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* File tests/helper/RemoteFunctionCall.php
4+
*
5+
* Helper class extending the abstract remote function class for testing.
6+
*
7+
* @package common
8+
* @author Gregor J.
9+
* @license MIT
10+
*/
11+
12+
namespace tests\phpsap\saprfc\helper;
13+
14+
use phpsap\interfaces\IConfig;
15+
use phpsap\saprfc\AbstractRemoteFunctionCall;
16+
17+
/**
18+
* Class tests\phpsap\saprfc\helper\RemoteFunctionCall
19+
*
20+
* Helper class extending the abstract remote function class for testing.
21+
*
22+
* @package tests\phpsap\saprfc\helper
23+
* @author Gregor J.
24+
* @license MIT
25+
*/
26+
class RemoteFunctionCall extends AbstractRemoteFunctionCall
27+
{
28+
/**
29+
* @var string function name
30+
*/
31+
public $returnName = 'cketfemo';
32+
33+
/**
34+
* The SAP remote function name.
35+
* @return string
36+
*/
37+
public function getName()
38+
{
39+
return $this->returnName;
40+
}
41+
42+
/**
43+
* Make protected function public for testing.
44+
* Create a connection instance using the given config.
45+
* @param \phpsap\interfaces\IConfig $config
46+
* @return \phpsap\interfaces\IConnection|\phpsap\saprfc\SapRfcConnection
47+
* @throws \phpsap\interfaces\exceptions\IIncompleteConfigException
48+
*/
49+
public function createConnectionInstance(IConfig $config)
50+
{
51+
return parent::createConnectionInstance($config);
52+
}
53+
54+
/**
55+
* Make protected function public for testing.
56+
* Get the typecast of the expected return values.
57+
* @return \kbATeam\TypeCast\ITypeCast|null
58+
*/
59+
public function getReturnTypecast()
60+
{
61+
return parent::getReturnTypecast();
62+
}
63+
}

0 commit comments

Comments
 (0)