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
+77-25Lines changed: 77 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,65 @@
1
-
# This is my package tabular-assertions
1
+
# Write tabular assertions with Pest or PHPUnit
2
2
3
3
[](https://packagist.org/packages/spatie/tabular-assertions)
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
8
+
**🚧 This package is under development! Documentation is scarce and it isn't published on Packagist yet but feel free to play around already.**
9
+
10
+
Tabular assertions allow you to describe data in a Markdown table-like format and compare it to the actual data. This is especially useful when comparing large, ordered data sets like financial data or a time series.
With Pest, the plugin will be autoloaded and readily available. Use the custom `toMatchTable()` expectation to compare data with a table.
38
85
39
-
This is the contents of the published config file:
86
+
### Basic usage: PHPUnit
40
87
41
-
```php
42
-
return [
43
-
];
44
-
```
88
+
With PHPUnit, add the `Spatie\TabularAssertions\PHPUnit\TabularAssertions` trait to the tests you want to use tabular assertions with. Use `$this->assertMatchesTable()` to compare data with a table.
Sometimes you want to compare data without actually comparing the exact value. For example, you want to assert that each person is in the same team, but don't know the team ID because the data is randomly seeded on every run. A column can be marked as "dynamic" by prefixing its name with a `#`. Dynamic columns will replace values with placeholders. A placeholder is unique for the value in the column. So a team with ID `123` would always be rendered as `#1`, another team `456` with `#2` etc.
51
93
52
-
## Usage
94
+
For example, Sebastian & Freek are in team Spatie which has a random ID, and Christoph is in team Laravel with another random ID.
53
95
54
-
```php
55
-
$tabularAssertions = new Spatie\TabularAssertions();
0 commit comments