<commit_before><commit_msg>Add unit tests for FileSerialiser<commit_after><?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);
    }
}
{'fraction_non_alphanumeric': 0.11892901618929017, 'fraction_numerical': 0.0112079701120797, 'mean_word_length': 2.7372093023255815, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1790854', 'n_tokens_mistral': 478, 'n_tokens_neox': 458, 'n_words': 106}