~coughphp/coughphp/2.0

« back to all changes in this revision

Viewing changes to tests/cough_generator/TestCoughGenerator.class.php

  • Committer: Anthony Bush
  • Date: 2008-08-23 03:35:08 UTC
  • mfrom: (262.1.18 coughphp-release-1.3)
  • Revision ID: anthony@anthonybush.com-20080823033508-uy4yn5pmio6wcetv
Accept release-1.3 branch changes into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 *                ... folders and files to be compared with generated output.
31
31
 *            output/ (all generator configs will be setup to write here, temporarily creating it if necessary)
32
32
 * 
33
 
 * @package default
 
33
 * @package tests
34
34
 * @author Anthony Bush
35
35
 **/
36
36
class TestCoughGenerator extends UnitTestCase
37
37
{
 
38
        protected $db = null;
 
39
        
38
40
        public function __construct()
39
41
        {
40
42
                // include cough generator, core cough, and the as_database DAL.
41
 
                require_once(dirname(dirname(__FILE__)) . '/load.inc.php');
42
 
                require_once(dirname(dirname(dirname(__FILE__))) . '/cough/load.inc.php');
43
 
                require_once(dirname(dirname(dirname(__FILE__))) . '/as_database/load.inc.php');
 
43
                $coughRoot = dirname(dirname(dirname(__FILE__)));
 
44
                require_once($coughRoot . '/cough_generator/load.inc.php');
 
45
                require_once($coughRoot . '/cough/load.inc.php');
 
46
                require_once($coughRoot . '/as_database/load.inc.php');
44
47
                
45
48
                // Setup DB config
46
 
                CoughDatabaseFactory::addConfig(array(
47
 
                        'driver' => 'mysql',
48
 
                        'host' => 'localhost',
49
 
                        'db_name' => 'test_cough_object',
50
 
                        'user' => 'cough_test',
51
 
                        'pass' => 'cough_test',
52
 
                        'port' => '3306',
53
 
                        'aliases' => array('test_cough_object')
54
 
                ));
 
49
                require(dirname(dirname(__FILE__)) . '/database_config.inc.php');
 
50
                $coughDbConfig = $dsn;
 
51
                $coughDbConfig['aliases'] = array($dsn['db_name']);
 
52
                CoughDatabaseFactory::addConfig($coughDbConfig);
 
53
                
 
54
                // Cache the db object for rest of tests
 
55
                $this->db = CoughDatabaseFactory::getDatabase($dsn['db_name']);
55
56
        }
56
57
        
57
58
        public function executeSqlFile($sqlFile)
62
63
                // the last element is a blank string, so get rid of it
63
64
                array_pop($sqlCommands);
64
65
 
65
 
                $db = CoughDatabaseFactory::getDatabase('test_cough_object');
66
66
                foreach ($sqlCommands as $sql) {
67
 
                        $db->query($sql);
 
67
                        $this->db->query($sql);
68
68
                }
69
69
        }
70
70