TYPO3 CMS  TYPO3_6-2
AttributesAttributeTest.php
Go to the documentation of this file.
1 <?php
3 
7 
8 /*
9  * This file is part of the TYPO3 CMS project.
10  *
11  * It is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License, either version 2
13  * of the License, or any later version.
14  *
15  * For the full copyright and license information, please read the
16  * LICENSE.txt file that was distributed with this source code.
17  *
18  * The TYPO3 project - inspiring people to share!
19  */
20 
25 
29  protected $subject = NULL;
30 
34  protected $singletonInstances = array();
35 
39  protected $elementId;
40 
44  public function setUp(){
45  $contentObjectRendererProphecy = $this->prophesize('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
46  GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $contentObjectRendererProphecy->reveal());
47  $localisationProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Localization');
48  GeneralUtility::addInstance('TYPO3\\CMS\\Form\\Localization', $localisationProphecy->reveal());
49  $requestProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Request');
50  $this->singletonInstances = GeneralUtility::getSingletonInstances();
51  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Form\\Request', $requestProphecy->reveal());
52  $this->elementId = uniqid('elementId_', TRUE);
53  $this->subject = new AttributesAttribute($this->elementId);
54  }
55 
59  protected function tearDown() {
60  GeneralUtility::resetSingletonInstances($this->singletonInstances);
61  parent::tearDown();
62  }
63 
68  $this->assertFalse($this->subject->hasAttribute('anAttribute'));
69  }
70 
75  $this->assertEmpty($this->subject->getValue('anAttribute'));
76  }
77 
82  $attributeProphecy = $this->prophesize('TYPO3\\CMS\\Form\\Domain\\Model\\Attribute\\AbstractAttribute');
83  $attributeProphecy->getValue()->shouldBeCalled()->willReturn('aValue');
84 
85  $this->subject->setAttribute('anAttribute', $attributeProphecy->reveal());
86  $this->assertSame('aValue', $this->subject->getValue('anAttribute'));
87  }
88 }
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static addInstance($className, $instance)
static resetSingletonInstances(array $newSingletonInstances)