Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added FileWriter test

  • Loading branch information...
commit b9a6d8e19da61eae4dada40dac9e0e90e89e729d 1 parent 8b01163
@weierophinney weierophinney authored
Showing with 50 additions and 0 deletions.
  1. +50 −0 test/PhlyBlog/Compiler/FileWriterTest.php
View
50 test/PhlyBlog/Compiler/FileWriterTest.php
@@ -0,0 +1,50 @@
+<?php
+namespace PhlyBlog\Compiler;
+
+use PHPUnit_Framework_TestCase as TestCase;
+
+class FileWriterTest extends TestCase
+{
+ public function setUp()
+ {
+ $this->writer = new FileWriter();
+ $this->basePath = sys_get_temp_dir() . '/file_writer';
+ $this->cleanup();
+ }
+
+ public function tearDown()
+ {
+ $this->cleanup();
+ }
+
+ public function cleanup()
+ {
+ if (!is_dir($this->basePath)) {
+ return;
+ }
+
+ $this->rrmdir($this->basePath);
+ }
+
+ public function rrmdir($dir)
+ {
+ foreach (glob($dir . '/*') as $file) {
+ if (is_dir($file)) {
+ $this->rrmdir($file);
+ } else {
+ unlink($file);
+ }
+ }
+ rmdir($dir);
+ }
+
+ public function testCreatesFileAndDirectorySpecified()
+ {
+ $filename = $this->basePath . '/foo.bar';
+ $data = 'data';
+ $this->writer->write($filename, $data);
+ $this->assertTrue(file_exists($filename));
+ $contents = file_get_contents($filename);
+ $this->assertEquals($data, $contents);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.