Skip to content

Commit

Permalink
[TASK] Remove/re-enable tests currently disabled
Browse files Browse the repository at this point in the history
Some tests no longer apply, others required additional mocking.
  • Loading branch information
NamelessCoder committed Feb 22, 2015
1 parent b032c65 commit 696c083
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 69 deletions.
Empty file.
11 changes: 11 additions & 0 deletions Tests/Unit/Service/WorkspacesAwareRecordServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;

/**
* @package Flux
*/
Expand All @@ -26,4 +28,13 @@ public function overlayRecordsCallsExpectedMethodSequence() {
$this->assertEquals($expected, $result);
}

/**
* @test
*/
public function getWorkspaceVersionOfRecordOrRecordItselfReturnsSelf() {
$instance = new WorkspacesAwareRecordService();
$result = $this->callInaccessibleMethod($instance, 'getWorkspaceVersionOfRecordOrRecordItself', 'void', array('uid' => 1));
$this->assertEquals(array('uid' => 1), $result);
}

}
12 changes: 9 additions & 3 deletions Tests/Unit/Utility/MiscellaneousUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,44 @@ protected function getFormInstance() {
}

/**
* @disabledtest
* @test
*/
public function canCreateIconWithUrl() {
$GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
$clipBoardData = $this->getClipBoardDataFixture();
ClipBoardUtility::setClipBoardData($clipBoardData);
$iconWithUrl = ClipBoardUtility::createIconWithUrl('1-2-3');
$this->assertNotEmpty($iconWithUrl);
ClipBoardUtility::clearClipBoardData();
unset($GLOBALS['BE_USER']);
}

/**
* @disabledtest
* @test
*/
public function canCreateIconWithUrlAsReference() {
$GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
$clipBoardData = $this->getClipBoardDataFixture();
$clipBoardData['normal']['mode'] = 'reference';
ClipBoardUtility::setClipBoardData($clipBoardData);
$iconWithUrl = ClipBoardUtility::createIconWithUrl('1-2-3', TRUE);
$this->assertNotEmpty($iconWithUrl);
ClipBoardUtility::clearClipBoardData();
unset($GLOBALS['BE_USER']);
}

/**
* @disabledtest
* @test
*/
public function canCreateIconWithUrlAsReferenceReturnsEmptyStringIfModeIsCut() {
$GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
$clipBoardData = $this->getClipBoardDataFixture();
ClipBoardUtility::setClipBoardData($clipBoardData);
$iconWithUrl = ClipBoardUtility::createIconWithUrl('1-2-3', TRUE);
$this->assertIsString($iconWithUrl);
$this->assertEmpty($iconWithUrl);
ClipBoardUtility::clearClipBoardData();
unset($GLOBALS['BE_USER']);
}

/**
Expand Down
77 changes: 11 additions & 66 deletions Tests/Unit/View/ExposedTemplateViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,6 @@ public function canRenderEmptyPreviewSection() {
$this->assertEmpty($preview);
}

/**
* @disabledtest
*/
public function canRenderPreviewSectionWithGrid() {
$templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_BASICGRID);
$service = $this->createFluxServiceInstance();
$record = Records::$contentRecordWithoutParentAndWithoutChildren;
$record['pi_flexform'] = Xml::SIMPLE_FLEXFORM_SOURCE_DEFAULT_SHEET_ONE_FIELD;
$viewContext = new ViewContext($templatePathAndFilename, 'Flux');
$viewContext->setVariables(array('record' => $record));
$viewContext->setSectionName('Configuration');
$variables = array(
'row' => $record,
'grid' => $service->getGridFromTemplateFile($viewContext, 'grid')
);
$view = $this->getPreparedViewWithTemplateFile($templatePathAndFilename);
$preview = $view->renderStandaloneSection('Preview', $variables);
$preview = trim($preview);
$this->assertNotEmpty($preview);
$this->assertStringStartsWith('<', $preview);
$this->assertStringEndsWith('>', $preview);
$this->assertContains('flux-grid', $preview); // the class targeted in CSS selectors must be applied at least once
$this->assertContains('content-grid', $preview); // the ID of the Grid must exist
$this->assertNotContains('Duplicate variable declarations!', $preview); // the ever-so-dreaded error when variables collide
$this->assertGreaterThanOrEqual(1000, strlen($preview)); // If Grid template contains (moderately) few characters, assume error
}

