MySQL2MySQLi/UnitTests
SAIF 546a74246d Add The Scripts Files
Add The Scripts Files
2013-09-19 21:54:48 +01:00
..
.svn Add The Scripts Files 2013-09-19 21:54:48 +01:00
Converter Add The Scripts Files 2013-09-19 21:54:48 +01:00
Function Add The Scripts Files 2013-09-19 21:54:48 +01:00
AllTests.php Add The Scripts Files 2013-09-19 21:54:48 +01:00
README Add The Scripts Files 2013-09-19 21:54:48 +01:00

README

+++ WARNING +++

The PHPUnit version that was used is NOT the PEAR version of PHPUnit
Download PHPUnit 2.3+ from its new home on http://www.phpunit.de!

+++ Introduction +++

The converter tool uses PHPUnit for its tests. Two types of tests are
implemented:

 a) classiscal unit tests
 b) "real-life" examples
 
 The classical unit tests are contained in the folder UnitTests/Function/. 
 The tests in that folder mainly check if the mysql_*->mysqli_* transformation
 callback function functions behave as expected. E.g. they check if 
 invalid numbers of parameters are recognized and a warning gets thrown. 
 The don't really test the scanner/parser not do they check if the code
 generated by the converter can be 1) run and 2) behaves in the same
 way as the original code.
 
 This is tested using "real-life" examples contained in the folder
 UnitTests/Converter/. Have a look at the files in the folder 
 UnitTests/Converter/TestCode. The tests look very similar 
 to the *.phpt files which PHP uses to test extensions.
 
 PHPUnit acts only as a wrapper to read the files in the folder 
 UnitTests/Converter/TestCode. E.g. UnitTests/Converter/ConnParamTest.php 
 does nothing but load and execute (eval) the test files conn_param001.php 
 to conn_param007.php and groups them together in one PHPUnit test case. 
 
 If you want to add new tests for a certain mysql_* function, check out 
 which mysql_*->mysqli_ transformation callback function is responsible for
 the conversion. There's a list of all function mappings in the file
 Converter.php. Once you know which transformation function gets used, 
 open the  correspondending test class in UnitTests/Converter/, e.g.
 UnitTests/Converter/DropDBTest for mysql_drop_db. Add a new file to 
 the list of files in the $files array and implement your new test.
  
+++ Running the tests +++

The preferred way to run the tests is to call UnitTests/AllTests.php.
It's assumed that you have the PHPUnit installation path in your include
directory. It's also assumed that you are one level above the installation
directory of the converter tool when you call:

php MyConverterTool/UnitTests/AllTests.php

Before you run the "real-life" tests, you must set up a test database and 
adapt the configuration file UnitTests/Converter/TestCode/config.php. 
The file contains the necessary SQL commands for setting up the database
and the user accounts. Make sure that you remove the test users and 
test database from your system after you've run the tests. Default
users and default passwords are not very secure...