Ajax query, PHP Unit and testing

techie | June 15 - 2010

There are certain important steps to be followed while you are using Ajax query
When you are writing ajax queries,don’t call the server every time a single character is added, but only when  the user stops writing or presses space, etc.
When  you are trying to send a lot of queries , you feel that that it will give a faster response. But browsers have limited a number of connections for Ajax.
A browser like IE will  wait with sending requests if there is more than one Ajax query being made at the moment.
An important step is how to make it fast on the server
It is a common mistake to try to fetch everything in one MySQL query.
When the query involves some joins on large tables you probably need to redesign. Otherwise you will have to write separate queries and build it up with PHP. Joining large tables is always slow.And you will not really need it.
PHP Unit is one of the more popular testing suites for PHP, it has full support for Fixtures, Mock Objects, Code Coverage and a lot of other features.The module only requires a few changes to the bootstrap in order to integrate Kohana with PHP Unit, and afterwards you can run tests from the client, IDE or  custom web runner.  All available tests are loaded from Kohana’s cascading file system and can be filtered using PHP Unit’s –group switch.
When you do tests along with the actual module – or an ORM we are building, the tests must include a load of dummy models and data. You should not force anyone using our module to also have loads of extra testing models in any application they write. Ndot.in have got the expertise to tests on modules ina unique way.  At ndot.in, we used to package all these tests as a separate module so that people can download and run if they want but  this will not interfere people’s production applications. We could keep the tests in a separate branch but it is much easier to manage which tests are for which module branch.Then we can write tests in a parallel branch of the test report. At the same time, we will be working in a branch on the main module.