public function testAll() { $defaults = array('AutoCoupon', 'TotalAction'); $all = AutoLoader::ListModules('TotalAction', true); foreach ($defaults as $d) { $this->assertContains($d, $all); } foreach ($all as $class) { $obj = new $class(); $this->assertInstanceOf('TotalAction', $obj, $class . ' is not a TotalAction'); $result = $obj->apply(); $this->assertInternalType('boolean', $result, $class . ' apply() does not return boolean'); } }
public function testAll() { $defaults = array('Kicker'); $all = AutoLoader::ListModules('Kicker', True); foreach ($defaults as $d) { $this->assertContains($d, $all); } foreach ($all as $class) { $obj = new $class(); $this->assertInstanceOf('Kicker', $obj); $test1 = $obj->kickOnSignIn(); $test2 = $obj->kickOnSignOut(); $test3 = $obj->doKick('9999-99-1'); $this->assertInternalType('boolean', $test1); $this->assertInternalType('boolean', $test2); $this->assertInternalType('boolean', $test3); } }
public function testAll() { $defaults = array('FooterBox', 'EveryoneSales', 'MemSales', 'MultiTotal', 'SavedOrCouldHave', 'TransPercentDiscount'); $all = AutoLoader::ListModules('FooterBox', True); foreach ($defaults as $d) { $this->assertContains($d, $all); } foreach ($all as $class) { $obj = new $class(); $this->assertInstanceOf('FooterBox', $obj); $this->assertObjectHasAttribute('header_css', $obj); $this->assertObjectHasAttribute('display_css', $obj); $header = $obj->header_content(); $this->assertInternalType('string', $header); $display = $obj->display_content(); $this->assertInternalType('string', $display); } }
public function testAll() { $defaults = array('TenderModule', 'CheckTender', 'CreditCardTender', 'DisabledTender', 'FoodstampTender', 'GiftCardTender', 'GiftCertificateTender', 'RefundAndCashbackTender', 'StoreChargeTender', 'StoreTransferTender'); $all = AutoLoader::ListModules('TenderModule', True); foreach ($defaults as $d) { $this->assertContains($d, $all); } foreach ($all as $class) { $obj = new $class('CA', 1.0); $this->assertInstanceOf('TenderModule', $obj); $err = $obj->ErrorCheck(); $this->assertThat($err, $this->logicalOr($this->isType('boolean', $err), $this->isType('string', $err))); $pre = $obj->ErrorCheck(); $this->assertThat($pre, $this->logicalOr($this->isType('boolean', $pre), $this->isType('string', $pre))); $change = $obj->ChangeType(); $this->assertInternalType('string', $change); } }
public function testMemberSearch() { $mods = AutoLoader::ListModules('MemberLookup', true); foreach ($mods as $class) { $obj = new $class(); $this->assertInstanceOf('MemberLookup', $obj); $this->assertInternalType('boolean', $obj->handle_numbers()); $this->assertInternalType('boolean', $obj->handle_text()); $search_terms = array('JOHNSON', 1, 2354, 'RO'); foreach ($search_terms as $term) { if (is_numeric($term) && !$obj->handle_numbers()) { continue; } else { if (!is_numeric($term) && !$obj->handle_text()) { continue; } } $result = array(); if (is_numeric($term)) { $result = $obj->lookup_by_number($term); } else { $result = $obj->lookup_by_text($term); } $this->assertInternalType('array', $result); $this->assertArrayHasKey('url', $result); $this->assertArrayHasKey('results', $result); $this->assertThat($result['url'], $this->logicalOr($this->isType('boolean', $result['url']), $this->isType('string', $result['url']))); $this->assertInternalType('array', $result['results']); foreach ($result['results'] as $key => $value) { $this->assertInternalType('string', $key); $this->assertInternalType('string', $value); $this->assertRegExp('/\\d+::\\d+/', $key); } } } }
function preprocess() { $entered = ""; if (isset($_REQUEST["search"])) { $entered = strtoupper(trim($_REQUEST["search"])); } elseif (CoreLocal::get("pvsearch") != "") { $entered = strtoupper(trim(CoreLocal::get("pvsearch"))); } else { $this->temp_num_rows = 0; return True; } // canceled if (empty($entered)) { $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } // picked an item from the list if (is_numeric($entered) && strlen($entered) == 13) { CoreLocal::set("msgrepeat", 1); CoreLocal::set("strRemembered", $entered); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } if (is_numeric($entered)) { // expand UPC-E to UPC-A if (substr($entered, 0, 1) == 0 && strlen($entered) == 7) { $p6 = substr($entered, -1); if ($p6 == 0) { $entered = substr($entered, 0, 3) . "00000" . substr($entered, 3, 3); } elseif ($p6 == 1) { $entered = substr($entered, 0, 3) . "10000" . substr($entered, 4, 3); } elseif ($p6 == 2) { $entered = substr($entered, 0, 3) . "20000" . substr($entered, 4, 3); } elseif ($p6 == 3) { $entered = substr($entered, 0, 4) . "00000" . substr($entered, 4, 2); } elseif ($p6 == 4) { $entered = substr($entered, 0, 5) . "00000" . substr($entered, 6, 1); } else { $entered = substr($entered, 0, 6) . "0000" . $p6; } } // UPCs should be length 13 w/ at least one leading zero if (strlen($entered) == 13 && substr($entered, 0, 1) != 0) { $entered = "0" . substr($entered, 0, 12); } else { $entered = substr("0000000000000" . $entered, -13); } // zero out the price field of scale UPCs if (substr($entered, 0, 3) == "002") { $entered = substr($entered, 0, 8) . "00000"; } } /* Get all enabled plugins and standard modules of the base. */ $modules = AutoLoader::ListModules('ProductSearch'); $results = array(); $this->boxSize = 1; /* Search first with the plugins * and then with standard modules. * Keep only the first instance of each upc. * Increase the depth of the list from module parameters. */ foreach ($modules as $mod_name) { $mod = new $mod_name(); $mod_results = $mod->search($entered); foreach ($mod_results as $upc => $record) { if (!isset($results[$upc])) { $results[$upc] = $record; } } if ($mod->result_size > $this->boxSize) { $this->boxSize = $mod->result_size; } if (isset($mod->this_mod_only) && $mod->this_mod_only) { break; } } $this->temp_result = $results; $this->temp_num_rows = count($results); return True; }
public function testSpecialDepts() { $defaults = array('ArWarnDept', 'AutoReprintDept', 'EquityEndorseDept', 'EquityWarnDept'); $all = AutoLoader::ListModules('SpecialDept', False); foreach ($defaults as $d) { $this->assertContains($d, $all); } $map = array(); foreach ($all as $class) { $obj = new $class(); $this->assertInstanceOf('SpecialDept', $obj); $map = $obj->register(1, $map); $this->assertInternalType('array', $map); $this->assertArrayHasKey(1, $map); $this->assertInternalType('array', $map[1]); $this->assertContains($class, $map[1]); } CoreLocal::set('msgrepeat', 0); // first call should set warn vars $arwarn = new ArWarnDept(); $json = $arwarn->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertNotEmpty($json['main_frame']); CoreLocal::set('msgrepeat', 1); // second call should clear vars and proceed $json = $arwarn->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertEmpty($json['main_frame']); CoreLocal::set('autoReprint', 0); $auto = new AutoReprintDept(); $json = $auto->handle(1, 1.0, array()); $this->assertInternalType('array', $json); $this->assertEquals(1, CoreLocal::get('autoReprint')); CoreLocal::set('msgrepeat', 0); CoreLocal::set('memberID', 0); // error because member is required $eEndorse = new EquityEndorseDept(); $json = $eEndorse->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertNotEmpty($json['main_frame']); // show endorse warning screen CoreLocal::set('memberID', 123); $json = $eEndorse->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertNotEmpty($json['main_frame']); // clear warning and proceed CoreLocal::set('memberID', 123); CoreLocal::set('msgrepeat', 1); $json = $eEndorse->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertEmpty($json['main_frame']); CoreLocal::set('memberID', 0); CoreLocal::set('msgrepeat', 0); // error because member is required $eWarn = new EquityWarnDept(); $json = $eWarn->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertNotEmpty($json['main_frame']); CoreLocal::set('memberID', 123); // show warning screen CoreLocal::set('memberID', 123); $json = $eWarn->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertNotEmpty($json['main_frame']); // clear warning and proceed CoreLocal::set('memberID', 123); CoreLocal::set('msgrepeat', 1); $json = $eWarn->handle(1, 1.0, array('main_frame' => '')); $this->assertInternalType('array', $json); $this->assertArrayHasKey('main_frame', $json); $this->assertInternalType('string', $json['main_frame']); $this->assertEmpty($json['main_frame']); }
/** Gather postparse modules @return array of PostParser class names Scan the parse directory for module files. Return an array of available modules. */ public static function getPostParseChain() { $set = AutoLoader::ListModules('PostParser'); $set = array_reverse($set); return $set; }
/** Gather parse modules @return array of Parser class names Scan the parse directory for module files. Return an array of available modules. */ public static function get_parse_chain($type = 'Parser') { $set = AutoLoader::ListModules($type); $set = array_reverse($set); $parse_chain = array(); $first = ""; foreach ($set as $classname) { $instance = new $classname(); if ($instance->isLast()) { array_push($parse_chain, $classname); } elseif ($instance->isFirst()) { $first = $classname; } else { array_unshift($parse_chain, $classname); } } if ($first != '') { array_unshift($parse_chain, $first); } return $parse_chain; }
function preprocess() { $entered = ""; if (isset($_REQUEST['idSearch']) && strlen($_REQUEST['idSearch']) > 0) { $entered = $_REQUEST['idSearch']; } elseif (isset($_REQUEST['search'])) { $entered = strtoupper(trim($_REQUEST["search"])); $entered = str_replace("'", '', $entered); } else { return true; } if (substr($entered, -2) == "ID") { $entered = substr($entered, 0, strlen($entered) - 2); } // No input available, stop if (!$entered || strlen($entered) < 1 || $entered == "CL") { $this->change_page($this->page_url . "gui-modules/pos2.php"); return false; } $personNum = false; $memberID = false; $this->submitted = true; if (strstr($entered, "::") !== false) { // User selected a :: delimited item from the list interface list($memberID, $personNum) = explode("::", $entered, 2); } else { // search for the member $lookups = AutoLoader::ListModules('MemberLookup', True); foreach ($lookups as $class) { if (!class_exists($class)) { continue; } $obj = new $class(); if (is_numeric($entered) && !$obj->handle_numbers()) { continue; } else { if (!is_numeric($entered) && !$obj->handle_text()) { continue; } else { if (is_numeric($entered)) { $chk = $obj->lookup_by_number($entered); if ($chk['url'] !== false) { $this->change_page($chk['url']); return false; } foreach ($chk['results'] as $key => $val) { $this->results[$key] = $val; } } elseif (!is_numeric($entered)) { $chk = $obj->lookup_by_text($entered); if ($chk['url'] !== false) { $this->change_page($chk['url']); return false; } foreach ($chk['results'] as $key => $val) { $this->results[$key] = $val; } } } } } if (count($this->results) == 1 && (CoreLocal::get('verifyName') == 0 || $entered == CoreLocal::get('defaultNonMem'))) { $members = array_keys($this->results); $match = $members[0]; list($memberID, $personNum) = explode('::', $match, 2); } } // we have exactly one row and // don't need to confirm any further if ($memberID !== false && $personNum !== false) { $callback = $this->getCallbackAction($memberID); if ($callback != false) { $callback->apply(); } if ($memberID == CoreLocal::get('defaultNonMem')) { $personNum = 1; } PrehLib::setMember($memberID, $personNum); if (CoreLocal::get('store') == "WEFC_Toronto") { $error_msg = $this->wefcCardCheck($memberID); if ($error_msg !== true) { $this->temp_message = $error_msg; return true; } } // don't bother with unpaid balance check if there is no balance if ($memberID != CoreLocal::get("defaultNonMem") && CoreLocal::get('balance') > 0) { $unpaid = PrehLib::check_unpaid_ar($memberID); if ($unpaid) { $this->change_page($this->page_url . "gui-modules/UnpaidAR.php"); } else { $this->change_page($this->page_url . "gui-modules/pos2.php"); } } else { $this->change_page($this->page_url . "gui-modules/pos2.php"); } return false; } return true; }
<?php include 'test_env.php'; $mods = AutoLoader::ListModules('TenderReport'); ?> <form action="testTenderReport.php"> <select name='t_mod'> <?php foreach ($mods as $m) { ?> <option><?php echo $m; ?> </option> <?php } ?> </select> <br /> Send to printer <select name="print"> <option value="0">No</option> <option value="1">Yes</option> </select> <br /> Emp# <input type="text" size="3" name="emp_no" /> <input type="submit" value="Get Output" /> </form> <hr /> <?php