2 /***************************************************************
5 * (c) 2010-2011 Ernesto Baschny (ernst@cron-it.de)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
26 * Testcase for the t3lib_db class in the TYPO3 Core.
31 * @author Ernesto Baschny <ernst@cron-it.de>
33 class t3lib_dbTest
extends tx_phpunit_testcase
{
37 private $fixture = NULL;
41 public function setUp() {
42 $this->fixture
= $GLOBALS['TYPO3_DB'];
44 $this->testTable
= 'test_t3lib_dbtest';
46 $this->fixture
->sql_query('CREATE TABLE ' . $this->testTable
. ' (
47 id int(11) unsigned NOT NULL auto_increment,
50 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
54 public function tearDown() {
55 $this->fixture
->sql_query(
56 'DROP TABLE ' . $this->testTable
. ';'
59 unset($this->fixture
);
63 //////////////////////////////////////////////////
64 // Write/Read tests for charsets and binaries
65 //////////////////////////////////////////////////
70 public function storedFullAsciiRangeReturnsSameData() {
72 for ($i = 0; $i < 256; $i ++
) {
73 $binaryString .= chr($i);
76 $this->fixture
->exec_INSERTquery(
78 array('fieldblob' => $binaryString)
81 $id = $this->fixture
->sql_insert_id();
83 $entry = $this->fixture
->exec_SELECTgetRows(
91 $entry[0]['fieldblob']
98 public function storedGzipCompressedDataReturnsSameData() {
99 $testStringWithBinary = @gzcompress
('sdfkljer4587');
101 $this->fixture
->exec_INSERTquery(
103 array('fieldblob' => $testStringWithBinary)
106 $id = $this->fixture
->sql_insert_id();
108 $entry = $this->fixture
->exec_SELECTgetRows(
115 $testStringWithBinary,
116 $entry[0]['fieldblob']
121 ////////////////////////////////
122 // Tests concerning listQuery
123 ////////////////////////////////
128 * @see http://bugs.typo3.org/view.php?id=15211
130 public function listQueryWithIntegerCommaAsValue() {
131 // Note: 44 = ord(',')
133 $this->fixture
->listQuery('dummy', 44, 'table'),
134 $this->fixture
->listQuery('dummy', '44', 'table')
139 /////////////////////////////////////////////////
140 // Tests concerning escapeStringForLikeComparison
141 /////////////////////////////////////////////////
146 public function escapeStringForLikeComparison() {
149 $this->fixture
->escapeStrForLike('foo_bar%', 'table')