YAML Now Supported by PHPUnit Database Extension

I have now just committed YAML data sets to the Database Extension for PHPUnit. So now all those that love the simplicity and straightforwardness of YAML can use it with your data sets. I have also created a persistor for YAML datasets so you can easily convert existing data sets or database data into YAML representations.

This is really the first I have dealt with YAML and it is definitely a viable alternative for data sets. Here is what they will look like.

The biggest issue I had was figuring out how YAML dealt with trailing line breaks. It appears that ‘|-’ did the trick. It will strip the final line break. Another thing to take note is that indention is important. It doesn’t HAVE to be spaces (it can be tabs) it just needs to be consistent. The last thing is that strings do not need to be quoted, but if they are you can use escape characters (like n.)

This was committed to the trunk of PHPUnit and I anticipate Sebastian will be merging it back into 3.4 shortly.

8 thoughts on “YAML Now Supported by PHPUnit Database Extension”

  1. Can you give an example of how to use it? I’ve looked around in the API documentation but I didn’t see a PHPUnit_Extensions_Database_DataSet_YamlDataSet or anything similar.

    Thanks!

  2. Largely a lack of time on my part. There will be a fairly thorough description of this functionality in a soon to be released book. I am also attempting to put some more time in on my personal projects which would include some long awaited documentation and bug fixes. I have to feed the family first ;).

  3. found it, with 3.4.12 (current stable), there’s actually a yaml data set class
    thanks for the great work, yaml is great for fixture

    [geshi lang=php]
    require_once ‘PHPUnit/Extensions/Database/DataSet/YamlDataSet.php’;
    protected function getDataSet() {
    return new PHPUnit_Extensions_Database_DataSet_YamlDataSet($path_to_yaml);
    }
    [/lang]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">