You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-1Lines changed: 52 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Install the client SDK:
16
16
composer require thenativeweb/eventsourcingdb
17
17
```
18
18
19
-
Import the package and create an instance by providing the URL of your EventSourcingDB instance and the API token to use:
19
+
Import the `Client` class and create an instance by providing the URL of your EventSourcingDB instance and the API token to use:
20
20
21
21
```php
22
22
require __DIR__ . '/vendor/autoload.php';
@@ -39,3 +39,54 @@ If you want to verify the API token, call `verifyApiToken`. If the token is inva
39
39
```php
40
40
$client->verifyApiToken();
41
41
```
42
+
43
+
### Using Testcontainers
44
+
45
+
Import the `Container` class, call the `start` function to run a test container, get a client, run your test code, and finally call the `stop` function to stop the test container:
46
+
47
+
```php
48
+
require __DIR__ . '/vendor/autoload.php';
49
+
50
+
use Thenativeweb\Eventsourcingdb\Container;
51
+
52
+
$container = new Container();
53
+
$container->start();
54
+
55
+
$client = $container->getClient();
56
+
57
+
// ...
58
+
59
+
$container->stop();
60
+
```
61
+
62
+
To check if the test container is running, call the `isRunning` function:
63
+
64
+
```php
65
+
$isRunning = $container->isRunning();
66
+
```
67
+
68
+
#### Configuring the Container Instance
69
+
70
+
By default, `Container` uses the `latest` tag of the official EventSourcingDB Docker image. To change that, call the `withImageTag` function:
71
+
72
+
```php
73
+
$container = new Container()
74
+
->withImageTag("1.0.0");
75
+
```
76
+
77
+
Similarly, you can configure the port to use and the API token. Call the `withPort` or the `withApiToken` function respectively:
78
+
79
+
```php
80
+
$container = new Container()
81
+
->withPort(4000)
82
+
->withApiToken("secret");
83
+
```
84
+
85
+
#### Configuring the Client Manually
86
+
87
+
In case you need to set up the client yourself, use the following functions to get details on the container:
88
+
89
+
-`getHost()` returns the host name
90
+
-`getMappedPort()` returns the port
91
+
-`getBaseUrl()` returns the full URL of the container
0 commit comments