Esempio n. 1
0
 public function tearDown()
 {
     if ($this->is_driver_active()) {
         $this->driver()->clear();
     }
     if ($this->is_environment_active()) {
         $this->environment()->restore();
     }
     if (in_array($this->driver_type(), array('kohana', 'simple'))) {
         Functest_Tests::rollback_transaction();
     } else {
         Functest_Tests::load_fixtures();
     }
     parent::tearDown();
 }
Esempio n. 2
0
 public function test_load_fixtures()
 {
     global $_functest_test_counter;
     $_functest_test_counter = 0;
     Kohana::cache(Functest_Tests::FIXTURE_CACHE, null, 0);
     Database::instance(Kohana::TESTING)->query(NULL, 'DELETE FROM table1');
     Functest_Tests::load_fixtures();
     $result = Database::instance(Kohana::TESTING)->query(Database::SELECT, 'SELECT * FROM table1');
     $expected = array(array('id' => 1, 'name' => 'test record'));
     $this->assertEquals(1, $_functest_test_counter);
     $this->assertEquals($expected, $result->as_array());
     Database::instance(Kohana::TESTING)->query(NULL, 'DELETE FROM table1');
     Functest_Tests::load_fixtures();
     $result = Database::instance(Kohana::TESTING)->query(Database::SELECT, 'SELECT * FROM table1');
     $this->assertEquals($expected, $result->as_array());
     $this->assertEquals(1, $_functest_test_counter, 'Should load the sql from the cache. so the counter is not incremented');
 }
Esempio n. 3
0
    $system = DOCROOT . $system;
}
// Define the absolute paths for configured directories
define('APPPATH', realpath($application) . DIRECTORY_SEPARATOR);
define('MODPATH', realpath($modules) . DIRECTORY_SEPARATOR);
define('SYSPATH', realpath($system) . DIRECTORY_SEPARATOR);
// Clean up the configuration vars
unset($application, $modules, $system);
/**
 * Define the start time of the application, used for profiling.
 */
if (!defined('KOHANA_START_TIME')) {
    define('KOHANA_START_TIME', microtime(TRUE));
}
/**
 * Define the memory usage at the start of the application, used for profiling.
 */
if (!defined('KOHANA_START_MEMORY')) {
    define('KOHANA_START_MEMORY', memory_get_usage());
}
$_SERVER["PHP_APP_ENV"] = 'testing';
// Bootstrap the application
require APPPATH . 'bootstrap' . EXT;
Kohana::$environment = Kohana::TESTING;
// Disable output buffering
ob_end_flush();
// Enable the unittest module
Kohana::modules(Kohana::modules() + array('functest' => MODPATH . 'functest'));
Functest_Tests::enable_environment();
Functest_Tests::load_fixtures();