Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Plugin > Allow setting order of columns when using headers #28

Open
tienvx opened this issue Apr 3, 2023 · 1 comment
Open

CSV Plugin > Allow setting order of columns when using headers #28

tienvx opened this issue Apr 3, 2023 · 1 comment
Labels
enhancement Indicates new feature requests

Comments

@tienvx
Copy link
Contributor

tienvx commented Apr 3, 2023

Currently we can't set order of columns if we use headers:

$response
     ->setStatus(200)
    ->setBody([
        'csvHeaders' => true,
        'column:id' => "matching(regex, '^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$','{$id}')",
        'column:name' => "matching(type,'{$name}')",
        'column:gender' => "matching(regex, 'male|female|other','{$gender}')",
    ])
    ->setContentType('text/csv')
 ;

Then mock server will response with columns that are sorted by column's name in ascending order:

gender,id,name
$gender,$id,$name

I suggest adding 'csvColumns' => 'id,name,gender' so:

  • Mock server will return columns in this order
  • Provider verifier will verify csv's columns in this order
@rholshausen rholshausen added the enhancement Indicates new feature requests label Apr 4, 2023
@rholshausen
Copy link
Contributor

The main problem is that the map used for the data here

[
        'csvHeaders' => true,
        'column:id' => "matching(regex, '^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$','{$id}')",
        'column:name' => "matching(type,'{$name}')",
        'column:gender' => "matching(regex, 'male|female|other','{$gender}')",
    ]

does not guarantee insertion order. This will need some other mechanism to determine what the key order is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants