Skip to content

Commit 8e6c487

Browse files
committed
fix: Update documentation.
1 parent 3a1b8cd commit 8e6c487

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Install the client SDK:
1616
composer require thenativeweb/eventsourcingdb
1717
```
1818

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:
2020

2121
```php
2222
require __DIR__ . '/vendor/autoload.php';
@@ -39,3 +39,54 @@ If you want to verify the API token, call `verifyApiToken`. If the token is inva
3939
```php
4040
$client->verifyApiToken();
4141
```
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
92+
- `getApiToken()` returns the API token

0 commit comments

Comments
 (0)