/** * @depends testbuildScenarioByPlacements */ public function testJsonToScenario() { $placements = array(array('A:2', 'A:3'), array('B:1', 'B:2'), array('C:2', 'C:3'), array('D:1', 'D:2', 'D:3')); $scenario1 = Scenario::buildScenarioByPlacements($placements); $json = Scenario::toDataTableJSON($scenario1); $scenario2 = Scenario::getScenarioFromJSON($json); $this->assertEquals($scenario1['nvms'], $scenario2['nvms'], 'VM # !match'); $this->assertEquals($scenario1['npms'], $scenario2['npms'], 'PM # !match'); foreach ($scenario1['rvm'] as $key => $value) { $this->assertEquals($value, $scenario2['rvm'][$key], "# of placements of {$key} !match"); } foreach ($scenario1['rpm'] as $key => $value) { $this->assertEquals($value, $scenario2['rpm'][$key], "# of placements of {$key} !match"); } }
set_include_path('../'); require_once "view/formats.php"; require_once "src/model/Scenario.php"; require_once "src/model/Approximation.php"; require_once "src/model/Combinations.php"; require_once "view/Accordion.php"; require_once "view/ViewHelper.php"; ini_set('xdebug.max_nesting_level', 1000); ini_set('max_execution_time', 0); $max = isset($_GET['max']) ? $_GET['max'] : 3; $nvm = isset($_GET['nvm']) ? $_GET['nvm'] : 7; $npm = isset($_GET['npm']) ? $_GET['npm'] : 3; $apr = isset($_GET['apr']) ? $_GET['apr'] : 0.75; //$_GET['file'] = 'Scenarios_APR(0.75)_VMs(10,12,14,16,18,20)_PMs(4).json'; if (isset($_GET['state'])) { $scenario = Scenario::getScenarioFromJSON($_GET['state']); } elseif (isset($_GET['file']) && file_exists('others/' . $_GET['file'])) { $scenario = array_pop(json_decode(file('others/' . $_GET['file'])[0], true)); } else { $scenarios = Scenario::geraScenarios($apr, array($nvm), array($npm)); $scenario = array_pop($scenarios); } $json = Scenario::toDataTableJSON($scenario); //$memcache = memcache_connect('localhost', 11211); //$accordion = isset($_GET['cache']) ? false : memcache_get($memcache, 'accordion'); //$accordion = false; //if ($accordion == false) { //echo "<script>alert('Not Cached');</script>"; $accordion = new Accordion(); $sem = Approximation::calcularSemRegras($scenario); $com = Approximation::calcularComRegras($scenario);