/**
* @disabledtest
*/
public function canRenderPreviewSectionWithCollapsedGrid() {
$record = Records::$contentRecordWithoutParentAndWithoutChildren;
$_COOKIE['fluxCollapseStates'] = urlencode(json_encode(array($record['uid'])));
$this->canRenderPreviewSectionWithGrid();
}

/**
* @test
*/
Expand All @@ -93,7 +57,7 @@ public function canRenderCustomSection() {
}

/**
* @disabledtest
* @test
*/
public function canRenderRaw() {
$templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_CUSTOM_SECTION);
Expand All @@ -106,7 +70,7 @@ public function canRenderRaw() {
}

/**
* @disabledtest
* @test
*/
public function canRenderWithDisabledCompiler() {
$templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_CUSTOM_SECTION);
Expand All @@ -132,7 +96,7 @@ public function createsDefaultFormFromInvalidTemplate() {
}

/**
* @disabledtest
* @test
*/
public function renderingTemplateTwiceTriggersTemplateCompilerSaving() {
$templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL);
Expand All @@ -155,6 +119,7 @@ public function throwsRuntimeExceptionIfImproperlyInitialized() {
* @disabledtest
*/
public function throwsParserExceptionIfTemplateSourceContainsErrors() {
// @TODO: use vfs
$validTemplatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL);
$validTemplateSource = file_get_contents($validTemplatePathAndFilename);
$invalidTemplateSource = $validTemplateSource . LF . LF . '</f:section>' . LF;
Expand All @@ -166,7 +131,7 @@ public function throwsParserExceptionIfTemplateSourceContainsErrors() {
}

/**
* @disabledtest
* @test
*/
public function canGetStoredVariableWithoutConfigurationSectionName() {
$templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL);
Expand All @@ -175,39 +140,19 @@ public function canGetStoredVariableWithoutConfigurationSectionName() {
}

/**
* @disabledtest
*/
public function canGetStoredVariableImmediatelyAfterRemovingCachedFiles() {
$templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL);
$view = $this->getPreparedViewWithTemplateFile($templatePathAndFilename);
$this->callInaccessibleMethod($view, 'getStoredVariable', 'FluidTYPO3\Flux\ViewHelpers\FormViewHelper', 'storage');
}


/**
* @disabledtest
*/
public function canGetStoredVariableImmediatelyAfterRemovingCachedFilesWhenCompilerIsDisabled() {
$backup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['flux']['setup']['disableCompiler'];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['flux']['setup']['disableCompiler'] = 1;
$this->canGetStoredVariableImmediatelyAfterRemovingCachedFiles();
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['flux']['setup']['disableCompiler'] = $backup;
}

/**
* @disabledtest
* @test
*/
public function canGetTemplateByActionName() {
$templatePaths = $this->getFixtureTemplatePaths();
$service = $this->createFluxServiceInstance();
$viewContext = new ViewContext(NULL, 'Flux', 'API');
$viewContext->setTemplatePaths($templatePaths);
$viewContext = new ViewContext(NULL, 'Flux', 'Content');
$viewContext->setTemplatePaths(new TemplatePaths($templatePaths));
$view = $service->getPreparedExposedTemplateView($viewContext);
$controllerContext = ObjectAccess::getProperty($view, 'controllerContext', TRUE);
$controllerContext->getRequest()->setControllerActionName('index');
$controllerContext->getRequest()->setControllerName('Grid');
$controllerContext->getRequest()->setControllerActionName('dummy');
$controllerContext->getRequest()->setControllerName('Content');
$view->setControllerContext($controllerContext);
$output = $view->getTemplatePathAndFilename('index');
$output = $view->getTemplatePathAndFilename('dummy');
$this->assertNotEmpty($output);
$this->assertFileExists($output);
}
Expand Down

0 comments on commit 696c083

Please sign in to comment.