Skip to content

Commit 9e58e96

Browse files
committed
[PATCH] Tests
1 parent 2dab931 commit 9e58e96

10 files changed

Lines changed: 44 additions & 74 deletions

.github/workflows/tests.yml

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,14 @@ on:
77
branches: [ main, master ]
88

99
jobs:
10-
unit:
10+
tests:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
fail-fast: false
1414
matrix:
1515
php-version: [ '8.2', '8.3', '8.4', '8.5' ]
1616

17-
name: Unit — PHP ${{ matrix.php-version }}
18-
19-
steps:
20-
- uses: actions/checkout@v6
21-
22-
- name: Setup PHP ${{ matrix.php-version }}
23-
uses: shivammathur/setup-php@v2
24-
with:
25-
php-version: ${{ matrix.php-version }}
26-
extensions: openssl, sockets, pcntl
27-
coverage: ${{ matrix.php-version == '8.5' && 'xdebug' || 'none' }}
28-
29-
- name: Install Composer dependencies
30-
run: composer install --no-interaction --prefer-dist
31-
32-
- name: Run unit tests
33-
run: vendor/bin/pest tests/Unit ${{ matrix.php-version == '8.5' && '--coverage-clover=coverage/unit-clover.xml' || '' }}
34-
35-
- name: Upload unit coverage to Codecov
36-
if: matrix.php-version == '8.5'
37-
uses: codecov/codecov-action@v5
38-
with:
39-
files: coverage/unit-clover.xml
40-
token: ${{ secrets.CODECOV_TOKEN }}
41-
flags: unit
42-
fail_ci_if_error: false
43-
44-
integration:
45-
runs-on: ubuntu-latest
46-
strategy:
47-
fail-fast: false
48-
matrix:
49-
php-version: [ '8.2', '8.3', '8.4', '8.5' ]
50-
51-
name: Integration — PHP ${{ matrix.php-version }}
17+
name: PHP ${{ matrix.php-version }}
5218

5319
steps:
5420
- uses: actions/checkout@v6
@@ -67,7 +33,7 @@ jobs:
6733
id: opcua
6834
uses: GianfriAur/opcua-test-server-suite@v1.1.4
6935

70-
- name: Run all tests
36+
- name: Run tests
7137
env:
7238
OPCUA_CERTS_DIR: ${{ steps.opcua.outputs.certs-dir }}
7339
run: vendor/bin/pest --log-junit=results/junit.xml ${{ matrix.php-version == '8.5' && '--coverage-clover=coverage/clover.xml' || '' }}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ OPCUA_AUTH_TOKEN=$(cat /etc/opcua/daemon.token) php bin/opcua-session-manager \
283283
| [opcua-laravel-client](https://github.com/GianfriAur/opcua-laravel-client) | Laravel integration — service provider, facade, config |
284284
| [opcua-test-server-suite](https://github.com/GianfriAur/opcua-test-server-suite) | Docker-based OPC UA test servers for integration testing |
285285

286+
## Roadmap
287+
288+
See [ROADMAP.md](ROADMAP.md) for what's coming next.
289+
286290
## Contributing
287291

288292
Contributions welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).

tests/Integration/AutoCertConnectionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
$dataValue = $client->read(NodeId::numeric(0, 2259));
4545
expect($dataValue->statusCode)->toBe(StatusCode::Good);
46-
expect($dataValue->value)->toBeInt()->toBe(0);
46+
expect($dataValue->getValue())->toBeInt()->toBe(0);
4747
} finally {
4848
TestHelper::safeDisconnect($client);
4949
}
@@ -95,7 +95,7 @@
9595
expect($secondSession)->not->toBe($firstSession);
9696

9797
$dataValue = $client->read(NodeId::numeric(0, 2259));
98-
expect($dataValue->value)->toBeInt();
98+
expect($dataValue->getValue())->toBeInt();
9999

100100
$client->disconnect();
101101
})->group('integration');
@@ -155,8 +155,8 @@
155155
expect($autoClient->getSessionId())->not->toBe($explicitClient->getSessionId());
156156

