我正在尝试使用 PHP 进行 TDD,并且正在编写一个基于 Web 的应用程序来访问 MySQL 数据库中的文章;这是测试功能:
class TestArticleTestCase extends UnitTestCase {
...
public function testArticleGenerateInsertSqlString() {
$testArticle = new Article("12345", "2009-09-13 20:20:20", "Test heading", "Test text");
...
}
这是文章类:
class Article {
private $_articleId;
private $_pubDate;
private $_heading;
private $_text;
public function __construct($articleId, $pubDateUnchecked, $headingUnescaped, $textUnescaped) {
echo "pubDateUnchecked == $pubDateUnchecked </BR>";
...
}
我在构造函数中包含了回显,因为数据库中的日期不是我初始化文章时使用的日期,果然,跟踪问题,这是构造函数中回显的输出:
pubDateUnchecked == 2005-06-01 12:00:00
也许我只是盯着这段代码太久了,但是在我开始将它作为日期操作之前,字符串如何从我实例化它的位置更改为直接实例化它的位置(我检查它是否是允许的日期格式与 strtotime () 和 date() 稍后......)。
有人对在哪里看有任何想法吗?
谢谢你,斯蒂芬。