Commit 2ab22d5e authored by sgalinsk's avatar sgalinsk

[BUGFIX] Fix unit tests


git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/pmkshadowbox/trunk@85416 735d13b6-9817-0410-8766-e36946ffe9aa
parent 648a056d
......@@ -40,15 +40,13 @@ class tx_pmkshadowbox_build {
/**
* Content Object for Typoscript Operations
*
* @param tslib_cObj
* @var tslib_cObj
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
public $cObj = NULL;
/**
* Cache Handler
*
* @property tx_pmkshadowbox_cache
* @var tx_pmkshadowbox_cache
*/
protected $cacheHandler = NULL;
......@@ -77,11 +75,8 @@ class tx_pmkshadowbox_build {
*/
public function __construct($cacheHandler = NULL) {
$this->cObj = t3lib_div::makeInstance('tslib_cObj');
$this->sourceDirectory = t3lib_extMgm::siteRelPath('pmkshadowbox') .
'resources/shadowbox/source/';
$this->extensionConfiguration = unserialize(
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['pmkshadowbox']
);
$this->sourceDirectory = t3lib_extMgm::siteRelPath('pmkshadowbox') . 'resources/shadowbox/source/';
$this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['pmkshadowbox']);
if ($cacheHandler === NULL) {
try {
......@@ -122,12 +117,16 @@ class tx_pmkshadowbox_build {
/**
* Applies the stdWrap typoscript property on all entries of the given array that
* are suffixed with a dot. The primitive value without a dot is overriden in this case.
* are suffixed with a dot. The primitive value without a dot is overridden in this case.
*
* @param array $configuration typoscript configuration
* @return array normalized typoscript configuration
*/
protected function applyStdWrapOn(array $configuration) {
if (!is_object($GLOBALS['TSFE'])) {
$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe', array(), 0, 0);
}
$newConfiguration = array();
foreach ($configuration as $label => $value) {
if (!is_array($value)) {
......@@ -137,6 +136,7 @@ class tx_pmkshadowbox_build {
$labelWithoutDot = rtrim($label, '.');
$newConfiguration[$labelWithoutDot] = $this->cObj->stdWrap('', $value);
print_r($newConfiguration[$labelWithoutDot]);
}
return $newConfiguration;
......@@ -144,7 +144,7 @@ class tx_pmkshadowbox_build {
/**
* Checks the availability of the adapter and returns the given value or 'base' as an
* harcoded fallback value. It's returned as a relative path to the adapter based upon
* hardcoded fallback value. It's returned as a relative path to the adapter based upon
* the TYPO3 root.
*
* @param string $adapter
......@@ -176,8 +176,7 @@ class tx_pmkshadowbox_build {
$language = $this->sourceDirectory . 'languages/' . $language . '.js';
if (!file_exists(PATH_site . $language)) {
$languageFallback = ($languageFallback === 'de' ? 'de-DE' : $languageFallback);
$language = $this->sourceDirectory . 'languages/' .
$languageFallback . '.js';
$language = $this->sourceDirectory . 'languages/' . $languageFallback . '.js';
if (!file_exists(PATH_site . $language)) {
$language = $this->sourceDirectory . 'languages/en.js';
}
......
<?php
/***************************************************************
* Copyright notice
*
......@@ -71,12 +72,11 @@ class tx_pmkshadowbox_buildTest extends tx_phpunit_testcase {
public function testBuildInstanceWithoutCacheHandlerAsParameter() {
try {
$buildInstance = new tx_pmkshadowbox_build();
$cacheHandler = $buildInstance->getCacheHandler();
$this->assertTrue(is_dir(PATH_site . $cacheHandler->getCacheDirectory()));
} catch(Exception $exception) {
$this->fail('Failed with message: ' . $exception->getMessage());
}
$cacheHandler = $buildInstance->getCacheHandler();
$this->assertTrue(is_dir(PATH_site . $cacheHandler->getCacheDirectory()));
}
/**
......@@ -244,11 +244,12 @@ class tx_pmkshadowbox_buildTest extends tx_phpunit_testcase {
$this->assertTrue(file_exists(PATH_site . $relativeBuildDirectoryPath . 'shadowbox.js'));
$expectedResources = array('shadowbox.js', 'expressInstall.swf', 'play.png', 'next.png',
'close.png', 'pause.png', 'shadowbox.css', 'previous.png', 'player.swf', 'loading.gif');
'close.png', 'pause.png', 'shadowbox.css', 'previous.png', 'player.swf', 'loading.gif', 'yt.swf');
$actualResources = array();
$directoryHandler = new DirectoryIterator(PATH_site . $relativeBuildDirectoryPath);
foreach ($directoryHandler as $fileInfo) {
/** @var $fileInfo DirectoryIterator */
if ($fileInfo->isDot()) {
continue;
}
......@@ -286,6 +287,7 @@ class tx_pmkshadowbox_buildTest extends tx_phpunit_testcase {
$directoryHandler = new DirectoryIterator(PATH_site . $relativeBuildDirectoryPath);
foreach ($directoryHandler as $fileInfo) {
/** @var $fileInfo DirectoryIterator */
if ($fileInfo->isDot()) {
continue;
}
......@@ -323,6 +325,7 @@ class tx_pmkshadowbox_buildTest extends tx_phpunit_testcase {
$directoryHandler = new DirectoryIterator(PATH_site . $relativeBuildDirectoryPath);
foreach ($directoryHandler as $fileInfo) {
/** @var $fileInfo DirectoryIterator */
if ($fileInfo->isDot()) {
continue;
}
......@@ -361,11 +364,12 @@ class tx_pmkshadowbox_buildTest extends tx_phpunit_testcase {
$this->assertTrue(file_exists(PATH_site . $relativeBuildDirectoryPath . 'shadowbox.js'));
$expectedResources = array('shadowbox.js', 'expressInstall.swf', 'play.png', 'next.png',
'close.png', 'pause.png', 'shadowbox.css', 'previous.png', 'player.swf', 'loading.gif');
'close.png', 'pause.png', 'shadowbox.css', 'previous.png', 'player.swf', 'loading.gif', 'yt.swf');
$actualResources = array();
$directoryHandler = new DirectoryIterator(PATH_site . $relativeBuildDirectoryPath);
foreach ($directoryHandler as $fileInfo) {
/** @var $fileInfo DirectoryIterator */
if ($fileInfo->isDot()) {
continue;
}
......@@ -381,4 +385,4 @@ class tx_pmkshadowbox_buildTest extends tx_phpunit_testcase {
}
}
?>
?>
\ No newline at end of file
<?php
/***************************************************************
* Copyright notice
*
......@@ -32,7 +33,7 @@
*/
class tx_pmkshadowbox_cacheTest extends tx_phpunit_testcase {
/**
* @var tx_pmkshadowbox_build
* @var tx_pmkshadowbox_cache
*/
protected $fixture = null;
......@@ -119,4 +120,5 @@ class tx_pmkshadowbox_cacheTest extends tx_phpunit_testcase {
$this->assertTrue(file_exists(PATH_site . $expectedPathName));
}
}
?>
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment