From 53d5ee6c6e595bc80851bf933215216610c052a7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 17 Feb 2014 16:57:48 +0200 Subject: Enable write_file() test --- tests/codeigniter/helpers/file_helper_test.php | 74 ++++++++++++-------------- 1 file changed, 35 insertions(+), 39 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php index 3a6c73a5c..c31817595 100644 --- a/tests/codeigniter/helpers/file_helper_test.php +++ b/tests/codeigniter/helpers/file_helper_test.php @@ -31,9 +31,10 @@ class File_helper_Test extends CI_TestCase { { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified(time() - 86400) + ->at($this->_test_dir); $this->assertEquals('777', octal_permissions($file->getPermissions())); } @@ -47,9 +48,10 @@ class File_helper_Test extends CI_TestCase { { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified(time() - 86400) + ->at($this->_test_dir); $this->assertEquals('urwxrwxrwx', symbolic_permissions($file->getPermissions())); } @@ -60,9 +62,10 @@ class File_helper_Test extends CI_TestCase { { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified(time() - 86400) + ->at($this->_test_dir); $this->assertEquals('text/plain', get_mime_by_extension(vfsStream::url('my_file.txt'))); @@ -103,19 +106,20 @@ class File_helper_Test extends CI_TestCase { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; $last_modified = time() - 86400; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified($last_modified) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified($last_modified) + ->at($this->_test_dir); $ret_values = array( - 'name' => 'my_file.txt', - 'server_path' => 'vfs://my_file.txt', - 'size' => 57, - 'date' => $last_modified, - 'readable' => TRUE, - 'writable' => TRUE, - 'executable' => TRUE, - 'fileperms' => 33279 + 'name' => 'my_file.txt', + 'server_path' => 'vfs://my_file.txt', + 'size' => 57, + 'date' => $last_modified, + 'readable' => TRUE, + 'writable' => TRUE, + 'executable' => TRUE, + 'fileperms' => 33279 ); $info = get_file_info(vfsStream::url('my_file.txt'), $vals); @@ -128,24 +132,16 @@ class File_helper_Test extends CI_TestCase { // -------------------------------------------------------------------- - // Skipping for now, as it's not implemented in vfsStreamWrapper - // flock(): vfsStreamWrapper::stream_lock is not implemented! - - // public function test_write_file() - // { - // if ( ! defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')) - // { - // define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); - // } - // - // $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - // - // $file = vfsStream::newFile('write.txt', 0777)->withContent('') - // ->lastModified(time() - 86400) - // ->at($this->_test_dir); - // - // $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); - // - // } + public function test_write_file() + { + $content = 'Jack and Jill went up the mountain to fight a billy goat.'; + + $file = vfsStream::newFile('write.txt', 0777) + ->withContent('') + ->lastModified(time() - 86400) + ->at($this->_test_dir); + + $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b