Skip to content

Commit b8c4468

Browse files
committed
remove connection pool
1 parent e6e9643 commit b8c4468

File tree

5 files changed

+7
-272
lines changed

5 files changed

+7
-272
lines changed

exceptions/ConnectionNotFoundException.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/AbstractRemoteFunctionCall.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
*/
2626
abstract class AbstractRemoteFunctionCall implements IFunction
2727
{
28+
/**
29+
* @var \phpsap\interfaces\IConnection
30+
*/
31+
protected $connection;
32+
2833
/**
2934
* @var string The connection ID of the current SAP remote connection.
3035
*/
@@ -42,13 +47,7 @@ abstract class AbstractRemoteFunctionCall implements IFunction
4247
public function __construct(IConfig $config)
4348
{
4449
//create a new instance of the connection without actually connecting
45-
$connection = $this->createConnectionInstance($config);
46-
//determine the connection ID of the connection
47-
$this->connectionId = $connection->getId();
48-
//add the connection to the pool in case it doesn't exist there yet
49-
if (!ConnectionPool::has($this->connectionId)) {
50-
ConnectionPool::add($this->connectionId, $connection);
51-
}
50+
$this->connection = $this->createConnectionInstance($config);
5251
}
5352

5453
/**
@@ -100,9 +99,7 @@ public function invoke($params = null)
10099
protected function getFunction()
101100
{
102101
if ($this->function === null) {
103-
//now connect and prepare the function
104-
$this->function = ConnectionPool::get($this->connectionId)
105-
->prepareFunction($this->getName());
102+
$this->function = $this->connection->prepareFunction($this->getName());
106103
}
107104
return $this->function;
108105
}

src/ConnectionPool.php

Lines changed: 0 additions & 116 deletions
This file was deleted.

tests/AbstractRemoteFunctionCallTest.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
use kbATeam\TypeCast\TypeCastValue;
1616
use phpsap\classes\AbstractFunction;
1717
use phpsap\classes\AbstractRemoteFunctionCall;
18-
use phpsap\classes\ConnectionPool;
19-
use phpsap\exceptions\ConnectionNotFoundException;
2018
use phpsap\interfaces\IFunction;
2119
use tests\phpsap\classes\helper\ConfigA;
22-
use tests\phpsap\classes\helper\Connection;
2320
use tests\phpsap\classes\helper\RemoteFunction;
2421
use tests\phpsap\classes\helper\RemoteFunctionCall;
2522

@@ -59,38 +56,6 @@ public function testGetFunction()
5956
static::assertSame('awvovkms', $function->getName());
6057
}
6158

62-
/**
63-
* Test using the same connection config twice which should create only one
64-
* connection.
65-
*/
66-
public function testDuplicateConnectionInPool()
67-
{
68-
/**
69-
* Create a connection from a config and add it to the connection pool.
70-
*/
71-
$config = new ConfigA();
72-
$connection = new Connection($config);
73-
ConnectionPool::add($connection->getId(), $connection);
74-
/**
75-
* Create a new RFC from the same config, which should add the same
76-
* connection ID to the pool.
77-
*/
78-
$rfc = new RemoteFunctionCall($config);
79-
/**
80-
* Now remove the connection ID we created and see if the rfc runs into an
81-
* exception.
82-
*/
83-
ConnectionPool::remove($connection->getId());
84-
$this->setExpectedException(
85-
ConnectionNotFoundException::class,
86-
sprintf(
87-
'Connection ID \'%s\' does not exist.',
88-
$connection->getId()
89-
)
90-
);
91-
$rfc->getFunction();
92-
}
93-
9459
/**
9560
* Test setting a parameter.
9661
*/

tests/ConnectionPoolTest.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)