/** * Tests File::mime() * * @test * @dataProvider provider_split_join * @param boolean $input Input for File::split * @param boolean $peices Input for File::split * @param boolean $expected Output for File::splut */ public function test_split_join($input, $peices, $expected) { $this->assertSame($expected, File::split($input, $peices)); $this->assertSame($expected, File::join($input)); foreach (glob(Kohana::find_file('tests', 'test_data/github', 'png') . '.*') as $file) unlink($file); }
/** * 内部调用合并文件 * */ public function action_join() { # 目录 $dir = $this->arguments[0]; if (!isset(File::$dir[$dir])) { # 目录不允许操作 $this->show_error('目录不允许操作'); } if (!$this->arguments[1]) { $this->show_error('缺少参数'); } # 文件 $filename = File::$dir[$dir] . $this->arguments[1]; if (File::join($filename)) { $this->show_success(); } else { # 记录错误日志 Core::log('system.error.file.join', array('file' => $filename), LOG_ERR); $this->show_error('执行失败'); } }
/** * 内部调用合并文件 * */ public function action_join() { # 目录 $dir = $this->arguments[0]; if (!isset(File::$dir[$dir])) { # 目录不允许操作 $this->show_error('目录不允许操作'); } if (!$this->arguments[1]) { $this->show_error('缺少参数'); } # 文件 $filename = File::$dir[$dir] . $this->arguments[1]; if (File::join($filename)) { $this->show_success(); } else { # 记录错误日志 Core::log('join file(' . $filename . ') error.', 'error'); $this->show_error('执行失败'); } }
public function test_split_join() { $hash = sha1_file($this->_file); $this->assert_equal(File::split($this->_file, 1), 4)->assert_equal(File::join($this->_file), 4)->assert_equal(sha1_file($this->_file), $hash); }
/** * 内部调用合并文件 * */ public function action_join() { # 目录 $dir = $this->arguments[0]; if (!isset(\File::$dir[$dir])) { # 目录不允许操作 static::show_error('目录不允许操作'); } if (!$this->arguments[1]) { static::show_error('缺少参数'); } # 文件 $filename = \File::$dir[$dir] . $this->arguments[1]; if (\File::join($filename)) { static::show_message('success', null, 1); } else { # 记录错误日志 \Core::log('join file(' . $filename . ') error.', 'error'); static::show_error('执行失败'); } }