Kubo2 / diggyshelper

dh Forum — software, na ktorom beží diskusné fórum Diggy's Helper.
https://diggyshelper.net
3 stars 0 forks source link

Introducing acceptancy tests #22

Closed Kubo2 closed 6 years ago

Kubo2 commented 6 years ago

This PR introduces the possibility of directly testing if a certain page request produces the desired results and output. We can check for the results directly in the database or in the filesystem, but every test case must be atomic / self-contained and therefore cleaning up any mess possibly produced (except for the database, which is setup and deleted automatically). We can simulate HTTP requests but we cannot preset headers unless we are using server-tests.php, which is not a part of this approach. Instead, we simulate headers by adding them ot the $_SERVER superglobal array.

We can use sessions but we either have to clean them up afterwards or if using the default ones, only use them for reading. session_encode() is encouraged to be used instead. Moreover, most of dhForum pages use database in some way, so it is encourage to begin the test with require DIR . '/bootstrap.php'; and finish with require DIR . '/cleanup.php'; in the --CLEAN-- section; but do not include the database unnecessarily, because its setup radically slows down the test execution, by upto 5-10 full seconds. Also, use of native assert() in tests is encourgaed, while it has to be specified explicitly in assert.active=1 ini option.

Wiki

Kubo2 commented 6 years ago

Superseded by #23.