Skip to content
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"mustache/mustache": "^2.14.1",
"symfony/finder": ">2.7",
"wp-cli/mustangostang-spyc": "^0.6.3",
"wp-cli/php-cli-tools": "~0.12.1"
"wp-cli/php-cli-tools": "~0.12.3"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
Expand Down
36 changes: 36 additions & 0 deletions features/formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,39 @@ Feature: Format output
| gaa/gaa-log | * | ✔ |
| gaa/gaa-nonsense | v3.0.11 | 🛇 |
| gaa/gaa-100%new | v100%new | ✔ |

Scenario: Table rows containing linebreaks
Given an empty directory
And a file.php file:
"""
<?php
$items = array(
(object) array(
'post_id' => 1,
'meta_key' => 'foo',
'meta_value' => 'foo',
),
(object) array(
'post_id' => 1,
'meta_key' => 'fruits',
'meta_value' => "apple\nbanana\nmango",
),
(object) array(
'post_id' => 1,
'meta_key' => 'bar',
'meta_value' => 'br',
),
);
$assoc_args = array();
$formatter = new WP_CLI\Formatter( $assoc_args, array( 'post_id', 'meta_key', 'meta_value' ) );
$formatter->display_items( $items );
"""

When I run `wp eval-file file.php --skip-wordpress`
Then STDOUT should be a table containing rows:
| post_id | meta_key | meta_value |
| 1 | foo | foo |
| 1 | fruits | apple |
| | | banana |
| | | mango |
| 1 | bar | br |
Loading