Implement TestSwarmContext (issue #127) #131

Merged
merged 5 commits into from Mar 22, 2012
Commits on Mar 21, 2012
  1. Database class update

    Krinkle committed Mar 21, 2012
    - Call close() at the beginning of open()
      close() checks if it is open and closes if it is and is an
      innocent no-op otherwise.
    
    - Call open() from Database::__construct
    
    - Add function documentation
  2. [TestSwarm OOP] Implement TestSwarmContext

    Krinkle committed Mar 21, 2012
    - This reduces the number of global variables to basically 2 (config and context).
      There are still some code paths relying on very generic globals from one file to
      another (such as "$username", "$user_id" etc. from init-usersession.php).
      and the existing uses of mysql_queryf and $swarmBrowser/$swarmRequest.
    
    - Context makes dependency resolving a lot easier, no longer depending on order of
      php includes. Instead things are created on-demand (context->getBD() will create
      the Database object when needed).
    
    - Might also speed up some JSON responses since objects that aren't needed, won't be
      created.
    
    - Adapting existing classes to get their info from the context instead.
      I did this without keeping backwards compatibility. These classes were developed
      only a few days ago, so changed them as if they were created like this from the
      beginning.
     * BrowserInfo:
       - Removed caching from BrowserInfo, became to complicated and not really needed.
       so far it is only used once for the current user agent, and in the event we do
       create it for other user agents, the gain in caching them in case we come across
       the exact same user agent twice within the same request and slim. If that does
       become an issue we can optimize for that when we actually do that.
       - Removed redundant findSwarmUAFromBI method
Commits on Mar 22, 2012
  1. Update uses of deprecated globals with TestSwarmContext

    Krinkle committed Mar 22, 2012
    - All instances of $swarmBrowser replaced, global removed.
    - All instances of $swarmConfig replaced, global removed.
    - All instances of $swarmDB replaced, global removed.
    - All instances of $swarmRequest replaced, global removed.