采用SimpleTest进行PHP单元测试

发表于:2009-12-24来源:作者:点击数: 标签:
采用SimpleTest进行 PHP 单元测试 单元测试工具 SimpleTest : http://simpletest.org/index.html 文件操作类 file.class.php class File { var $filename; function File($file) { if (emptyempty($file)) { die('Filename should not be empty'); } $this-f

  采用SimpleTest进行PHP单元测试  单元测试工具 

    SimpleTest : http://simpletest.org/index.html

  文件操作类 file.class.php

  

  class File

  {

  var $filename;

  function File($file)

  {

  if (emptyempty($file)) {

  die('Filename should not be empty');

  }

  $this->filename = $file;

  if (!$this->exists() && !$this->create()) die('Unable to find / create the file');

  }

  function exists()

  {

  return file_exists($this->filename);

  }

  function create()

  {

  if ($this->exists()) return true;

  return $this->putContents(null);

  }

  function getContents()

  {

  return @file_get_contents($this->filename);

原文转自:http://www.ltesting.net