diff --git a/tests/ClientTest.php b/tests/ClientTest.php index ba5a679..52adb62 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -42,7 +42,13 @@ class ClientTest extends TestCase 'ssh_port' => (int) getenv('ROS_SSH_PORT'), ]; - $this->client = new Client($this->config); + $this->client = new class($this->config) extends Client { + // Convert protected method to public + public function pregResponse(string $value, ?array &$matches): void + { + parent::pregResponse($value, $matches); + } + }; $this->port_modern = (int) getenv('ROS_PORT_MODERN'); $this->port_legacy = (int) getenv('ROS_PORT_LEGACY'); @@ -176,6 +182,30 @@ class ClientTest extends TestCase ]); } + public function pregResponseDataProvider(): array + { + return [ + ['line' => '=.id=1', 'result' => [['=.id=1'], ['.id'], [1]]], + ['line' => '=name=kjhasdrlkh=5468=3456kh3l45', 'result' => [['=name=kjhasdrlkh=5468=3456kh3l45'], ['name'], ['kjhasdrlkh=5468=3456kh3l45']]], + ['line' => '=name==d===efault=a===123sadf=3=3===', 'result' => [['=name==d===efault=a===123sadf=3=3==='], ['name'], ['=d===efault=a===123sadf=3=3===']]], + ['line' => '=name============', 'result' => [['=name============'], ['name'], ['===========']]], + ['line' => '=on-login={:liahdf =aasdf(zz)a;ldfj}', 'result' => [['=on-login={:liahdf =aasdf(zz)a;ldfj}'], ['on-login'], ['{:liahdf =aasdf(zz)a;ldfj}']]], + ]; + } + + /** + * @dataProvider pregResponseDataProvider + * + * @param string $line + * @param array $result + */ + public function testPregResponse(string $line, array $result): void + { + $matches = []; + $this->client->pregResponse($line, $matches); + $this->assertEquals($matches, $result); + } + public function testQueryRead(): void { /* diff --git a/tests/Laravel/ServiceProviderTests.php b/tests/Laravel/ServiceProviderTests.php index 469a80b..7abe41f 100644 --- a/tests/Laravel/ServiceProviderTests.php +++ b/tests/Laravel/ServiceProviderTests.php @@ -10,6 +10,7 @@ class ServiceProviderTests extends TestCase private $client = [ '__construct', 'query', + 'readRAW', 'read', 'readAsIterator', 'parseResponse',