TYPO3 CMS  TYPO3_6-2
All Classes Namespaces Files Functions Variables Pages
CountViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 
22  protected $viewHelper;
23 
24  public function setUp() {
25  parent::setUp();
26  $this->viewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\CountViewHelper', array('renderChildren'));
27  $this->injectDependenciesIntoViewHelper($this->viewHelper);
28  $this->viewHelper->initializeArguments();
29  }
30 
35  $expectedResult = 3;
36  $actualResult = $this->viewHelper->render(array('foo', 'bar', 'Baz'));
37  $this->assertSame($expectedResult, $actualResult);
38  }
39 
44  $expectedResult = 2;
45  $actualResult = $this->viewHelper->render(new \ArrayObject(array('foo', 'bar')));
46  $this->assertSame($expectedResult, $actualResult);
47  }
48 
53  $expectedResult = 0;
54  $actualResult = $this->viewHelper->render(array());
55  $this->assertSame($expectedResult, $actualResult);
56  }
57 
62  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue(array('foo', 'bar', 'baz')));
63  $expectedResult = 3;
64  $actualResult = $this->viewHelper->render(NULL);
65  $this->assertSame($expectedResult, $actualResult);
66  }
67 
72  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue(NULL));
73  $expectedResult = 0;
74  $actualResult = $this->viewHelper->render(NULL);
75  $this->assertSame($expectedResult, $actualResult);
76  }
77 
83  $object = new \stdClass();
84  $this->viewHelper->render($object);
85  }
86 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)