<?php /** Initialize environment & session so testing behaves correctly */ if (!class_exists('AutoLoader')) { include dirname(__FILE__) . '/../lib/AutoLoader.php'; } CoreLocal::set("parse_chain", ''); CoreLocal::set("preparse_chain", ''); CoreLocal::set("postparse_chain", ''); AutoLoader::loadMap(); CoreState::initiate_session();
public function testCoreState() { // normal session init attempts to recover state // transaction info - e.g., after a browser crash // or reboot. Clear the table so that doesn't // happen $db = Database::tDataConnect(); $db->query('TRUNCATE TABLE localtemptrans'); /** This will trigger any syntax or run-time errors Testing all the invidual values of session might be worthwhile is anyone wants to write all those tests out. They're mostly static values so the test would only catch changes to the defaults. */ CoreState::initiate_session(); $str = CoreState::getCustomerPref('asdf'); $this->assertInternalType('string', $str); $this->assertEquals('', $str); // non-numeric age converts to zero CoreState::cashierLogin(false, 'z'); $this->assertEquals(0, CoreLocal::get('cashierAge')); }