5 * Tests for outputformat.drush.inc
10 class outputFormatUnitCase extends UnitUnishTestCase {
13 * Test various output formats using php-eval with no Drupal site.
15 * @dataProvider provider
17 public function testOutputFormat($name, $format, $data, $expected) {
19 $this->assertEquals($expected, trim(drush_format($data, array(), $format)), $name . ': '. $format);
22 public function provider() {
23 $json = '{"a":{"b":2,"c":3},"d":{"e":5,"f":6}}';
24 if (version_compare(phpversion(), '5.4.0', '>=')) {
25 $json = json_encode(json_decode($json), JSON_PRETTY_PRINT);
30 'name' => 'String test',
32 'data' => array('drush version' => '6.0-dev'),
33 'expected' => '6.0-dev',
36 'name' => 'List test',
38 'data' => array('drush version' => '6.0-dev'),
39 'expected' => '6.0-dev',
42 'name' => 'Key-value test',
43 'format' => 'key-value',
44 'data' => array('drush version' => '6.0-dev'),
45 'expected' => 'drush version : 6.0-dev',
48 // 'name' => 'Table test',
49 // 'format' => 'table',
51 // 'a' => array('b' => 2, 'c' => 3),
52 // 'd' => array('b' => 5, 'c' => 6),
59 'name' => 'print-r test',
60 'format' => 'print-r',
62 'a' => array('b' => 2, 'c' => 3),
63 'd' => array('b' => 5, 'c' => 6),
82 'name' => 'json test',
85 'a' => array('b' => 2, 'c' => 3),
86 'd' => array('e' => 5, 'f' => 6),
91 // 'name' => 'key-value test 1d array',
92 // 'format' => 'key-value',
94 // 'b' => 'Two B or ! Two B, that is the comparison',
95 // 'c' => 'I see that C has gone to Sea',
97 // 'expected' => "b : Two B or ! Two B, that is the comparison
98 // c : I see that C has gone to Sea",
101 // 'name' => 'key-value test 2d array',
102 // 'format' => 'key-value',
105 // 'b' => 'Two B or ! Two B, that is the comparison',
106 // 'c' => 'I see that C has gone to Sea',
109 // 'e' => 'Elephants and electron microscopes',
110 // 'f' => 'My margin is too small',
113 // 'expected' => "a : Two B or ! Two B, that is the comparison
114 // I see that C has gone to Sea
115 // d : Elephants and electron microscopes
116 // My margin is too small",
119 'name' => 'export test',
120 'format' => 'var_export',
122 'a' => array('b' => 2, 'c' => 3),
123 'd' => array('e' => 5, 'f' => 6),
125 'expected' => "array(
137 // 'name' => 'config test',
138 // 'format' => 'config',
140 // 'a' => array('b' => 2, 'c' => 3),
141 // 'd' => array('e' => 5, 'f' => 6),
143 // 'expected' => "\$config[\"a\"] = array (
147 //\$config[\"d\"] = array (
153 'name' => 'variables test',
154 'format' => 'variables',
156 'a' => array('b' => 2, 'c' => 3),
157 'd' => array('e' => 5, 'f' => 6),
159 'expected' => "\$a[\"b\"] = 2;