Bug #4051 » 4051.patch

Bastian Waidelich, 2009-07-29 14:01

View differences:

Classes/Core/ViewHelper/TagBasedViewHelper.php (working copy)
87 87
	 */
88 88
	public function initialize() {
89 89
		parent::initialize();
90
		$this->tag->removeAllAttributes();
91
		$this->tag->setContent(NULL);
90 92
		$this->tag->setTagName($this->tagName);
91 93
		if (is_array($this->arguments['additionalAttributes'])) {
92 94
			$this->tag->addAttributes($this->arguments['additionalAttributes']);
Classes/Core/ViewHelper/TagBuilder.php (working copy)
191 191
	}
192 192

  
193 193
	/**
194
	 * Removes all attribute from the $attributes-collection
195
	 *
196
	 * @return void
197
	 * @author Bastian Waidelich <bastian@typo3.org>
198
	 * @api
199
	 */
200
	public function removeAllAttributes() {
201
		$this->attributes = array();
202
	}
203

  
204
	/**
194 205
	 * Renders and returns the tag
195 206
	 *
196 207
	 * @return void
Tests/Core/TagBasedViewHelperTest.php (working copy)
28 28
	public function setUp() {
29 29
		$this->viewHelper = new \F3\Fluid\Core\Fixtures\TestTagBasedViewHelper();
30 30
	}
31

  
31 32
	/**
32 33
	 * @test
34
	 * @author Bastian Waidelich <bastian@typo3.org>
35
	 */
36
	public function initializeRemovesAttributesAndContentsOfUnderlyingTagBuilder() {
37
		$mockTagBuilder = $this->getMock('F3\Fluid\Core\ViewHelper\TagBuilder', array('removeAllAttributes', 'setContent'), array(), '', FALSE);
38
		$mockTagBuilder->expects($this->once())->method('removeAllAttributes');
39
		$mockTagBuilder->expects($this->once())->method('setContent')->with(NULL);
40
		$this->viewHelper->injectTagBuilder($mockTagBuilder);
41

  
42
		$this->viewHelper->initialize();
43
	}
44

  
45
	/**
46
	 * @test
33 47
	 * @author Sebastian Kurfürst <sebastian@typo3.org>
34 48
	 * @author Bastian Waidelich <bastian@typo3.org>
35 49
	 */
Tests/Core/TagBuilderTest.php (working copy)
102 102
	 * @test
103 103
	 * @author Bastian Waidelich <bastian@typo3.org>
104 104
	 */
105
	public function contentCanBeRemoved() {
106
		$tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('tag', 'some content');
107
		$tagBuilder->setContent(NULL);
108
		$this->assertEquals('<tag />', $tagBuilder->render());
109
	}
110

  
111
	/**
112
	 * @test
113
	 * @author Bastian Waidelich <bastian@typo3.org>
114
	 */
105 115
	public function renderReturnsOpeningAndClosingTagIfNoContentIsSpecifiedButForceClosingTagIsTrue() {
106 116
		$tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('tag');
107 117
		$tagBuilder->forceClosingTag(TRUE);
......
157 167
	 * @test
158 168
	 * @author Bastian Waidelich <bastian@typo3.org>
159 169
	 */
170
	public function removeAllAttributesRemovesAllAttributes() {
171
		$tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('tagName', 'tag content');
172
		$tagBuilder->addAttribute('attribute1', 'attribute1value');
173
		$tagBuilder->addAttribute('attribute2', 'attribute2value');
174
		$tagBuilder->removeAllAttributes();
175
		$this->assertEquals('<tagName>tag content</tagName>', $tagBuilder->render());
176
	}
177

  
178
	/**
179
	 * @test
180
	 * @author Bastian Waidelich <bastian@typo3.org>
181
	 */
160 182
	public function tagNameCanBeOverridden() {
161 183
		$tagBuilder = new \F3\Fluid\Core\ViewHelper\TagBuilder('foo');
162 184
		$tagBuilder->setTagName('bar');
    (1-1/1)