Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.

Commit ba5f526

Browse files
committed
cURL timeout option added
1 parent f6f8658 commit ba5f526

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ Konfigurace se provádí nastavením následujících konstant:
6161
*/
6262
define('FLEXIBEE_COMPANY', 'test_s_r_o_');
6363
/*
64-
* Nebo pokud nechceme používat jméno a heslo
64+
* Nebo pokud nechceme používat jméno a heslo
6565
*/
66-
define('FLEXIBEE_AUTHSESSID', '6QuifebMits');
66+
define('FLEXIBEE_AUTHSESSID', '6QuifebMits'); //Volitelné
67+
/*
68+
* Pomalý server, velká databáze a přes modem k tomu
69+
*/
70+
define('FLEXIBEE_TIMEOUT', 60); //Volitelné
6771
```
6872

6973
nebo je možné přihlašovací údaje zadávat při vytváření instance třídy.
@@ -217,6 +221,23 @@ administrátora zadaný při instalaci FlexiBee.)
217221
Upozornění: testování proti firmě s množstvím faktur a připojenou bankou může
218222
trvat nějakou dobu, jelikož se testuje i zavolání automatického párování dokladů.
219223

224+
Pokud se ve vašem projektu rozhodnete podědit FlexiPeeHP a k těmto třídám napíšete
225+
testy také poděděné z FlexiPeeHP např:
226+
227+
class HookRecieverTest extends \Test\FlexiPeeHP\ChangesTest
228+
229+
Přidejte do vašeho composer.json i cesty k původním testům:
230+
231+
"autoload-dev": {
232+
"psr-4": {
233+
"Test\\": "vendor/spoje.net/flexipeehp/testing/src/FlexiPeeHP/testing/",
234+
"Test\\Ease\\": "vendor/vitexsoftware/ease-framework/tests/src/Ease",
235+
"Test\\FlexiPeeHP\\": "vendor/spoje.net/flexipeehp/testing/src/FlexiPeeHP/",
236+
}
237+
}
238+
239+
240+
220241
Ukázka
221242
------
222243

debian/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "PHP Based Library for easy interaction with czech accounting system Flexibee.",
44
"homepage": "https://github.com/Spoje-NET/FlexiPeeHP",
55
"license": "GPL-2.0+",
6-
"version": "1.9.4",
6+
"version": "1.9.5",
77
"type": "library",
88
"authors": [
99
{

src/FlexiPeeHP/FlexiBeeRO.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ class FlexiBeeRO extends \Ease\Sand
366366
* @var boolean
367367
*/
368368
public $offline = false;
369+
370+
/**
371+
* Override cURL timeout
372+
* @var int seconds
373+
*/
374+
public $timeout = null;
369375

370376
/**
371377
* Class for read only interaction with FlexiBee.
@@ -392,6 +398,7 @@ public function __construct($init = null, $options = [])
392398
* company,url,evidence,
393399
* prefix,defaultUrlParams,debug,
394400
* detail,offline,filter,ignore404
401+
* timeout
395402
*/
396403
public function setUp($options = [])
397404
{
@@ -400,6 +407,7 @@ public function setUp($options = [])
400407
$this->setupProperty($options, 'user', 'FLEXIBEE_LOGIN');
401408
$this->setupProperty($options, 'password', 'FLEXIBEE_PASSWORD');
402409
$this->setupProperty($options, 'authSessionId', 'FLEXIBEE_AUTHSESSID');
410+
$this->setupProperty($options, 'timeout', 'FLEXIBEE_TIMEOUT');
403411
if (!empty($this->authSessionId)) {
404412
$this->defaultHttpHeaders['X-authSessionId'] = $this->authSessionId;
405413
}
@@ -462,6 +470,9 @@ public function getConnectionOptions()
462470
if (!empty($company)) {
463471
$conOpts['company'] = $company;
464472
}
473+
if(!is_null($this->timeout)){
474+
$conOpts['timeout'] = $this->timeout;
475+
}
465476
return $conOpts;
466477
}
467478

@@ -484,6 +495,9 @@ public function curlInit()
484495
curl_setopt($this->curl, CURLOPT_USERPWD,
485496
$this->user.':'.$this->password); // set username and password
486497
}
498+
if(!is_null($this->timeout)){
499+
curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->timeout);
500+
}
487501
}
488502
return !$this->offline;
489503
}

testing/src/FlexiPeeHP/FlexiBeeROTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function testSetupProperty()
9292
*/
9393
public function testCurlInit()
9494
{
95+
$this->object->timeout = 120;
9596
$this->object->curlInit();
9697
$this->assertTrue(is_resource($this->object->curl));
9798
}
@@ -101,6 +102,7 @@ public function testCurlInit()
101102
*/
102103
public function testProcessInit()
103104
{
105+
$this->object->processInit(1);
104106
$this->object->processInit(['id' => 1]);
105107
$this->assertEquals(1, $this->object->getDataValue('id'));
106108

@@ -159,6 +161,10 @@ public function testGetConnectionOptions()
159161
{
160162
$options = $this->object->getConnectionOptions();
161163
$this->assertArrayHasKey('url', $options);
164+
$this->object->timeout = 120;
165+
$this->object->authSessionId = 'sessid';
166+
$this->object->setCompany('test');
167+
$this->object->getConnectionOptions();
162168
}
163169

164170
/**
@@ -1026,7 +1032,7 @@ public function testFlexiDateTimeToDateTime()
10261032
*/
10271033
public function testSetDataValue()
10281034
{
1029-
if(!empty($this->object->getColumnsInfo())){
1035+
if (!empty($this->object->getColumnsInfo())) {
10301036
$this->object->setDataValue('datVyst', new \DateTime());
10311037
}
10321038
}

0 commit comments

Comments
 (0)