Skip to content

Instantly share code, notes, and snippets.

@kevee
Created January 23, 2014 17:18
Show Gist options
  • Select an option

  • Save kevee/8582760 to your computer and use it in GitHub Desktop.

Select an option

Save kevee/8582760 to your computer and use it in GitHub Desktop.
PHP code for moving quail tests around
<?php
$json = json_decode(file_get_contents('dist/tests.json'));
$new = array();
$order = array(
'type', 'testability', 'title', 'description', 'guidelines', 'tags', 'components', 'strings', 'callback');
$no = array();
$arg = array();
foreach($json as $testname => $test) {
$n = array();
$options = array();
foreach((array)$test as $k => $v) {
if(!in_array($k, $order)) {
$options[$k] = $test->$k;
$arg[$k] = $k;
}
}
foreach($order as $o) {
if(isset($test->$o)) {
$n[$o] = $test->$o;
}
}
if(count($options)) {
$n['options'] = $options;
}
$new[$testname] = $n;
}
print json_encode($new);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment