Exemplo n.º 1
0
 public function testGetYear()
 {
     /**
      * @var $object MTSXML
      */
     $object = simplexml_load_file(Yii::getAlias('@data') . '/mts_report.xml', MTSXML::className());
     $this->tester->assertEquals($object->getYear(), '2014');
 }
Exemplo n.º 2
0
 public function testGenerate()
 {
     $xml = simplexml_load_file(Yii::getAlias('@data') . '/mts_report.xml', MTSXML::className());
     $report = Report::generate($xml);
     $this->tester->assertTrue($report instanceof Report);
     //codecept_debug(ReportSearch::getOperatorItems());
     //$report = new Report();
     //codecept_debug( Yii::$app->formatter->asDate(mktime(null,null,null,1,1,2015),'LLLL yyyy'));
     //codecept_debug();
     //Report::find();
 }
Exemplo n.º 3
0
 /**
  * Creates a new Report model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $file = UploadedFile::getInstanceByName('operatorReport');
     if ($file->hasError) {
         echo Json::encode(['error' => "Ошибка загрузки файла {$file->name}"]);
         return;
     }
     /**
      * @var $mtsXML MTSXML
      */
     $mtsXML = simplexml_load_file($file->tempName, MTSXML::className());
     if (!$mtsXML || !$mtsXML->validate()) {
         echo Json::encode(['error' => 'Предоставленный файл имеет неверный формат']);
         return;
     }
     $report = Report::generate($mtsXML);
     if ($report instanceof Report) {
         \Yii::$app->session->setFlash('reportCreated', "Отчет «{$report->operator->name}» за " . \Yii::$app->formatter->asDate($report->getPeriodTimeStamp(), 'LLLL yyyy') . " успешно создан");
         $this->redirect(['index']);
     } else {
         echo Json::encode(['error' => 'Не удалось создать отчет']);
         return;
     }
 }