Skip to content

Commit f347edb

Browse files
committed
Document how to use another driver
1 parent 6a47e43 commit f347edb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,28 @@ protected function getSnapshotDirectory(): string
197197
}
198198
```
199199

200+
### Using specific Drivers
201+
202+
The driver used to serialize the data can be specificied as second argument of the
203+
`assertMatchesSnapshot` method, so you can pick one that better suits your needs:
204+
205+
```php
206+
use Spatie\Snapshots\Drivers\ObjectDriver;
207+
use Spatie\Snapshots\MatchesSnapshots;
208+
209+
class OrderTest
210+
{
211+
use MatchesSnapshots;
212+
213+
public function test_snapshot_with_object_driver()
214+
{
215+
$order = new Order(1);
216+
217+
$this->assertMatchesSnapshot($order, new ObjectDriver());
218+
}
219+
}
220+
```
221+
200222
### Writing Custom Drivers
201223

202224
Drivers ensure that different types of data can be serialized and matched in their own way. A driver is a class that implements the `Spatie\Snapshots\Driver` interface, which requires three method implementations: `serialize`, `extension` and `match`.

0 commit comments

Comments
 (0)