/**
  * 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;
 }
Пример #2
0
 public function testGetPanels()
 {
     $config['panels']['Company'] = "(%%type%% == 'individual')";
     $config['panels']['Personal'] = "(%%type%% == 'company')";
     $actual = Panel::getPanelNames($config);
     $expected = ['Company', 'Personal'];
     $this->assertEquals($actual, $expected, 'Does not return the actual panel names from config.');
     $config = [];
     $actual = Panel::getPanelNames($config);
     $expected = false;
     $this->assertEquals($actual, $expected, 'On an empty config, the function should return false.');
 }