Skip to content

Commit eb8ffc4

Browse files
Add TuGraph test
1 parent 5eb5e8d commit eb8ffc4

4 files changed

Lines changed: 80 additions & 0 deletions

File tree

.github/workflows/tugraph.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests with TuGraph on PHP 8.5
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
branches: [ master ]
7+
8+
jobs:
9+
tugraph-tests:
10+
if: ${{ github.event.pull_request.draft == false }}
11+
runs-on: ubuntu-latest
12+
name: "Running Integration tests for PHP on TuGraph"
13+
14+
services:
15+
tugraph:
16+
image: tugraph/tugraph-runtime-centos7
17+
ports:
18+
- 7687:7687
19+
- 7070:7070
20+
- 9090:9090
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: '8.5'
30+
extensions: mbstring, sockets
31+
coverage: xdebug
32+
ini-values: max_execution_time=0, variables_order="EGPCS"
33+
34+
- name: Install dependencies
35+
run: composer install --no-progress
36+
37+
- name: Test with phpunit
38+
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite "TuGraph"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ We are trying to keep up and this library supports **Bolt <= 6**.
2929
- [ArcadeDB](https://arcadedb.com/)
3030
- [DozerDB](https://dozerdb.org/)
3131
- [ONgDB](https://graphfoundation.org/ongdb/)
32+
- [TuGraph](https://tugraph.tech/?lang=en-US)
3233

3334
## :white_check_mark: Requirements
3435

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@
2525
<testsuite name="ArcadeDB">
2626
<file>./tests/helpers/ClientTest.php</file>
2727
</testsuite>
28+
<testsuite name="TuGraph">
29+
<file>./tests/TuGraphTest.php</file>
30+
</testsuite>
2831
</testsuites>
2932
</phpunit>

tests/TuGraphTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Bolt\tests;
4+
5+
use Bolt\Bolt;
6+
use PHPUnit\Framework\TestCase;
7+
use Bolt\helpers\Client;
8+
use Bolt\connection\Socket;
9+
10+
/**
11+
* Class TuGraphTest
12+
*
13+
* @author Michal Stefanak
14+
* @link https://github.com/stefanak-michal/php-bolt-driver
15+
* @package Bolt\tests
16+
*/
17+
class TuGraphTest extends TestCase
18+
{
19+
public function testQuery(): void
20+
{
21+
$conn = new Socket('127.0.0.1', 7687);
22+
$bolt = new Bolt($conn);
23+
$bolt->setProtocolVersions(4.4);
24+
25+
$client = new Client($bolt->build(), ['scheme' => 'basic', 'principal' => 'admin', 'credentials' => '73@TuGraph']);
26+
$extra = ['db' => 'default'];
27+
28+
$data = $client->query('RETURN 1 AS num, "Hello, World!" AS str', [], $extra);
29+
$this->assertEquals(1, $data[0]['num']);
30+
$this->assertEquals('Hello, World!', $data[0]['str']);
31+
32+
$data = $client->queryFirstField('RETURN 1 AS num', [], $extra);
33+
$this->assertEquals(1, $data);
34+
35+
$data = $client->queryFirstColumn('UNWIND [1, 2, 3] AS num RETURN num', [], $extra);
36+
$this->assertEquals([1, 2, 3], $data);
37+
}
38+
}

0 commit comments

Comments
 (0)