157157
// Both sessions should return valid data
158-
$v1 = $autoClient->read(NodeId::numeric(0, 2259))->value;
159-
$v2 = $explicitClient->read(NodeId::numeric(0, 2259))->value;
158+
$v1 = $autoClient->read(NodeId::numeric(0, 2259))->getValue();
159+
$v2 = $explicitClient->read(NodeId::numeric(0, 2259))->getValue();
160160
expect($v1)->toBeInt();
161161
expect($v2)->toBeInt();
162162

tests/Integration/ConnectionStateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
expect($client->isConnected())->toBeTrue();
5757

5858
$dv = $client->read(NodeId::numeric(0, 2259));
59-
expect($dv->value)->toBe(0);
59+
expect($dv->getValue())->toBe(0);
6060
} finally {
6161
TestHelper::safeDisconnect($client);
6262
}

tests/Integration/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
$client = TestHelper::connectNoSecurity();
4747
$dataValue = $client->read(NodeId::numeric(0, 2259));
4848
expect($dataValue->statusCode)->toBe(StatusCode::Good);
49-
expect($dataValue->value)->toBeInt()->toBe(0);
49+
expect($dataValue->getValue())->toBeInt()->toBe(0);
5050
} finally {
5151
TestHelper::safeDisconnect($client);
5252
}

tests/Integration/ReadTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'BooleanValue']);
2323
$dv = $client->read($nodeId);
2424
expect($dv->statusCode)->toBe(StatusCode::Good);
25-
expect($dv->value)->toBeBool();
25+
expect($dv->getValue())->toBeBool();
2626
} finally {
2727
TestHelper::safeDisconnect($client);
2828
}
@@ -35,7 +35,7 @@
3535
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'Int32Value']);
3636
$dv = $client->read($nodeId);
3737
expect($dv->statusCode)->toBe(StatusCode::Good);
38-
expect($dv->value)->toBeInt();
38+
expect($dv->getValue())->toBeInt();
3939
} finally {
4040
TestHelper::safeDisconnect($client);
4141
}
@@ -48,7 +48,7 @@
4848
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'DoubleValue']);
4949
$dv = $client->read($nodeId);
5050
expect($dv->statusCode)->toBe(StatusCode::Good);
51-
expect($dv->value)->toBeFloat();
51+
expect($dv->getValue())->toBeFloat();
5252
} finally {
5353
TestHelper::safeDisconnect($client);
5454
}
@@ -61,7 +61,7 @@
6161
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'StringValue']);
6262
$dv = $client->read($nodeId);
6363
expect($dv->statusCode)->toBe(StatusCode::Good);
64-
expect($dv->value)->toBeString();
64+
expect($dv->getValue())->toBeString();
6565
} finally {
6666
TestHelper::safeDisconnect($client);
6767
}
@@ -74,7 +74,7 @@
7474
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'FloatValue']);
7575
$dv = $client->read($nodeId);
7676
expect($dv->statusCode)->toBe(StatusCode::Good);
77-
expect($dv->value)->toBeFloat();
77+
expect($dv->getValue())->toBeFloat();
7878
} finally {
7979
TestHelper::safeDisconnect($client);
8080
}
@@ -87,7 +87,7 @@
8787
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'ByteValue']);
8888
$dv = $client->read($nodeId);
8989
expect($dv->statusCode)->toBe(StatusCode::Good);
90-
expect($dv->value)->toBeInt();
90+
expect($dv->getValue())->toBeInt();
9191
} finally {
9292
TestHelper::safeDisconnect($client);
9393
}
@@ -100,7 +100,7 @@
100100
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Scalar', 'UInt16Value']);
101101
$dv = $client->read($nodeId);
102102
expect($dv->statusCode)->toBe(StatusCode::Good);
103-
expect($dv->value)->toBeInt();
103+
expect($dv->getValue())->toBeInt();
104104
} finally {
105105
TestHelper::safeDisconnect($client);
106106
}
@@ -128,11 +128,11 @@
128128

