<?php
namespace Inanimatt\SiteBuilder\Serialiser;

/**
 * Generated by PHPUnit_SkeletonGenerator on 2012-05-28 at 10:24:11.
 */
class FileSerialiserTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var FileSerialiser
     */
    protected $object;
    
    protected $outputPath;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     * 
     * @covers Inanimatt\SiteBuilder\Serialiser\FileSerialiser::__construct
     */
    protected function setUp()
    {
        $this->outputPath = sys_get_temp_dir().sprintf('/sitebuilder-test-%08x', crc32(microtime(true)));
        $this->object = new FileSerialiser($this->outputPath);
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        rmdir($this->outputPath);
    }

    /**
     * @covers Inanimatt\SiteBuilder\Serialiser\FileSerialiser::write
     */
    public function testWrite()
    {
        $this->assertFalse(is_dir($this->outputPath), 'Output directory does not exist before write');

        $pathName = $this->outputPath.'/testfile';
        $filename = 'testfile';
        
        $test_content = 'Lorem ipsum';
        
        $this->object->write($test_content, $filename);
        
        $this->assertEquals($test_content, file_get_contents($pathName), 'Can read written content.');
        
        unlink($pathName);
    }
}

Add unit tests for FileSerialiser
Add unit tests for FileSerialiser
