Hi!
I'm trying my hand at TDD with PHP and am writing a webbased app to access articles in a MySQL database; this is the test function:
class TestArticleTestCase extends UnitTestCase {
...
public function testArticleGenerateInsertSqlString() {
$testArticle = new Article("12345", "2009-09-13 20:20:20", "Test heading", "Test text");
...
}
and this is the Article class:
class Article {
private $_articleId;
private $_pubDate;
private $_heading;
private $_text;
public function __construct($articleId, $pubDateUnchecked, $headingUnescaped, $textUnescaped) {
echo "pubDateUnchecked == $pubDateUnchecked </BR>";
...
}
I included the echo in the constructor because the dates in the database was not what I initialised the Article with, and sure enough, tracing the problem, this is the output of that echo in the constructor:
pubDateUnchecked == 2005-06-01 12:00:00
Maybe I've just stared at this code too long, but how can the string change from where I instantiate it to directly where it gets instantiated, BEFORE I start manipulating it as a date (I check that it's in am allowable date format with strtotime() and date() later on..).
Does anyone have any ideas on where to look?
Thank you, Stephan.