129129
expect($results)->toHaveCount(3);
130130
expect($results[0]->statusCode)->toBe(StatusCode::Good);
131-
expect($results[0]->value)->toBeBool();
131+
expect($results[0]->getValue())->toBeBool();
132132
expect($results[1]->statusCode)->toBe(StatusCode::Good);
133-
expect($results[1]->value)->toBeInt();
133+
expect($results[1]->getValue())->toBeInt();
134134
expect($results[2]->statusCode)->toBe(StatusCode::Good);
135-
expect($results[2]->value)->toBeString();
135+
expect($results[2]->getValue())->toBeString();
136136
} finally {
137137
TestHelper::safeDisconnect($client);
138138
}
@@ -150,7 +150,7 @@
150150
$client = TestHelper::connectNoSecurity();
151151
$dv = $client->read(NodeId::numeric(0, 2259));
152152
expect($dv->statusCode)->toBe(StatusCode::Good);
153-
expect($dv->value)->toBe(0);
153+
expect($dv->getValue())->toBe(0);
154154
} finally {
155155
TestHelper::safeDisconnect($client);
156156
}
@@ -169,7 +169,7 @@
169169
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Array', 'Int32Array']);
170170
$dv = $client->read($nodeId);
171171
expect($dv->statusCode)->toBe(StatusCode::Good);
172-
expect($dv->value)->toBeArray()->not->toBeEmpty();
172+
expect($dv->getValue())->toBeArray()->not->toBeEmpty();
173173
} finally {
174174
TestHelper::safeDisconnect($client);
175175
}
@@ -182,7 +182,7 @@
182182
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'Array', 'StringArray']);
183183
$dv = $client->read($nodeId);
184184
expect($dv->statusCode)->toBe(StatusCode::Good);
185-
expect($dv->value)->toBeArray()->not->toBeEmpty();
185+
expect($dv->getValue())->toBeArray()->not->toBeEmpty();
186186
} finally {
187187
TestHelper::safeDisconnect($client);
188188
}
@@ -201,8 +201,8 @@
201201
$nodeId = TestHelper::browseToNode($client, ['TestServer', 'DataTypes', 'WithRange', 'Temperature']);
202202
$dv = $client->read($nodeId);
203203
expect($dv->statusCode)->toBe(StatusCode::Good);
204-
expect($dv->value)->toBeFloat();
205-
expect($dv->value)->toBeGreaterThan(20.0)->toBeLessThan(25.0);
204+
expect($dv->getValue())->toBeFloat();
205+
expect($dv->getValue())->toBeGreaterThan(20.0)->toBeLessThan(25.0);
206206
} finally {
207207
TestHelper::safeDisconnect($client);
208208
}

tests/Integration/SecurityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function stopAuthDaemon(): void
371371
expect($client->getSessionId())->toBeString()->not->toBeEmpty();
372372

373373
$dataValue = $client->read(NodeId::numeric(0, 2259));
374-
expect($dataValue->value)->toBeInt();
374+
expect($dataValue->getValue())->toBeInt();
375375

376376
$client->disconnect();
377377
})->group('integration');

tests/Integration/TimeoutAndBatchingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
$dv = $client->read(NodeId::numeric(0, 2259));
2222
expect($dv->statusCode)->toBe(StatusCode::Good);
23-
expect($dv->value)->toBe(0);
23+
expect($dv->getValue())->toBe(0);
2424
} finally {
2525
TestHelper::safeDisconnect($client);
2626
}

tests/Integration/TranslateBrowsePathTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
]);
7373

