Skip to content

Commit 88ac3a0

Browse files
Finetune of ServiceProviderTests, testPregResponse added to ClientTest
1 parent e94bea6 commit 88ac3a0

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

tests/ClientTest.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ public function setUp(): void
4242
'ssh_port' => (int) getenv('ROS_SSH_PORT'),
4343
];
4444

45-
$this->client = new Client($this->config);
45+
$this->client = new class($this->config) extends Client {
46+
// Convert protected method to public
47+
public function pregResponse(string $value, ?array &$matches): void
48+
{
49+
parent::pregResponse($value, $matches);
50+
}
51+
};
4652

4753
$this->port_modern = (int) getenv('ROS_PORT_MODERN');
4854
$this->port_legacy = (int) getenv('ROS_PORT_LEGACY');
@@ -176,6 +182,30 @@ public function testConstructWrongNet(): void
176182
]);
177183
}
178184

185+
public function pregResponseDataProvider(): array
186+
{
187+
return [
188+
['line' => '=.id=1', 'result' => [['=.id=1'], ['.id'], [1]]],
189+
['line' => '=name=kjhasdrlkh=5468=3456kh3l45', 'result' => [['=name=kjhasdrlkh=5468=3456kh3l45'], ['name'], ['kjhasdrlkh=5468=3456kh3l45']]],
190+
['line' => '=name==d===efault=a===123sadf=3=3===', 'result' => [['=name==d===efault=a===123sadf=3=3==='], ['name'], ['=d===efault=a===123sadf=3=3===']]],
191+
['line' => '=name============', 'result' => [['=name============'], ['name'], ['===========']]],
192+
['line' => '=on-login={:liahdf =aasdf(zz)a;ldfj}', 'result' => [['=on-login={:liahdf =aasdf(zz)a;ldfj}'], ['on-login'], ['{:liahdf =aasdf(zz)a;ldfj}']]],
193+
];
194+
}
195+
196+
/**
197+
* @dataProvider pregResponseDataProvider
198+
*
199+
* @param string $line
200+
* @param array $result
201+
*/
202+
public function testPregResponse(string $line, array $result): void
203+
{
204+
$matches = [];
205+
$this->client->pregResponse($line, $matches);
206+
$this->assertEquals($matches, $result);
207+
}
208+
179209
public function testQueryRead(): void
180210
{
181211
/*

tests/Laravel/ServiceProviderTests.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ServiceProviderTests extends TestCase
1010
private $client = [
1111
'__construct',
1212
'query',
13+
'readRAW',
1314
'read',
1415
'readAsIterator',
1516
'parseResponse',

0 commit comments

Comments
 (0)