protected function initDepends() { $depends = get_default($this->config, 'depends'); if ($depends) { if (!is_array($depends)) { $depends = array($depends); } foreach ($depends as $d) { $w = $this->tool->widget($d); if (valid_obj($w, 'Clips\\WidgetV2')) { // Call the init function to force init the widget $w->init_v2(); } } } }
public function __construct($item = null) { if ($item) { if (valid_obj($item, 'Clips\\Interfaces\\Action')) { // If this item is action $this->name = $item->label(); $this->content = $item->content(); $this->params = $item->params(); } else { if (valid_obj($item, 'Clips\\FormField')) { // If this item is form field $this->type = self::FIELD; $this->name = get_default($item, 'form'); $this->content = get_default($item, 'name'); $this->params = array(get_default($item, 'value')); } else { // This must be the column of pagination $this->type = self::COLUMN; $this->name = get_default($item, 'name'); $this->content = get_default($item, 'data'); } } } }
public function setUp() { $mute = getenv('MUTE_PHPUNIT'); $ref = new \ReflectionClass($this); $func = $this->getName(); if (!$mute && $func != 'testStub') { echo "\n----------" . $ref->name . " | " . $func . "----------\n"; } $this->tool =& get_clips_tool(); $this->tool->helper('fake'); $this->clips = new Engine(); $re = new \Addendum\ReflectionAnnotatedClass($this); foreach (array($re, $re->getMethod($func)) as $m) { foreach ($m->getAnnotations() as $a) { switch (get_class($a)) { case "Clips\\Rules": // We need to load the rules before test execution $this->clips->clear(); // We should clear the clips every time $rules = get_default($a, 'rules', array()); $templates = get_default($a, 'templates', array()); // Load the templates foreach ($templates as $t) { $this->clips->template($t); } // Load the rules foreach ($rules as $r) { $this->clips->load($r); } break; case "Clips\\FakeModel": $ds = $this->tool->library('dataSource'); $fake = $this->tool->library('fakeDataSource'); $ds->fake = $fake; if (valid_obj($this, 'Clips\\Interfaces\\FakeDataSourceHandler')) { $fake->handler = $this; } else { if (!$a->value) { $a->value = 'expectFakeDataSourceHandler'; } $fake->handler = $this->tool->library($a->value); $this->fake_handler = $fake->handler; } $ds->_datasources = array('fake'); break; case "Clips\\TestData": case "Clips\\DataGenerator": $this->data = $this->tool->enhance($a); break; case "Clips\\TestValue": if (isset($a->json)) { $a->file = $a->json; } if (isset($a->file)) { $test_config_dir = clips_config('test_data_dir'); if (!$test_config_dir) { $test_config_dir = clips_config('test_dir'); $test_config_dir = path_join($test_config_dir[0], 'data'); } else { $test_config_dir = $test_config_dir[0]; } $p = path_join($test_config_dir, $a->file); if (\file_exists($p)) { $this->value = \file_get_contents($p); if (isset($a->json)) { $this->value = parse_json($this->value); } } } else { if (isset($a->context)) { $this->value = clips_context($a->context); } else { if (isset($a->value)) { $this->value = $a->value; } } } break; default: $this->tool->annotationEnhance($a, $this); } } } $this->doSetUp(); }