コード例 #1
0
 /**
  * @dataProvider evalExpressionScenariosProvider
  */
 public function testEvalExpression($scenario, $expression, $data, $expected)
 {
     $panelName = 'Foobar';
     $config['panels']['Foobar'] = $expression;
     $panel = new Panel($panelName, $config);
     $this->assertEquals($expected, $panel->evalExpression($data), sprintf('%s - Expression evaluation failed', $scenario));
     unset($panel);
 }
コード例 #2
0
 /**
  * List of evaluated Panels.
  *
  * Returns the all the evaluated panels which are split into two
  * types success and fail.
  * Success type contains the panels have been evaluated with success
  * and vice verca for fail type.
  *
  * @see \CsvMigrations\Panel::evalExpression How the expression is evaluated.
  * @param  array  $config Table's config.
  * @param  array  $data to get the values for placeholders
  * @return array          Evaluated panel list.
  */
 public function getEvalPanels(array $config, array $data)
 {
     $result = ['success' => [], 'fail' => []];
     $panels = Panel::getPanelNames($config) ?: [];
     foreach ($panels as $name) {
         $panel = new Panel($name, $config);
         if ($panel->evalExpression($data)) {
             $result['success'][] = $panel->getName();
         } else {
             $result['fail'][] = $panel->getName();
         }
     }
     return $result;
 }