-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement package specific functions for abstract remote function cal…
…l class
- Loading branch information
Showing
3 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* File src/AbstractRemoteFunctionCall.php | ||
* | ||
* PHP/SAP proxy class for SAP remote function calls. | ||
* | ||
* @package saprfc-harding | ||
* @author Gregor J. | ||
* @license MIT | ||
*/ | ||
|
||
namespace phpsap\saprfc; | ||
|
||
use phpsap\interfaces\IConfig; | ||
|
||
/** | ||
* Class phpsap\saprfc\AbstractRemoteFunctionCall | ||
* | ||
* Abstract class handling a PHP/SAP connection and remote function. | ||
* | ||
* @package phpsap\saprfc | ||
* @author Gregor J. | ||
* @license MIT | ||
*/ | ||
abstract class AbstractRemoteFunctionCall extends \phpsap\classes\AbstractRemoteFunctionCall | ||
{ | ||
/** | ||
* Create a connection instance using the given config. | ||
* @param \phpsap\interfaces\IConfig $config | ||
* @return \phpsap\interfaces\IConnection|\phpsap\saprfc\SapRfcConnection | ||
* @throws \phpsap\interfaces\exceptions\IIncompleteConfigException | ||
*/ | ||
protected function createConnectionInstance(IConfig $config) | ||
{ | ||
return new SapRfcConnection($config); | ||
} | ||
|
||
/** | ||
* Get the typecast of the expected return values. | ||
* @return \kbATeam\TypeCast\ITypeCast|null | ||
*/ | ||
protected function getReturnTypecast() | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* File src/AbstractRemoteFunctionCallTest.php | ||
* | ||
* Test the abstract remote function call. | ||
* | ||
* @package saprfc-harding | ||
* @author Gregor J. | ||
* @license MIT | ||
*/ | ||
|
||
namespace tests\phpsap\saprfc; | ||
|
||
use phpsap\saprfc\SapRfcConfigA; | ||
use phpsap\saprfc\SapRfcConnection; | ||
use PHPUnit\Framework\TestCase; | ||
use tests\phpsap\saprfc\helper\RemoteFunctionCall; | ||
|
||
/** | ||
* Class tests\phpsap\saprfc\AbstractRemoteFunctionCallTest | ||
* | ||
* Test the abstract remote function call. | ||
* | ||
* @package tests\phpsap\saprfc | ||
* @author Gregor J. | ||
* @license MIT | ||
*/ | ||
class AbstractRemoteFunctionCallTest extends TestCase | ||
{ | ||
/** | ||
* Test test creating a package specific connection instance. | ||
*/ | ||
public function testCreateConnectionInstance() | ||
{ | ||
$config = new SapRfcConfigA([ | ||
'ashost' => 'sap.example.com', | ||
'sysnr' => '001', | ||
'client' => '002', | ||
'user' => 'username', | ||
'passwd' => 'password' | ||
]); | ||
$rfc = new RemoteFunctionCall($config); | ||
$connection = $rfc->createConnectionInstance($config); | ||
static::assertInstanceOf(SapRfcConnection::class, $connection); | ||
} | ||
|
||
/** | ||
* Test getting an empty return typecast. | ||
*/ | ||
public function testGetReturnTypecast() | ||
{ | ||
$config = new SapRfcConfigA([ | ||
'ashost' => 'sap.example.com', | ||
'sysnr' => '001', | ||
'client' => '002', | ||
'user' => 'username', | ||
'passwd' => 'password' | ||
]); | ||
$rfc = new RemoteFunctionCall($config); | ||
static::assertNull($rfc->getReturnTypecast()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* File tests/helper/RemoteFunctionCall.php | ||
* | ||
* Helper class extending the abstract remote function class for testing. | ||
* | ||
* @package common | ||
* @author Gregor J. | ||
* @license MIT | ||
*/ | ||
|
||
namespace tests\phpsap\saprfc\helper; | ||
|
||
use phpsap\interfaces\IConfig; | ||
use phpsap\saprfc\AbstractRemoteFunctionCall; | ||
|
||
/** | ||
* Class tests\phpsap\saprfc\helper\RemoteFunctionCall | ||
* | ||
* Helper class extending the abstract remote function class for testing. | ||
* | ||
* @package tests\phpsap\saprfc\helper | ||
* @author Gregor J. | ||
* @license MIT | ||
*/ | ||
class RemoteFunctionCall extends AbstractRemoteFunctionCall | ||
{ | ||
/** | ||
* @var string function name | ||
*/ | ||
public $returnName = 'cketfemo'; | ||
|
||
/** | ||
* The SAP remote function name. | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->returnName; | ||
} | ||
|
||
/** | ||
* Make protected function public for testing. | ||
* Create a connection instance using the given config. | ||
* @param \phpsap\interfaces\IConfig $config | ||
* @return \phpsap\interfaces\IConnection|\phpsap\saprfc\SapRfcConnection | ||
* @throws \phpsap\interfaces\exceptions\IIncompleteConfigException | ||
*/ | ||
public function createConnectionInstance(IConfig $config) | ||
{ | ||
return parent::createConnectionInstance($config); | ||
} | ||
|
||
/** | ||
* Make protected function public for testing. | ||
* Get the typecast of the expected return values. | ||
* @return \kbATeam\TypeCast\ITypeCast|null | ||
*/ | ||
public function getReturnTypecast() | ||
{ | ||
return parent::getReturnTypecast(); | ||
} | ||
} |