Bug #23845 » 16134_04-test.diff
tests/t3lib/t3lib_iconWorksTest.php (working copy) | ||
---|---|---|
* @subpackage t3lib
|
||
*/
|
||
class t3lib_iconWorksTest extends tx_phpunit_testcase {
|
||
|
||
/**
|
||
* Enable backup of global and system variables
|
||
*
|
||
* @var boolean
|
||
*/
|
||
protected $backupGlobals = TRUE;
|
||
|
||
/**
|
||
* Exclude TYPO3_DB from backup/restore of $GLOBALS
|
||
* because resource types cannot be handled during serializing
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $backupGlobalsBlacklist = array('TYPO3_DB');
|
||
|
||
/**
|
||
* @var array
|
||
*/
|
||
protected $mockRecord;
|
||
|
||
public function setUp() {
|
||
... | ... | |
|
||
|
||
//////////////////////////////////////////
|
||
// Tests concerning imagemake
|
||
//////////////////////////////////////////
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function imagemakeFixesPermissionsOnNewFiles() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('imagemakeFixesPermissionsOnNewFiles() test not available on Windows.');
|
||
}
|
||
|
||
$fixtureGifFile = dirname(__FILE__) . '/fixtures/clear.gif';
|
||
|
||
// Create image ressource, determine target filename, fake target permission, run method and clean up
|
||
$fixtureGifRessource = imagecreatefromgif($fixtureGifFile);
|
||
$targetFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.gif';
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
t3lib_iconWorks::imagemake($fixtureGifRessource, $targetFilename);
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($targetFilename)), 2);
|
||
t3lib_div::unlink_tempfile($targetFilename);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////
|
||
// Tests concerning getSpriteIconClasses
|
||
//////////////////////////////////////////
|
||
|
tests/t3lib/t3lib_divTest.php (working copy) | ||
---|---|---|
|
||
|
||
///////////////////////////////
|
||
// Tests concerning gif_compress
|
||
///////////////////////////////
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() test not available on Windows.');
|
||
}
|
||
|
||
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] || !$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']) {
|
||
$this->markTestSkipped('gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() test not available without imagemagick setup.');
|
||
}
|
||
|
||
$fixtureGifFile = dirname(__FILE__) . '/fixtures/clear.gif';
|
||
|
||
$GLOBALS['TYPO3_CONF_VARS']['GFX']['gif_compress'] = TRUE;
|
||
|
||
// Copy file to unique filename in typo3temp, set target permissions and run method
|
||
$testFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.gif';
|
||
@copy($fixtureGifFile, $testFilename);
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
t3lib_div::gif_compress($testFilename, 'IM');
|
||
|
||
// Get actual permissions and clean up
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($testFilename)), 2);
|
||
t3lib_div::unlink_tempfile($testFilename);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function gifCompressFixesPermissionOfConvertedFileIfUsingGd() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() test not available on Windows.');
|
||
}
|
||
|
||
$fixtureGifFile = dirname(__FILE__) . '/fixtures/clear.gif';
|
||
|
||
$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = TRUE;
|
||
$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] = FALSE;
|
||
|
||
// Copy file to unique filename in typo3temp, set target permissions and run method
|
||
$testFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.gif';
|
||
@copy($fixtureGifFile, $testFilename);
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
t3lib_div::gif_compress($testFilename, 'GD');
|
||
|
||
// Get actual permissions and clean up
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($testFilename)), 2);
|
||
t3lib_div::unlink_tempfile($testFilename);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
|
||
///////////////////////////////
|
||
// Tests concerning png_to_gif_by_imagemagick
|
||
///////////////////////////////
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function pngToGifByImagemagickFixesPermissionsOfConvertedFile() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('pngToGifByImagemagickFixesPermissionsOfConvertedFile() test not available on Windows.');
|
||
}
|
||
|
||
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] || !$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']) {
|
||
$this->markTestSkipped('pngToGifByImagemagickFixesPermissionsOfConvertedFile() test not available without imagemagick setup.');
|
||
}
|
||
|
||
$fixturePngFile = dirname(__FILE__) . '/fixtures/clear.png';
|
||
|
||
$GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif'] = TRUE;
|
||
|
||
// Copy file to unique filename in typo3temp, set target permissions and run method
|
||
$testFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.png';
|
||
@copy($fixturePngFile, $testFilename);
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
$newGifFile = t3lib_div::png_to_gif_by_imagemagick($testFilename);
|
||
|
||
// Get actual permissions and clean up
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($newGifFile)), 2);
|
||
t3lib_div::unlink_tempfile($newGifFile);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
|
||
///////////////////////////////
|
||
// Tests concerning read_png_gif
|
||
///////////////////////////////
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function readPngGifFixesPermissionsOfConvertedFile() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('readPngGifFixesPermissionsOfConvertedFile() test not available on Windows.');
|
||
}
|
||
|
||
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
|
||
$this->markTestSkipped('readPngGifFixesPermissionsOfConvertedFile() test not available without imagemagick setup.');
|
||
}
|
||
|
||
$testGifFile = dirname(__FILE__) . '/fixtures/clear.gif';
|
||
|
||
// Set target permissions and run method
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
$newPngFile = t3lib_div::read_png_gif($testGifFile, TRUE);
|
||
|
||
// Get actual permissions and clean up
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($newPngFile)), 2);
|
||
t3lib_div::unlink_tempfile($newPngFile);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
|
||
///////////////////////////////
|
||
// Tests concerning validIP
|
||
///////////////////////////////
|
||
|
||
... | ... | |
public function verifyFilenameAgainstDenyPatternDetectsNullCharacter() {
|
||
$this->assertFalse(t3lib_div::verifyFilenameAgainstDenyPattern("image\x00.gif"));
|
||
}
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////
|
||
// Tests concerning sysLog
|
||
/////////////////////////////////////////////////////////////////////////////////////
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function syslogFixesPermissionsOnFileIfUsingFileLogging() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('syslogFixesPermissionsOnFileIfUsingFileLogging() test not available on Windows.');
|
||
}
|
||
|
||
// Fake all required settings
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = 0;
|
||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
|
||
unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']);
|
||
$testLogFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.txt';
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'] = 'file,' . $testLogFilename . ',0';
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
|
||
// Call method, get actual permissions and clean up
|
||
t3lib_div::syslog('testLog', 'test', 1);
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($testLogFilename)), 2);
|
||
t3lib_div::unlink_tempfile($testLogFilename);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function deprecationLogFixesPermissionsOnLogFile() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('deprecationLogFixesPermissionsOnLogFile() test not available on Windows.');
|
||
}
|
||
|
||
// Fake all required settings and get an unique logfilename
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = uniqid('test_');
|
||
$deprecationLogFilename = t3lib_div::getDeprecationLogFileName();
|
||
print_r($deprecationLogFilename);
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = TRUE;
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
|
||
// Call method, get actual permissions and clean up
|
||
t3lib_div::deprecationLog('foo');
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($deprecationLogFilename)), 2);
|
||
@unlink($deprecationLogFilename);
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
}
|
||
?>
|
tests/t3lib/t3lib_lockTest.php (revision 0) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2010 Christian Kuhn <lolli@schwarzbu.ch>
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
|
||
/**
|
||
* Testcase for t3lib_lock
|
||
*
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
*
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*/
|
||
|
||
class t3lib_lockTest extends tx_phpunit_testcase {
|
||
|
||
/**
|
||
* Enable backup of global and system variables
|
||
*
|
||
* @var boolean
|
||
*/
|
||
protected $backupGlobals = TRUE;
|
||
|
||
/**
|
||
* Exclude TYPO3_DB from backup/ restore of $GLOBALS
|
||
* because resource types cannot be handled during serializing
|
||
*
|
||
* @var array
|
||
*/
|
||
protected $backupGlobalsBlacklist = array('TYPO3_DB');
|
||
|
||
///////////////////////////////
|
||
// tests concerning acquire
|
||
///////////////////////////////a
|
||
|
||
/**
|
||
* @test
|
||
*/
|
||
public function acquireFixesPermissionsOnLockFileIfUsingSimpleLogging() {
|
||
if (TYPO3_OS == 'WIN') {
|
||
$this->markTestSkipped('acquireFixesPermissionsOnLockFileIfUsingSimpleLogging() test not available on Windows.');
|
||
}
|
||
|
||
// Use a very high id to be unique
|
||
$instance = new t3lib_lock(999999999, 'simple');
|
||
$pathOfLockFile = $instance->getResource();
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
|
||
|
||
// Acquire lock, get actual file permissions and clean up
|
||
$instance->acquire();
|
||
clearstatcache();
|
||
$resultFilePermissions = substr(decoct(fileperms($pathOfLockFile)), 2);
|
||
$instance->__destruct();
|
||
|
||
$this->assertEquals($resultFilePermissions, '0777');
|
||
}
|
||
}
|
||
?>
|