function testTag()
  {
    $data = array('actions' => array('create' => array('jip' => true),
                                      'edit' => array('jip' => true),
                                      'display' => array(),
                                      'delete' => array('jip' => true)));

    $template = '<core:DATASOURCE id="realm"><limb:DSProcessor:GroupActions group_name="jip">'.
                '<list:LIST from="jip_actions"><list:ITEM>'.
                '<core:OPTIONAL for="jip">{$name}|</core:OPTIONAL>'.
                '</list:ITEM></list:LIST>'.
                '</core:DATASOURCE>';

    RegisterTestingTemplate('/limb/actions_DSProcessor.html', $template);

    $page =& new Template('/limb/actions_DSProcessor.html');
    $component =& $page->findChild('realm');

    $dataspace = new Dataspace();
    $dataspace->import($data);
    $component->registerDataSource($dataspace);

    $this->assertEqual($page->capture(), 'create|'.
                                         'edit|'.
                                         'delete|');
  }
コード例 #2
0
 function testLoad()
 {
     $variations_data = array('original' => array('id' => $id1 = 200, 'name' => $name1 = 'original', 'etag' => $etag1 = 'etag1', 'width' => $width1 = 200, 'height' => $height1 = 100, 'media_id' => $media_id1 = 101, 'media_file_id' => $media_file_id1 = 'media_file_id1', 'file_name' => $file_name1 = 'file_name1', 'mime_type' => $mime_type1 = 'mime_type1', 'size' => $size1 = 500), 'icon' => array('id' => $id2 = 300, 'name' => $name2 = 'icon', 'etag' => $etag2 = 'etag2', 'width' => $width2 = 20, 'height' => $height2 = 10, 'media_id' => $media_id2 = 102, 'media_file_id' => $media_file_id2 = 'media_file_id2', 'file_name' => $file_name2 = 'file_name2', 'mime_type' => $mime_type2 = 'mime_type2', 'size' => $size2 = 50));
     $result = array('id' => $id = 100, 'description' => $description = 'Description', 'variations' => $variations_data);
     $record = new Dataspace();
     $record->import($result);
     $image = new ImageObject();
     $this->mapper->load($record, $image);
     $this->assertEqual($image->getId(), $id);
     $this->assertEqual($image->getDescription(), $description);
     $this->_checkImageObjectVariations($image, $variations_data);
 }
コード例 #3
0
  function & fetchRecord()
  {
    $toolkit =& Limb :: toolkit();
    $resolver =& $toolkit->getRequestResolver($this->resolver_name);
    if(!is_object($resolver))
      die($this->resolver_name . ' request resolver not set:' . __FILE__ . ' at line '. __LINE__);

    $record = new Dataspace();

    if(!$entity =& $resolver->resolve($toolkit->getRequest()))
      return $record;

    $record->import($entity->export());
    return $record;
  }
 function testTag()
 {
     $data = array('_node_path' => $path = '/cms/limb/', '_service_name' => $service_name = 'TestService');
     $this->authorizer->expectOnce('getAccessibleActions', array($path, $service_name));
     $actions = array('create' => array('name' => 'create'), 'edit' => array('name' => 'edit'));
     $this->authorizer->setReturnValue('getAccessibleActions', $actions);
     $template = '<core:DATASOURCE id="realm"><limb:DSProcessor:Actions>' . '<list:LIST from="actions"><list:ITEM>' . '{$name}|' . '</list:ITEM></list:LIST>' . '</core:DATASOURCE>';
     RegisterTestingTemplate('/limb/actions_DSProcessor.html', $template);
     $page =& new Template('/limb/actions_DSProcessor.html');
     $component =& $page->findChild('realm');
     $dataspace = new Dataspace();
     $dataspace->import($data);
     $component->registerDataSource($dataspace);
     $this->assertEqual($page->capture(), 'create|' . 'edit|');
 }
コード例 #5
0
  function testLoad()
  {
    $mapper = new ObjectMapper();
    $object = new Object();

    $record = new Dataspace();
    $record->import(array('oid' => $id = 10,
                          'class_id' => $class_id = 100,
                          'class_name' => $class_name = 'some_class'));

    $mapper->load($record, $object);

    $this->assertEqual($object->get('oid'), $id);
    $this->assertEqual($object->get('class_id'), $class_id);
    $this->assertEqual($object->get('class_name'), $class_name);
  }
コード例 #6
0
  function testLoad()
  {
    $mapper = new TreeNodeDataMapper();
    $object = new Object();

    $record = new Dataspace();
    $record->import(array('_node_id' => $node_id = 10,
                          '_node_parent_id' => $parent_node_id = 100,
                          '_node_identifier' => $identifier = 'test',
                          ));

    $mapper->load($record, $object);

    $this->assertEqual($object->get('id'), $node_id);
    $this->assertEqual($object->get('parent_id'), $parent_node_id);
    $this->assertEqual($object->get('identifier'), $identifier);
  }
コード例 #7
0
  function testLoad()
  {
    $mapper = new ServiceLocationMapper();
    $object = new ServiceLocation();

    $record = new Dataspace();
    $record->import(array('_service_name' => $service_name = 'TestService',
                          '_service_title' => $title = 'some title',
                          '_service_id' => $id = 40,
                          ));

    $mapper->load($record, $object);

    $this->assertEqual($object->get('name'), $service_name);
    $this->assertEqual($object->get('title'), $title);
    $this->assertEqual($object->get('id'), $id);
  }
  function testTag()
  {
    $path = 'whatever';
    $data = array('_node_id' => $node_id = 10);

    $this->translator->expectOnce('getPathToNode', array($node_id));
    $this->translator->setReturnValue('getPathToNode', $path);

    $template = '<core:DATASOURCE id="realm"><limb:DSProcessor:Path>'.
                '{$_node_path}'.
                '</core:DATASOURCE>';

    RegisterTestingTemplate('/limb/path_DSProcessor.html', $template);

    $page =& new Template('/limb/path_DSProcessor.html');
    $component =& $page->findChild('realm');

    $dataspace = new Dataspace();
    $dataspace->import($data);
    $component->registerDataSource($dataspace);

    $this->assertEqual($page->capture(), $path);
  }
コード例 #9
0
  function testLoad()
  {
    $mapper = new VersionedObjectMapper($this->delegated_mapper);
    $object = new Object();

    $result = array('whatever');

    $record = new Dataspace();
    $record->import($result);

    $this->delegated_mapper->expectOnce('load', array($record, $object));

    $mapper->load($record, $object);
  }
コード例 #10
0
  function testLoadOverrideRecordPrefix()
  {
    $mapper = new OneTableObjectMapper('OneTableObjectMapperTest', 'foo');
    $object = new OneTableObjectMapperTestNewsObject();

    $result = array('bar_id' => $id = 10,
                    'bar_content' => $content = 'some content',
                    'bar_annotation' => $annotation = 'some annotation',
                    'bar_news_date' => $news_date = 'some date');

    $record = new Dataspace();
    $record->import($result);

    $mapper->load($record, $object, 'bar_');

    $this->assertEqual($object->get('id'), $id);
    $this->assertEqual($object->get('content'), $content);
    $this->assertEqual($object->get('annotation'), $annotation);
    $this->assertEqual($object->get('news_date'), $news_date);
  }