protected function _getLifeCycleHistory(Application\Proto\Subscription\LifeCycleHistory $req) { $resp = new Application\Proto\Subscription\LifeCycleHistory\Response(); $result = new PB\Result(); $result->setCode(0); $result->setReason('Ok'); $resp->setResult($result); $start = strtotime($req->getDateInterval()->getStartDate()) ?: mktime(0, 0, 0, 1, 1, 2011); $end = strtotime($req->getDateInterval()->getEndDate()) ?: time(); $year = date('Y', $start); $month = date('n', $start); $day = date('d', $start); $hour = rand(0, 23); // Obtain the list of values from the enum $refl = new ReflectionClass('\\Application\\Proto\\LifeCycleState'); $states = $refl->getConstants(); $limit = rand(10, 30); while ($limit--) { $row = new \Application\Proto\Subscription\LifeCycleData(); $hour += rand(1, 72); $time = mktime($hour, rand(0, 59), rand(0, 59), $month, $day, $year); if ($time > $end) { break; } $row->setCurrentStateDate(gmdate('Y-m-d\\TH:i:s+0000', $time)); if (rand(0, 1) === 0) { $row->setChangeType(\Application\Proto\LifeCycleChangeType::AUTOMATIC); } else { $row->setChangeType(\Application\Proto\LifeCycleChangeType::MANUAL); } $row->setState($states[array_rand($states)]); $row->setChangeUser('MOCK'); $row->setChangeReason('Lorem ipsum dolor sit...'); $lCRef = new \Application\Proto\RefData(); $lCRef->setId('ddfwssgfsd234r'); $lCRef->setName('MockName'); $row->setLifeCycle($lCRef); $resp->addData($row); } return $resp; }
protected function _DiagnosisHistory(\Application\Proto\SupSpotlight\Sim\SimHistoryRequest $req) { $resp = new \Application\Proto\SupSpotlight\Diagnosis\DiagnosisHistoryListResponse(); $result = new PB\Result(); $result->setCode(0); $result->setReason('Ok'); $resp->setResult($result); $id = new \Application\Proto\SupProvision\Sim\SimId(); $id->setImsi('MOCK'); $resp->setSimId($id); // Compute start and end times $start = strtotime($req->getDateInterval()->getStartDate()) ?: mktime(0, 0, 0, 1, 1, 2011); $end = strtotime($req->getDateInterval()->getEndDate()) ?: time(); // Extract start date parts to build new times over them $year = date('Y', $start); $month = date('n', $start); $day = date('d', $start); $hour = rand(0, 23); $statuses = array(\Application\Proto\SupSpotlight\Diagnosis\DiagnosisDetail\DiagResponseType::GSM_UP, \Application\Proto\SupSpotlight\Diagnosis\DiagnosisDetail\DiagResponseType::GSM_DOWN, \Application\Proto\SupSpotlight\Diagnosis\DiagnosisDetail\DiagResponseType::IP_UP, \Application\Proto\SupSpotlight\Diagnosis\DiagnosisDetail\DiagResponseType::IP_DOWN); $limit = rand(10, 30); for ($i = 0; $i < $limit; $i++) { // Build a new timestamp using random values $time = mktime($hour, rand(0, 59), rand(0, 59), $month, $day, $year); if ($time > $end) { continue; } $hour += rand(1, 36); $row = new Application\Proto\SupSpotlight\Diagnosis\DiagnosisDetail(); $row->setDescription($statuses[array_rand($statuses)]); $row->setEndDate(gmdate('Y-m-d\\TH:i:s\\Z', $time)); $resp->addDiagnosisDetail($row); } return $resp; }