コード例 #1
0
  function testSetupTargets()
  {
    $component = new DatasourceComponentSetupTargetsTestVersion($this);

    $component->parent = $this->parent;
    $this->parent->expectArgumentsAt(0, 'findChild', array('target1'));
    $this->parent->expectArgumentsAt(1, 'findChild', array('target2'));
    $this->parent->setReturnValueAt(0, 'findChild', $target1 = new MockListComponent($this));
    $this->parent->setReturnValueAt(1, 'findChild', $target2 = new MockListComponent($this));

    $component->expectOnce('getDataset');
    $dataset = new ArrayDataset(array('some_data'));
    $component->setReturnValue('getDataset', $dataset);

    $target1->expectOnce('registerDataset', array($dataset));
    $target2->expectOnce('registerDataset', array($dataset));
    $component->setupTargets('target1, target2');

    $component->tally();
    $target1->tally();
    $target2->tally();
  }
コード例 #2
0
  function testProcessSeveralTargetsWithNavigator()
  {
    $component = new LimbDAOComponentSetupTargetsTestVersion($this);

    $component->parent =& $this->parent;
    $this->parent->setReturnReference('findChild', $target1 = new MockListComponent($this), array('target1'));
    $this->parent->setReturnReference('findChild', $target2 = new MockListComponent($this), array('target2'));
    $this->parent->setReturnReference('findChild', $pager = new MockLimbPagerComponent($this), array('pager'));

    $component->expectOnce('getDataset');
    $rs = new MockPagedArrayDataSet($this);
    $rs->expectOnce('paginate', array(new IsAExpectation('MockLimbPagerComponent')));
    $component->setReturnReference('getDataset', $rs);

    $target1->expectOnce('registerDataset', array(new IsAExpectation('MockPagedArrayDataSet')));
    $target2->expectOnce('registerDataset', array(new IsAExpectation('MockPagedArrayDataSet')));
    $component->setTargets(array('target1', 'target2'));
    $component->setNavigator('pager');

    $component->process();

    $component->tally();
    $target1->tally();
    $target2->tally();
    $pager->tally();
    $rs->tally();
  }