CSV files
DrevOps\BehatSteps\Steps\Web\CsvTrait - Source, Example, Helpers
Assert the columns, rows and values of CSV files.
- Assert the columns the header row names.
- Assert the number of data rows.
- Assert that rows holding given values exist or do not exist.
- Assert every data row of a file, in order.
- Assert that a value appears in a field, or in none.
A CSV file is read with a header row naming its columns,
,as the separator and"as the enclosure. A row step compares values exactly, and a column it does not list may hold anything.
A relative path is resolved against the directory the run was launched from. A path with a scheme, such astemporary://report.csv, is read through the stream wrapper PHP has registered for that scheme.
Steps
@Then the CSV file :path should have the following columns:
Assert that a CSV file has exactly the given columns, in order
Then the CSV file "report.csv" should have the following columns:
| clip_id | title | result |
@Then the CSV file :path should have the column :name
Assert that a CSV file has a column
Then the CSV file "report.csv" should have the column "result"
@Then the CSV file :path should not have the column :name
Assert that a CSV file does not have a column
Then the CSV file "report.csv" should not have the column "password"
@Then the CSV file :path should have :count row(s)
Assert that a CSV file has a number of data rows
Then the CSV file "report.csv" should have 3 rows
Then the CSV file "empty-report.csv" should have 0 rows
@Then the CSV file :path should contain the following row:
Assert that a CSV file contains a row holding the given values
Then the CSV file "report.csv" should contain the following row:
| clip_id | clip-1 |
| result | updated |
@Then the CSV file :path should not contain the following row:
Assert that a CSV file does not contain a row holding the given values
Then the CSV file "report.csv" should not contain the following row:
| clip_id | clip-1 |
| result | failed |
@Then the CSV file :path should contain the following rows:
Assert that a CSV file contains a row for each row of the table
Then the CSV file "report.csv" should contain the following rows:
| clip_id | result |
| clip-1 | updated |
| clip-2 | created |
@Then the CSV file :path should not contain the following rows:
Assert that a CSV file contains no row matching any row of the table
Then the CSV file "report.csv" should not contain the following rows:
| clip_id | result |
| clip-1 | failed |
| clip-2 | failed |
@Then the CSV file :path should have the following rows:
Assert that the data rows of a CSV file are exactly the table's rows
Then the CSV file "report.csv" should have the following rows:
| clip_id | result |
| clip-1 | updated |
| clip-2 | created |
@Then the CSV file :path should contain :value
Assert that a value appears in a field of a CSV file
Then the CSV file "report.csv" should contain "clip-1"
@Then the CSV file :path should not contain :value
Assert that a value appears in no field of a CSV file
Then the CSV file "report.csv" should not contain "error"