On 8/11/09 1:03 PM, Chad wrote:
To be perfectly honest, I'm of the opinion that tests/ and t/ should be scrapped and it should all be done over, properly.
What we need is an easy and straightforward way to write test cases, so people are encouraged to write them. Right now, nobody understands wtf is going on in tests/ and t/, so they get ignored and the /vast/ majority of the code isn't tested.
What we need is something similar to parser tests, where it's absurdly easy to pop new tests in with little to no coding required at all. Also, extensions having the ability to inject their own tests into the framework is a must IMHO.
If we don't want to use straight PHPUnit or similar -- where you're writing PHP source code with a tiny bit of structure -- we could either adapt another surrounding structure or make up our own (scarrry!)
Note that PHP's own test suite uses a file-per-test-case structure which is similar to the individual chunks of our parser test definition file, with delimited sections listing the name, some options, the source to run, and the expected output...
php-5.2.5/tests/strings/bug22592.phpt:
--TEST-- Bug #22592 (Cascading assignments to strings with curly braces broken) --FILE-- <?php $wrong = $correct = 'abcdef';
$t = $x[] = 'x';
var_dump($correct); var_dump($wrong);
$correct[1] = '*'; $correct[3] = '*'; $correct[5] = '*';
// This produces the $wrong[1] = $wrong[3] = $wrong[5] = '*';
var_dump($correct); var_dump($wrong);
?> --EXPECT-- string(6) "abcdef" string(6) "abcdef" string(6) "a*c*e*" string(6) "a*c*e*"
It might be pretty handy actually to use a similar structure for all our tests, whether run through the parser tester or as PHP code; we could provide a standard setup/teardown environment (eg an implied commandLine.inc include and switch over to standard options and test database) so the code segment doesn't need to be a standalone PHP file.
Note that some of the parser test cases rely on setup such as saving some pages into the test database; tests such as a search test could also require custom database setup or the use of mock objects, and we should consider this in planning out potential new test system requirements.
-- brion