Fixing #138
[akelos.git] / test / unit / lib / AkDbSession.php
blob582edfc921198debba14174cc86cd84887ca32cb
1 <?php
3 defined('AK_TEST_DATABASE_ON') ? null : define('AK_TEST_DATABASE_ON', true);
4 require_once(dirname(__FILE__).'/../../fixtures/config/config.php');
7 require_once(AK_LIB_DIR.DS.'AkDbSession.php');
9 /**
10 * In order to test sessions we have created a help script that we will use for checking and setting session params
15 class Test_of_AkDbSession_Class extends WebTestCase
17 var $sessionLife = NULL;
19 function test_install_db_tables()
21 require_once(dirname(__FILE__).'/../../fixtures/app/installers/framework_installer.php');
22 $installer =& new FrameworkInstaller();
23 $installer->uninstall();
24 $installer->install();
28 function setUp()
30 $this->_test_script = str_replace('/fixtures/public','',trim(AK_TESTING_URL,'/')).
31 '/mocks/test_script_AkDbSession.php';
34 function Test_open()
36 $browser =& $this->getBrowser();
37 $this->get("$this->_test_script?open_check=1");
38 $expected_session_id = $browser->getContentAsText();
39 $this->get("$this->_test_script?open_check=1");
40 //$browser->getContentAsText();
41 $this->assertWantedText($expected_session_id,'Sessions are not working correctly');
44 function Test_read_write()
46 $expected = 'test_value';
47 $this->get("$this->_test_script?key=test_key&value=$expected");
48 $this->get("$this->_test_script?key=test_key");
49 $this->assertWantedText($expected,'Session is not storing values on database correctly when calling '.
50 $this->_test_script.'?key=test_key');
53 function Test_destroy()
55 $expected = 'value not found';
56 $this->get("$this->_test_script?key=test_key&value=test_value");
57 $this->get("$this->_test_script?destroy_check=1");
58 $this->get("$this->_test_script?key=test_key");
59 $this->assertWantedText($expected,'session_destroy(); is not working as expected');
62 function Test_gc()
64 $expected = 'value not found';
65 $copy = $this;
66 $copy->get("$this->_test_script?key=test_key&value=test_value&expire=1");
67 sleep(3);
68 $this->restart();
69 $this->get("$this->_test_script?dumb_call_for_activating_gc");
71 $copy->get("$this->_test_script?key=test_key");
72 $this->assertWantedText($expected,'Session garbage collection is not working correctly');
76 ak_test('Test_of_AkDbSession_Class', true);