|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Oliver Klee (typo3-coding@oliverklee.de) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * Testcase for the "tslib_fe" class in the TYPO3 Core. 00027 * 00028 * @package TYPO3 00029 * @subpackage tslib 00030 * 00031 * @author Oliver Klee <typo3-coding@oliverklee.de> 00032 */ 00033 class tslib_feTest extends tx_phpunit_testcase { 00034 /** 00035 * @var tslib_fe 00036 */ 00037 private $fixture; 00038 00039 public function setUp() { 00040 // This creates an instance of the class without calling the 00041 // original constructor. 00042 $className = uniqid('tslib_fe'); 00043 eval( 00044 'class ' . $className . ' extends tslib_fe {' . 00045 'public function ' . $className . '() {}' . 00046 'public function roundTripCryptString($string) {' . 00047 'return parent::roundTripCryptString($string);' . 00048 '}' . 00049 '}' 00050 ); 00051 00052 $this->fixture = new $className(); 00053 $this->fixture->TYPO3_CONF_VARS = $GLOBALS['TYPO3_CONF_VARS']; 00054 $this->fixture->TYPO3_CONF_VARS['SYS']['encryptionKey'] 00055 = '170928423746123078941623042360abceb12341234231'; 00056 } 00057 00058 public function tearDown() { 00059 unset($this->fixture); 00060 } 00061 00062 00063 //////////////////////////////// 00064 // Tests concerning codeString 00065 //////////////////////////////// 00066 00067 /** 00068 * @test 00069 */ 00070 public function codeStringForNonEmptyStringReturns10CharacterHashAndCodedString() { 00071 $this->assertRegExp( 00072 '/^[0-9a-f]{10}:[a-zA-Z0-9+=\/]+$/', 00073 $this->fixture->codeString('Hello world!') 00074 ); 00075 } 00076 00077 /** 00078 * @test 00079 */ 00080 public function decodingCodedStringReturnsOriginalString() { 00081 $clearText = 'Hello world!'; 00082 00083 $this->assertEquals( 00084 $clearText, 00085 $this->fixture->codeString( 00086 $this->fixture->codeString($clearText), TRUE 00087 ) 00088 ); 00089 } 00090 00091 00092 ////////////////////////////////////////// 00093 // Tests concerning roundTripCryptString 00094 ////////////////////////////////////////// 00095 00096 /** 00097 * @test 00098 */ 00099 public function roundTripCryptStringCreatesStringWithSameLengthAsInputString() { 00100 $clearText = 'Hello world!'; 00101 00102 $this->assertEquals( 00103 strlen($clearText), 00104 strlen($this->fixture->roundTripCryptString($clearText)) 00105 ); 00106 } 00107 00108 /** 00109 * @test 00110 */ 00111 public function roundTripCryptStringCreatesResultDifferentFromInputString() { 00112 $clearText = 'Hello world!'; 00113 00114 $this->assertNotEquals( 00115 $clearText, 00116 $this->fixture->roundTripCryptString($clearText) 00117 ); 00118 } 00119 00120 /** 00121 * @test 00122 */ 00123 public function roundTripCryptStringAppliedTwoTimesReturnsOriginalString() { 00124 $clearText = 'Hello world!'; 00125 00126 $this->assertEquals( 00127 $clearText, 00128 $this->fixture->roundTripCryptString( 00129 $this->fixture->roundTripCryptString($clearText) 00130 ) 00131 ); 00132 } 00133 } 00134 ?>
1.8.0