7474
expect($results)->toBeArray()->toHaveCount(1);
75-
expect($results[0]['statusCode'])->toBe(StatusCode::Good);
76-
expect($results[0]['targets'])->toBeArray()->not->toBeEmpty();
77-
expect($results[0]['targets'][0]['targetId'])->toBeInstanceOf(NodeId::class);
78-
expect($results[0]['targets'][0]['targetId']->identifier)->toBe(2253);
75+
expect($results[0]->statusCode)->toBe(StatusCode::Good);
76+
expect($results[0]->targets)->toBeArray()->not->toBeEmpty();
77+
expect($results[0]->targets[0]->targetId)->toBeInstanceOf(NodeId::class);
78+
expect($results[0]->targets[0]->targetId->identifier)->toBe(2253);
7979
} finally {
8080
TestHelper::safeDisconnect($client);
8181
}

tests/Integration/WriteTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
$dv = $client->read($nodeId);
2828
expect($dv->statusCode)->toBe(StatusCode::Good);
29-
expect($dv->value)->toBeTrue();
29+
expect($dv->getValue())->toBeTrue();
3030

3131
// Write false
3232
$statusCode = $client->write($nodeId, false, BuiltinType::Boolean);
3333
expect(StatusCode::isGood($statusCode))->toBeTrue();
3434

3535
$dv = $client->read($nodeId);
36-
expect($dv->value)->toBeFalse();
36+
expect($dv->getValue())->toBeFalse();
3737
} finally {
3838
TestHelper::safeDisconnect($client);
3939
}
@@ -50,7 +50,7 @@
5050

5151
$dv = $client->read($nodeId);
5252
expect($dv->statusCode)->toBe(StatusCode::Good);
53-
expect($dv->value)->toBe(12345);
53+
expect($dv->getValue())->toBe(12345);
5454
} finally {
5555
TestHelper::safeDisconnect($client);
5656
}
@@ -67,7 +67,7 @@
6767

6868
$dv = $client->read($nodeId);
6969
expect($dv->statusCode)->toBe(StatusCode::Good);
70-
expect(abs($dv->value - 3.14159))->toBeLessThan(0.0001);
70+
expect(abs($dv->getValue() - 3.14159))->toBeLessThan(0.0001);
7171
} finally {
7272
TestHelper::safeDisconnect($client);
7373
}
@@ -85,7 +85,7 @@
8585

8686
$dv = $client->read($nodeId);
8787
expect($dv->statusCode)->toBe(StatusCode::Good);
88-
expect($dv->value)->toBe($testString);
88+
expect($dv->getValue())->toBe($testString);
8989
} finally {
9090
TestHelper::safeDisconnect($client);
9191
}
@@ -102,7 +102,7 @@
102102

103103
$dv = $client->read($nodeId);
104104
expect($dv->statusCode)->toBe(StatusCode::Good);
105-
expect($dv->value)->toBe(200);
105+
expect($dv->getValue())->toBe(200);
106106
} finally {
107107
TestHelper::safeDisconnect($client);
108108
}
@@ -132,10 +132,10 @@
132132

133133
// Read back
134134
$dvInt = $client->read($intNodeId);
135-
expect($dvInt->value)->toBe(9999);
135+
expect($dvInt->getValue())->toBe(9999);
136136

137137
$dvStr = $client->read($strNodeId);
138-
expect($dvStr->value)->toBe('multi-write-test');
138+
expect($dvStr->getValue())->toBe('multi-write-test');
139139
} finally {
140140
TestHelper::safeDisconnect($client);
141141
}
@@ -159,7 +159,7 @@
159159

160160
$dv = $client->read($nodeId);
161161
expect($dv->statusCode)->toBe(StatusCode::Good);
162-
expect($dv->value)->toBe($values);
162+
expect($dv->getValue())->toBe($values);
163163
} finally {
164164
TestHelper::safeDisconnect($client);
165165
}
@@ -177,7 +177,7 @@
177177

178178
$dv = $client->read($nodeId);
179179
expect($dv->statusCode)->toBe(StatusCode::Good);
180-
expect($dv->value)->toBe($values);
180+
expect($dv->getValue())->toBe($values);
181181
} finally {
182182
TestHelper::safeDisconnect($client);
183183
}

0 commit comments

Comments
 (0)