Ejemplo n.º 1
0
 /**
  * @param string $name
  * @param array  $variables
  * @return array
  */
 protected function getPlaceholderData($name, $variables)
 {
     $result = array();
     $items = $this->placeholder->getPlaceholderItems($name, $variables);
     foreach ($items as $item) {
         $result[] = $this->renderItemContent($item, $variables);
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testGetPlaceholderItems()
 {
     $placeholderName = 'test_placeholder';
     $variables = ['foo' => 'bar'];
     $items = $this->placeholders['items'];
     $index = 0;
     $isGrantedIndex = 0;
     // item1
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item1'], $variables)->will($this->returnValue($items['item1']));
     // item2
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item2']['applicable']], $variables)->will($this->returnValue(['applicable' => true]));
     unset($items['item2']['applicable']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item2'], $variables)->will($this->returnValue($items['item2']));
     // item3
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item3']['applicable']], $variables)->will($this->returnValue(['applicable' => false]));
     // item4
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item4']['applicable']], $variables)->will($this->returnValue(['applicable' => $items['item4']['applicable']]));
     unset($items['item4']['applicable']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item4'], $variables)->will($this->returnValue($items['item4']));
     // item5
     $this->resolver->expects($this->at($index++))->method('resolve')->with(['applicable' => $items['item5']['applicable']], $variables)->will($this->returnValue(['applicable' => $items['item5']['applicable']]));
     // item6
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor')->will($this->returnValue(false));
     // item7
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor')->will($this->returnValue(true));
     unset($items['item7']['acl']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item7'], $variables)->will($this->returnValue($items['item7']));
     // item8
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor1')->will($this->returnValue(true));
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor2')->will($this->returnValue(true));
     unset($items['item8']['acl']);
     $this->resolver->expects($this->at($index++))->method('resolve')->with($items['item8'], $variables)->will($this->returnValue($items['item8']));
     // item9
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor1')->will($this->returnValue(true));
     $this->securityFacade->expects($this->at($isGrantedIndex++))->method('isGranted')->with('acl_ancestor2')->will($this->returnValue(false));
     $expected = [$items['item1'], $items['item2'], $items['item4'], $items['item7'], $items['item8']];
     $this->assertEquals($expected, $this->provider->getPlaceholderItems($placeholderName, $variables));
 }