Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
[TASK] Slightly improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Feb 3, 2015
1 parent b77475c commit f990a4d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Tests/Unit/Backend/ContentSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Fluidcontent\Backend\ContentSelector;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -16,10 +17,37 @@
*/
class ContentSelectorTest extends UnitTestCase {

/**
* @return void
*/
public function testCreatesInstance() {
$instance = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')
->get('FluidTYPO3\\Fluidcontent\\Backend\\ContentSelector');
$this->assertInstanceOf('FluidTYPO3\\Fluidcontent\\Backend\\ContentSelector', $instance);
}

/**
* @return void
*/
public function testRenderFieldCreatesSelectTag() {
$GLOBALS['LANG'] = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService', array('sL'));
$statement = $this->getMock('TYPO3\\CMS\\Core\\Database\\PreparedStatement', array('execute', 'free', 'fetch'), array(), '', FALSE);
$statement->expects($this->any())->method('execute')->willReturn(FALSE);
$statement->expects($this->any())->method('fetch')->willReturn(FALSE);
$statement->expects($this->any())->method('free');
$GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection',
array('exec_SELECTquery', 'prepare_SELECTquery'), array(), '', FALSE);
$GLOBALS['TYPO3_DB']->expects($this->any())->method('exec_SELECTquery')->willReturn(FALSE);
$GLOBALS['TYPO3_DB']->expects($this->any())->method('prepare_SELECTquery')->willReturn($statement);
$instance = new ContentSelector();
$parameters = array(
'itemFormElName' => 'foobar',
'itemFormElValue' => 'foovalue'
);
$parent = 'unused';
$rendered = $instance->renderField($parameters, $parent);
$this->assertStringStartsWith('<div><select', $rendered);
$this->assertContains($parameters['itemFormElName'], $rendered);
}

}

0 comments on commit f990a4d

Please sign in to comment.