/** * Tests StatesOptions::getState() */ public function testGetState() { $state = StatesOptions::getState('CA'); $this->assertEquals('California', $state, 'Failed to load state California'); // Test failure $state = StatesOptions::getState('XX'); $this->assertFalse($state, 'State should be empty.'); }
/** * Clears the states from the cache. * @return void */ public static function clearCache() { self::$states = null; }
<?php require_once '../../lib/StatesOptions.php'; $states_options = StatesOptions::getOptions(); $array = StatesOptions::getArray(); $pairs = StatesOptions::getPairs(); ?> <!DOCTYPE html> <html> <head> <title>States Parsing Class</title> <style type="text/css"> code{ display:block; padding:8px; margin: 5px 0; white-space:pre; border: solid 1px #CCC; background-color:#EEE; } </style> </head> <body> <h1>States Parsing Class</h1> <div> <h2>Options String</h2> <code><?php $states_options = StatesOptions::getOptions(); ?> <select name="states"> <?php echo $states_options; ?> </select></code> <label for="states">State:</label>