Created
January 23, 2014 17:18
-
-
Save kevee/8582760 to your computer and use it in GitHub Desktop.
PHP code for moving quail tests around
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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