33 $configuration = array(
34 'handlerCfg' => array(
43 'cachingframework_cache_hash' => array(
44 'mapTableName' =>
'cf_cache_hash',
46 'cachingframework_cache_hash_tags' => array(
47 'mapTableName' =>
'cf_cache_hash_tags',
49 'cachingframework_cache_pages' => array(
50 'mapTableName' =>
'cf_cache_pages',
52 'cpg_categories' => array(
53 'mapFieldNames' => array(
58 'mapTableName' =>
'my_pages',
59 'mapFieldNames' => array(
64 'mapTableName' =>
'ext_tt_news',
65 'mapFieldNames' => array(
67 'fe_group' =>
'usergroup',
70 'tt_news_cat' => array(
71 'mapTableName' =>
'ext_tt_news_cat',
72 'mapFieldNames' => array(
76 'tt_news_cat_mm' => array(
77 'mapTableName' =>
'ext_tt_news_cat_mm',
78 'mapFieldNames' => array(
79 'uid_local' =>
'local_uid',
82 'tx_crawler_process' => array(
83 'mapTableName' =>
'tx_crawler_ps',
84 'mapFieldNames' => array(
85 'process_id' =>
'ps_id',
86 'active' =>
'is_active',
89 'tx_dam_file_tracking' => array(
90 'mapFieldNames' => array(
91 'file_name' =>
'filename',
92 'file_path' =>
'path',
95 'tx_dbal_debuglog' => array(
96 'mapFieldNames' => array(
97 'errorFlag' =>
'errorflag',
100 'tx_templavoila_datastructure' => array(
101 'mapTableName' =>
'tx_templavoila_ds',
106 $this->subject = $this->prepareSubject(
'oci8', $configuration);
113 $this->assertTrue($this->subject->runningADOdbDriver(
'oci8'));
121 $result = $this->subject->SELECTquery(
'/*! SQL_NO_CACHE */ content',
'tx_realurl_urlencodecache',
'1=1');
122 $expected =
'SELECT "content" FROM "tx_realurl_urlencodecache" WHERE 1 = 1';
130 $parseString =
'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
131 $parseString .=
'VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\');';
132 $components = $this->subject->SQLparser->_callRef(
'parseINSERT', $parseString);
133 $this->assertTrue(is_array($components), $components);
134 $insert = $this->subject->SQLparser->_callRef(
'compileINSERT', $components);
139 'tr_parent_iso_nr' =>
'0',
140 'tr_name_en' =>
'Africa' 142 $this->assertEquals($expected, $insert);
149 $tableFields = array(
'uid',
'pid',
'tr_iso_nr',
'tr_parent_iso_nr',
'tr_name_en');
150 $this->subject->cache_fieldType[
'static_territories'] = array_flip($tableFields);
151 $parseString =
'INSERT INTO static_territories VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\'),(\'2\', \'0\', \'9\', \'0\', \'Oceania\'),' .
'(\'3\', \'0\', \'19\', \'0\', \'Americas\'),(\'4\', \'0\', \'142\', \'0\', \'Asia\');';
152 $components = $this->subject->SQLparser->_callRef(
'parseINSERT', $parseString);
153 $this->assertTrue(is_array($components), $components);
154 $insert = $this->subject->SQLparser->_callRef(
'compileINSERT', $components);
155 $this->assertEquals(4, count($insert));
156 for ($i = 0; $i < count($insert); $i++) {
157 foreach ($tableFields as $field) {
158 $this->assertTrue(isset($insert[$i][$field]),
'Could not find ' . $field .
' column');
167 $fields = array(
'uid',
'pid',
'title',
'body');
169 array(
'1',
'2',
'Title #1',
'Content #1'),
170 array(
'3',
'4',
'Title #2',
'Content #2'),
171 array(
'5',
'6',
'Title #3',
'Content #3')
173 $result = $this->subject->INSERTmultipleRows(
'tt_content', $fields, $rows);
174 $expected[0] =
'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'1\', \'2\', \'Title #1\', \'Content #1\' )';
175 $expected[1] =
'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'3\', \'4\', \'Title #2\', \'Content #2\' )';
176 $expected[2] =
'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'5\', \'6\', \'Title #3\', \'Content #3\' )';
177 $this->assertEquals(count($expected), count(
$result));
178 for ($i = 0; $i < count(
$result); $i++) {
179 $this->assertTrue(is_array(
$result[$i]),
'Expected array: ' .
$result[$i]);
180 $this->assertEquals(1, count(
$result[$i]));
190 $result = $this->subject->SELECTquery(
'*',
'pages',
'pid=0 AND pages.deleted=0 AND pages.hidden=0 AND pages.starttime<=1281620460 ' .
'AND (pages.endtime=0 OR pages.endtime>1281620460) AND NOT pages.t3ver_state>0 ' .
'AND pages.doktype<200 AND (pages.fe_group=\'\' OR pages.fe_group IS NULL OR ' .
'pages.fe_group=\'0\' OR FIND_IN_SET(\'0\',pages.fe_group) OR FIND_IN_SET(\'-1\',pages.fe_group))');
191 $expected =
'SELECT * FROM "pages" WHERE "pid" = 0 AND "pages"."deleted" = 0 AND "pages"."hidden" = 0 ' .
'AND "pages"."starttime" <= 1281620460 AND ("pages"."endtime" = 0 OR "pages"."endtime" > 1281620460) ' .
'AND NOT "pages"."t3ver_state" > 0 AND "pages"."doktype" < 200 AND ("pages"."fe_group" = \'\' ' .
'OR "pages"."fe_group" IS NULL OR "pages"."fe_group" = \'0\' OR \',\'||"pages"."fe_group"||\',\' LIKE \'%,0,%\' ' .
'OR \',\'||"pages"."fe_group"||\',\' LIKE \'%,-1,%\')';
202 $result = $this->subject->SELECTquery(
'uid',
'tt_content',
'pid=1',
'cruser_id',
'tstamp');
203 $expected =
'SELECT "uid" FROM "tt_content" WHERE "pid" = 1 GROUP BY "cruser_id" ORDER BY "tstamp"';
211 $result = $this->subject->TRUNCATEquery(
'be_users');
212 $expected =
'TRUNCATE TABLE "be_users"';
221 $result = $this->subject->SELECTquery(
'COUNT(DISTINCT pid)',
'tt_content',
'1=1');
222 $expected =
'SELECT COUNT(DISTINCT "pid") FROM "tt_content" WHERE 1 = 1';
232 $result = $this->subject->SELECTquery(
'*',
'tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local',
'1=1');
233 $expected =
'SELECT * FROM "tt_news_cat"';
234 $expected .=
' INNER JOIN "tt_news_cat_mm" ON "tt_news_cat"."uid"="tt_news_cat_mm"."uid_foreign"';
235 $expected .=
' INNER JOIN "tt_news" ON "tt_news"."uid"="tt_news_cat_mm"."uid_local"';
236 $expected .=
' WHERE 1 = 1';
245 $result = $this->subject->SELECTquery(
'COUNT(DISTINCT tx_dam.uid) AS count',
'tx_dam',
'tx_dam.pid IN (1) AND tx_dam.file_type IN (\'gif\',\'png\',\'jpg\',\'jpeg\') AND tx_dam.deleted = 0');
246 $expected =
'SELECT COUNT(DISTINCT "tx_dam"."uid") AS "count" FROM "tx_dam"';
247 $expected .=
' WHERE "tx_dam"."pid" IN (1) AND "tx_dam"."file_type" IN (\'gif\',\'png\',\'jpg\',\'jpeg\') AND "tx_dam"."deleted" = 0';
257 $result = $this->subject->SELECTquery(
'*',
'sys_refindex, tx_dam_file_tracking',
'sys_refindex.tablename = \'tx_dam_file_tracking\'' .
' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)');
258 $expected =
'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
259 $expected .=
' AND (instr(LOWER("sys_refindex"."ref_string"), concat("tx_dam_file_tracking"."file_path","tx_dam_file_tracking"."file_name"),1,1) > 0)';
268 $currentTime = time();
269 $result = $this->subject->SELECTquery(
'content',
'cache_hash',
'identifier = ' . $this->subject->fullQuoteStr(
'abbbabaf2d4b3f9a63e8dde781f1c106',
'cache_hash') .
' AND (crdate + lifetime >= ' . $currentTime .
' OR lifetime = 0)');
270 $expected =
'SELECT "content" FROM "cache_hash" WHERE "identifier" = \'abbbabaf2d4b3f9a63e8dde781f1c106\' AND ("crdate"+"lifetime" >= ' . $currentTime .
' OR "lifetime" = 0)';
279 $currentTime = time();
280 $result = $this->subject->SELECTquery(
'identifier',
'cachingframework_cache_pages',
'crdate + lifetime < ' . $currentTime .
' AND lifetime > 0');
281 $expected =
'SELECT "identifier" FROM "cachingframework_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime .
' AND "lifetime" > 0';
289 $result = $this->subject->SELECTquery(
'1',
'be_users',
'username = \'_cli_scheduler\' AND admin = 0 AND be_users.deleted = 0');
290 $expected =
'SELECT 1 FROM "be_users" WHERE "username" = \'_cli_scheduler\' AND "admin" = 0 AND "be_users"."deleted" = 0';
304 $fromTables =
'tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local';
305 $whereClause =
'1=1';
308 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
310 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
311 $expected =
'SELECT * FROM "ext_tt_news_cat"';
312 $expected .=
' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat"."cat_uid"="ext_tt_news_cat_mm"."uid_foreign"';
313 $expected .=
' INNER JOIN "ext_tt_news" ON "ext_tt_news"."news_uid"="ext_tt_news_cat_mm"."local_uid"';
314 $expected .=
' WHERE 1 = 1';
323 $handlerMock = $this->getMock(
'\ADODB_mock', array(
'MetaTables'), array(),
'', FALSE);
324 $handlerMock->expects($this->any())->method(
'MetaTables')->will($this->returnValue(array(
'cf_cache_hash')));
325 $this->subject->handlerInstance[
'_DEFAULT'] = $handlerMock;
327 $actual = $this->subject->admin_get_tables();
328 $expected = array(
'cachingframework_cache_hash' => array(
'Name' =>
'cachingframework_cache_hash'));
329 $this->assertSame($expected, $actual);
337 $selectFields =
'tstamp, script, SUM(exec_time) AS calc_sum, COUNT(*) AS qrycount, MAX(errorFlag) AS error';
338 $fromTables =
'tx_dbal_debuglog';
339 $whereClause =
'1=1';
342 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
344 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
345 $expected =
'SELECT "tstamp", "script", SUM("exec_time") AS "calc_sum", COUNT(*) AS "qrycount", MAX("errorflag") AS "error" FROM "tx_dbal_debuglog" WHERE 1 = 1';
354 $selectFields =
'MAX(tt_news_cat.uid) AS biggest_id';
355 $fromTables =
'tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign';
356 $whereClause =
'tt_news_cat_mm.uid_local > 50';
359 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
361 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
362 $expected =
'SELECT MAX("ext_tt_news_cat"."cat_uid") AS "biggest_id" FROM "ext_tt_news_cat"';
363 $expected .=
' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat"."cat_uid"="ext_tt_news_cat_mm"."uid_foreign"';
364 $expected .=
' WHERE "ext_tt_news_cat_mm"."local_uid" > 50';
375 $fromTables =
'sys_refindex, tx_dam_file_tracking';
376 $whereClause =
'sys_refindex.tablename = \'tx_dam_file_tracking\'' .
' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)';
379 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
381 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
382 $expected =
'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
383 $expected .=
' AND (instr(LOWER("sys_refindex"."ref_string"), concat("tx_dam_file_tracking"."path","tx_dam_file_tracking"."filename"),1,1) > 0)';
392 $selectFields =
'cpg_categories.uid, cpg_categories.name';
393 $fromTables =
'cpg_categories, pages';
394 $whereClause =
'pages.uid = cpg_categories.pid AND pages.deleted = 0 AND 1 = 1';
396 $orderBy =
'cpg_categories.pos';
397 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
399 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
400 $expected =
'SELECT "cpg_categories"."uid", "cpg_categories"."name" FROM "cpg_categories", "my_pages" WHERE "my_pages"."page_uid" = "cpg_categories"."page_id"';
401 $expected .=
' AND "my_pages"."deleted" = 0 AND 1 = 1 ORDER BY "cpg_categories"."pos"';
410 $selectFields =
'news.uid';
411 $fromTables =
'tt_news AS news';
412 $whereClause =
'news.uid = 1';
415 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
417 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
418 $expected =
'SELECT "news"."news_uid" FROM "ext_tt_news" AS "news" WHERE "news"."news_uid" = 1';
430 $selectFields =
'tt_news_cat.uid';
431 $fromTables =
'tt_news AS tt_news_cat';
432 $whereClause =
'tt_news_cat.uid = 1';
435 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
437 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
438 $expected =
'SELECT "tt_news_cat"."news_uid" FROM "ext_tt_news" AS "tt_news_cat" WHERE "tt_news_cat"."news_uid" = 1';
447 $selectFields =
'cat.uid, cat_mm.uid_local, news.uid';
448 $fromTables =
'tt_news_cat AS cat' .
' INNER JOIN tt_news_cat_mm AS cat_mm ON cat.uid = cat_mm.uid_foreign' .
' INNER JOIN tt_news AS news ON news.uid = cat_mm.uid_local';
449 $whereClause =
'1=1';
452 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
454 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
455 $expected =
'SELECT "cat"."cat_uid", "cat_mm"."local_uid", "news"."news_uid"';
456 $expected .=
' FROM "ext_tt_news_cat" AS "cat"';
457 $expected .=
' INNER JOIN "ext_tt_news_cat_mm" AS "cat_mm" ON "cat"."cat_uid"="cat_mm"."uid_foreign"';
458 $expected .=
' INNER JOIN "ext_tt_news" AS "news" ON "news"."news_uid"="cat_mm"."local_uid"';
459 $expected .=
' WHERE 1 = 1';
469 $selectFields =
'foo.uid';
470 $fromTables =
'tt_news AS foo INNER JOIN tt_news_cat_mm ON tt_news_cat_mm.uid_local = foo.uid';
471 $whereClause =
'tt_news_cat_mm.uid_foreign IN (SELECT foo.uid FROM tt_news_cat AS foo WHERE foo.hidden = 0)';
473 $orderBy =
'foo.uid';
474 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
475 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
476 $expected =
'SELECT "foo"."news_uid" FROM "ext_tt_news" AS "foo"';
477 $expected .=
' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat_mm"."local_uid"="foo"."news_uid"';
478 $expected .=
' WHERE "ext_tt_news_cat_mm"."uid_foreign" IN (';
479 $expected .=
'SELECT "foo"."cat_uid" FROM "ext_tt_news_cat" AS "foo" WHERE "foo"."hidden" = 0';
481 $expected .=
' ORDER BY "foo"."news_uid"';
490 $selectFields =
'foo.uid';
491 $fromTables =
'tt_news AS foo INNER JOIN tt_news_cat_mm ON tt_news_cat_mm.uid_local = foo.uid';
492 $whereClause =
'EXISTS (SELECT foo.uid FROM tt_news_cat AS foo WHERE foo.hidden = 0)';
494 $orderBy =
'foo.uid';
495 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
496 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
497 $expected =
'SELECT "foo"."news_uid" FROM "ext_tt_news" AS "foo"';
498 $expected .=
' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat_mm"."local_uid"="foo"."news_uid"';
499 $expected .=
' WHERE EXISTS (';
500 $expected .=
'SELECT "foo"."cat_uid" FROM "ext_tt_news_cat" AS "foo" WHERE "foo"."hidden" = 0';
502 $expected .=
' ORDER BY "foo"."news_uid"';
511 $selectFields =
'foo.uid';
512 $fromTables =
'tt_news AS foo';
513 $whereClause =
'uid IN (' .
'SELECT foobar.uid_local FROM tt_news_cat_mm AS foobar WHERE uid_foreign IN (' .
'SELECT uid FROM tt_news_cat WHERE deleted = 0' .
'))';
516 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
518 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
519 $expected =
'SELECT "foo"."news_uid" FROM "ext_tt_news" AS "foo"';
520 $expected .=
' WHERE "news_uid" IN (';
521 $expected .=
'SELECT "foobar"."local_uid" FROM "ext_tt_news_cat_mm" AS "foobar" WHERE "uid_foreign" IN (';
522 $expected .=
'SELECT "cat_uid" FROM "ext_tt_news_cat" WHERE "deleted" = 0';
533 $selectFields =
'pages.uid';
534 $fromTables =
'tt_news AS pages INNER JOIN tt_news_cat_mm AS cat_mm ON cat_mm.uid_local = pages.uid';
535 $whereClause =
'pages.pid IN (SELECT uid FROM pages WHERE deleted = 0 AND cat_mm.uid_local != 100)';
537 $orderBy =
'pages.uid';
538 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
540 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
541 $expected =
'SELECT "pages"."news_uid" FROM "ext_tt_news" AS "pages"';
542 $expected .=
' INNER JOIN "ext_tt_news_cat_mm" AS "cat_mm" ON "cat_mm"."local_uid"="pages"."news_uid"';
543 $expected .=
' WHERE "pages"."pid" IN (';
544 $expected .=
'SELECT "page_uid" FROM "my_pages" WHERE "deleted" = 0 AND "cat_mm"."local_uid" != 100';
546 $expected .=
' ORDER BY "pages"."news_uid"';
555 $this->subject->cache_fieldType[
'tt_content'][
'bodytext'][
'metaType'] =
'B';
556 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'tt_content.bodytext LIKE \'foo%\'');
557 $expected =
'SELECT * FROM "tt_content" WHERE (dbms_lob.instr(LOWER("tt_content"."bodytext"), \'foo\',1,1) > 0)';
566 $this->subject->cache_fieldType[
'tt_content'][
'bodytext'][
'metaType'] =
'B';
567 $result = $this->subject->SELECTquery(
'*',
'fe_users',
'fe_users.usergroup LIKE \'2\'');
568 $expected =
'SELECT * FROM "fe_users" WHERE (instr(LOWER("fe_users"."usergroup"), \'2\',1,1) > 0)';
577 $this->subject->cache_fieldType[
'tt_content'][
'bodytext'][
'metaType'] =
'B';
578 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'tt_content.bodytext NOT LIKE \'foo%\'');
579 $expected =
'SELECT * FROM "tt_content" WHERE NOT (dbms_lob.instr(LOWER("tt_content"."bodytext"), \'foo\',1,1) > 0)';
588 $this->subject->cache_fieldType[
'tt_content'][
'bodytext'][
'metaType'] =
'B';
589 $result = $this->subject->SELECTquery(
'*',
'fe_users',
'fe_users.usergroup NOT LIKE \'2\'');
590 $expected =
'SELECT * FROM "fe_users" WHERE NOT (instr(LOWER("fe_users"."usergroup"), \'2\',1,1) > 0)';
599 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'uid IN (62) AND tt_content.deleted=0 AND tt_content.t3ver_state<=0' .
' AND tt_content.hidden=0 AND (tt_content.starttime<=1264487640)' .
' AND (tt_content.endtime=0 OR tt_content.endtime>1264487640)' .
' AND (tt_content.fe_group=\'\' OR tt_content.fe_group IS NULL OR tt_content.fe_group=\'0\'' .
' OR (tt_content.fe_group LIKE \'%,0,%\' OR tt_content.fe_group LIKE \'0,%\' OR tt_content.fe_group LIKE \'%,0\'' .
' OR tt_content.fe_group=\'0\')' .
' OR (tt_content.fe_group LIKE\'%,-1,%\' OR tt_content.fe_group LIKE \'-1,%\' OR tt_content.fe_group LIKE \'%,-1\'' .
' OR tt_content.fe_group=\'-1\'))');
600 $expected =
'SELECT * FROM "tt_content"';
601 $expected .=
' WHERE "uid" IN (62) AND "tt_content"."deleted" = 0 AND "tt_content"."t3ver_state" <= 0';
602 $expected .=
' AND "tt_content"."hidden" = 0 AND ("tt_content"."starttime" <= 1264487640)';
603 $expected .=
' AND ("tt_content"."endtime" = 0 OR "tt_content"."endtime" > 1264487640)';
604 $expected .=
' AND ("tt_content"."fe_group" = \'\' OR "tt_content"."fe_group" IS NULL OR "tt_content"."fe_group" = \'0\'';
605 $expected .=
' OR ((instr(LOWER("tt_content"."fe_group"), \',0,\',1,1) > 0)';
606 $expected .=
' OR (instr(LOWER("tt_content"."fe_group"), \'0,\',1,1) > 0)';
607 $expected .=
' OR (instr(LOWER("tt_content"."fe_group"), \',0\',1,1) > 0)';
608 $expected .=
' OR "tt_content"."fe_group" = \'0\')';
609 $expected .=
' OR ((instr(LOWER("tt_content"."fe_group"), \',-1,\',1,1) > 0)';
610 $expected .=
' OR (instr(LOWER("tt_content"."fe_group"), \'-1,\',1,1) > 0)';
611 $expected .=
' OR (instr(LOWER("tt_content"."fe_group"), \',-1\',1,1) > 0)';
612 $expected .=
' OR "tt_content"."fe_group" = \'-1\'))';
625 CREATE TABLE tx_realurl_uniqalias ( 626 uid int(11) NOT NULL auto_increment, 627 tstamp int(11) DEFAULT \'0\' NOT NULL, 628 tablename varchar(60) DEFAULT \'\' NOT NULL, 629 field_alias varchar(255) DEFAULT \'\' NOT NULL, 630 field_id varchar(60) DEFAULT \'\' NOT NULL, 631 value_alias varchar(255) DEFAULT \'\' NOT NULL, 632 value_id int(11) DEFAULT \'0\' NOT NULL, 633 lang int(11) DEFAULT \'0\' NOT NULL, 634 expire int(11) DEFAULT \'0\' NOT NULL, 637 KEY tablename (tablename), 638 KEY bk_realurl01 (field_alias,field_id,value_id,lang,expire), 639 KEY bk_realurl02 (tablename,field_alias,field_id,value_alias(220),expire) 642 $components = $this->subject->SQLparser->_callRef(
'parseCREATETABLE', $parseString);
643 $this->assertTrue(is_array($components),
'Not an array: ' . $components);
644 $sqlCommands = $this->subject->SQLparser->_call(
'compileCREATETABLE', $components);
645 $this->assertTrue(is_array($sqlCommands),
'Not an array: ' . $sqlCommands);
646 $this->assertEquals(6, count($sqlCommands));
648 CREATE TABLE "tx_realurl_uniqalias" ( 649 "uid" NUMBER(20) NOT NULL, 650 "tstamp" NUMBER(20) DEFAULT 0, 651 "tablename" VARCHAR(60) DEFAULT \'\', 652 "field_alias" VARCHAR(255) DEFAULT \'\', 653 "field_id" VARCHAR(60) DEFAULT \'\', 654 "value_alias" VARCHAR(255) DEFAULT \'\', 655 "value_id" NUMBER(20) DEFAULT 0, 656 "lang" NUMBER(20) DEFAULT 0, 657 "expire" NUMBER(20) DEFAULT 0, 661 $this->assertEquals($expected, $this->
cleanSql($sqlCommands[0]));
671 CREATE TABLE tx_test ( 672 uid int(11) NOT NULL auto_increment, 673 lastname varchar(60) DEFAULT \'unknown\' NOT NULL, 674 firstname varchar(60) DEFAULT \'\' NOT NULL, 675 language varchar(2) NOT NULL, 676 tstamp int(11) DEFAULT \'0\' NOT NULL, 682 $components = $this->subject->SQLparser->_callRef(
'parseCREATETABLE', $parseString);
683 $this->assertTrue(is_array($components),
'Not an array: ' . $components);
684 $sqlCommands = $this->subject->SQLparser->_call(
'compileCREATETABLE', $components);
685 $this->assertTrue(is_array($sqlCommands),
'Not an array: ' . $sqlCommands);
686 $this->assertEquals(4, count($sqlCommands));
688 CREATE TABLE "tx_test" ( 689 "uid" NUMBER(20) NOT NULL, 690 "lastname" VARCHAR(60) DEFAULT \'unknown\', 691 "firstname" VARCHAR(60) DEFAULT \'\', 692 "language" VARCHAR(2) DEFAULT \'\', 693 "tstamp" NUMBER(20) DEFAULT 0, 697 $this->assertEquals($expected, $this->
cleanSql($sqlCommands[0]));
708 $result = $this->subject->SELECTquery(
'*',
'tx_crawler_queue',
'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)');
709 $expected =
'SELECT * FROM "tx_crawler_queue" WHERE "process_id" IN (SELECT "process_id" FROM "tx_crawler_process" WHERE "active" = 0 AND "deleted" = 0)';
719 $fromTables =
'tx_crawler_queue';
720 $whereClause =
'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)';
723 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
724 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
725 $expected =
'SELECT * FROM "tx_crawler_queue" WHERE "process_id" IN (SELECT "ps_id" FROM "tx_crawler_ps" WHERE "is_active" = 0 AND "deleted" = 0)';
734 $currentTime = time();
735 $result = $this->subject->DELETEquery(
'cachingframework_cache_hash_tags',
'identifier IN (' . $this->subject->SELECTsubquery(
'identifier',
'cachingframework_cache_pages', (
'crdate + lifetime < ' . $currentTime .
' AND lifetime > 0')) .
')');
736 $expected =
'DELETE FROM "cachingframework_cache_hash_tags" WHERE "identifier" IN (';
737 $expected .=
'SELECT "identifier" FROM "cachingframework_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime .
' AND "lifetime" > 0';
747 $currentTime = time();
748 $table =
'cachingframework_cache_hash_tags';
749 $where =
'identifier IN (' . $this->subject->SELECTsubquery(
'identifier',
'cachingframework_cache_pages', (
'crdate + lifetime < ' . $currentTime .
' AND lifetime > 0')) .
')';
752 $tableArray = $this->subject->_call(
'map_needMapping', $table);
754 $whereParts = $this->subject->SQLparser->parseWhereClause($where);
755 $this->subject->_callRef(
'map_sqlParts', $whereParts, $tableArray[0][
'table']);
756 $where = $this->subject->SQLparser->compileWhereClause($whereParts, FALSE);
758 if ($this->subject->mapping[$table][
'mapTableName']) {
759 $table = $this->subject->mapping[$table][
'mapTableName'];
762 $result = $this->subject->DELETEquery($table, $where);
763 $expected =
'DELETE FROM "cf_cache_hash_tags" WHERE "identifier" IN (';
764 $expected .=
'SELECT "identifier" FROM "cf_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime .
' AND "lifetime" > 0';
774 $result = $this->subject->SELECTquery(
'*',
'tx_crawler_process',
'active = 0 AND NOT EXISTS (' . $this->subject->SELECTsubquery(
'*',
'tx_crawler_queue',
'tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)') .
')');
775 $expected =
'SELECT * FROM "tx_crawler_process" WHERE "active" = 0 AND NOT EXISTS (';
776 $expected .=
'SELECT * FROM "tx_crawler_queue" WHERE "tx_crawler_queue"."process_id" = "tx_crawler_process"."process_id" AND "tx_crawler_queue"."exec_time" = 0';
787 $fromTables =
'tx_crawler_process';
788 $whereClause =
'active = 0 AND NOT EXISTS (' . $this->subject->SELECTsubquery(
'*',
'tx_crawler_queue',
'tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0') .
')';
791 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
793 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
794 $expected =
'SELECT * FROM "tx_crawler_ps" WHERE "is_active" = 0 AND NOT EXISTS (';
795 $expected .=
'SELECT * FROM "tx_crawler_queue" WHERE "tx_crawler_queue"."process_id" = "tx_crawler_ps"."ps_id" AND "tx_crawler_queue"."exec_time" = 0';
808 $result = $this->subject->SELECTquery(
'process_id, CASE active' .
' WHEN 1 THEN ' . $this->subject->fullQuoteStr(
'one',
'tx_crawler_process') .
' WHEN 2 THEN ' . $this->subject->fullQuoteStr(
'two',
'tx_crawler_process') .
' ELSE ' . $this->subject->fullQuoteStr(
'out of range',
'tx_crawler_process') .
' END AS number',
'tx_crawler_process',
'1=1');
809 $expected =
'SELECT "process_id", CASE "active" WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS "number" FROM "tx_crawler_process" WHERE 1 = 1';
819 $selectFields =
'process_id, CASE active' .
' WHEN 1 THEN ' . $this->subject->fullQuoteStr(
'one',
'tx_crawler_process') .
' WHEN 2 THEN ' . $this->subject->fullQuoteStr(
'two',
'tx_crawler_process') .
' ELSE ' . $this->subject->fullQuoteStr(
'out of range',
'tx_crawler_process') .
' END AS number';
820 $fromTables =
'tx_crawler_process';
821 $whereClause =
'1=1';
824 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
826 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
827 $expected =
'SELECT "ps_id", CASE "is_active" WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS "number" ';
828 $expected .=
'FROM "tx_crawler_ps" WHERE 1 = 1';
837 $selectFields =
'process_id, CASE tt_news.uid' .
' WHEN 1 THEN ' . $this->subject->fullQuoteStr(
'one',
'tt_news') .
' WHEN 2 THEN ' . $this->subject->fullQuoteStr(
'two',
'tt_news') .
' ELSE ' . $this->subject->fullQuoteStr(
'out of range',
'tt_news') .
' END AS number';
838 $fromTables =
'tx_crawler_process, tt_news';
839 $whereClause =
'1=1';
842 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
844 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
845 $expected =
'SELECT "ps_id", CASE "ext_tt_news"."news_uid" WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS "number" ';
846 $expected .=
'FROM "tx_crawler_ps", "ext_tt_news" WHERE 1 = 1';
855 $result = $this->subject->SELECTquery(
'*, CASE WHEN' .
' LOCATE(' . $this->subject->fullQuoteStr(
'(fce)',
'tx_templavoila_tmplobj') .
', datastructure)>0 THEN 2' .
' ELSE 1' .
' END AS scope',
'tx_templavoila_tmplobj',
'1=1');
856 $expected =
'SELECT *, CASE WHEN INSTR("datastructure", \'(fce)\') > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
865 $result = $this->subject->SELECTquery(
'*, CASE WHEN' .
' LOCATE(' . $this->subject->fullQuoteStr(
'(fce)',
'tx_templavoila_tmplobj') .
', datastructure, 4)>0 THEN 2' .
' ELSE 1' .
' END AS scope',
'tx_templavoila_tmplobj',
'1=1');
866 $expected =
'SELECT *, CASE WHEN INSTR("datastructure", \'(fce)\', 4) > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
875 $result = $this->subject->SELECTquery(
'*',
'tt_news_cat_mm',
'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)');
876 $expected =
'SELECT * FROM "tt_news_cat_mm" WHERE NVL("tt_news_cat_mm"."uid_foreign", 0) IN (21,22)';
885 $result = $this->subject->SELECTquery(
'*',
'fe_users',
'FIND_IN_SET(10, usergroup)');
886 $expected =
'SELECT * FROM "fe_users" WHERE \',\'||"usergroup"||\',\' LIKE \'%,10,%\'';
895 $selectFields =
'fe_group';
896 $fromTables =
'tt_news';
897 $whereClause =
'FIND_IN_SET(10, fe_group)';
900 $remappedParameters = $this->subject->_call(
'map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
902 $result = $this->subject->_call(
'SELECTqueryFromArray', $remappedParameters);
903 $expected =
'SELECT "usergroup" FROM "ext_tt_news" WHERE \',\'||"ext_tt_news"."usergroup"||\',\' LIKE \'%,10,%\'';
912 $result = $this->subject->SELECTquery(
'*',
'fe_users', $this->subject->listQuery(
'usergroup', 10,
'fe_users'));
913 $expected =
'SELECT * FROM "fe_users" WHERE \',\'||"usergroup"||\',\' LIKE \'%,10,%\'';
922 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'bodytext LIKE BINARY \'test\'');
923 $expected =
'SELECT * FROM "tt_content" WHERE (dbms_lob.instr("bodytext", \'test\',1,1) > 0)';
931 $listMaxExpressions = 1000;
933 $mockSpecificsOci8 = $this->
getAccessibleMock(
'TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(),
'', FALSE);
934 $mockSpecificsOci8->expects($this->any())->method(
'getSpecific')->will($this->returnValue($listMaxExpressions));
936 $items = range(0, 1250);
937 $where =
'uid NOT IN(' . implode(
',', $items) .
')';
938 $result = $this->subject->SELECTquery(
'*',
'tt_content', $where);
940 $chunks = array_chunk($items, $listMaxExpressions);
941 $whereExpr = array();
942 foreach ($chunks as $chunk) {
943 $whereExpr[] =
'"uid" NOT IN (' . implode(
',', $chunk) .
')';
953 $expectedWhere =
'(' . implode(
' AND ', $whereExpr) .
')';
954 $expectedQuery =
'SELECT * FROM "tt_content" WHERE ' . $expectedWhere;
962 $listMaxExpressions = 1000;
964 $mockSpecificsOci8 = $this->
getAccessibleMock(
'TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(),
'', FALSE);
965 $mockSpecificsOci8->expects($this->any())->method(
'getSpecific')->will($this->returnValue($listMaxExpressions));
967 $items = range(0, 1250);
968 $where =
'uid IN(' . implode(
',', $items) .
')';
969 $result = $this->subject->SELECTquery(
'*',
'tt_content', $where);
971 $chunks = array_chunk($items, $listMaxExpressions);
972 $whereExpr = array();
973 foreach ($chunks as $chunk) {
974 $whereExpr[] =
'"uid" IN (' . implode(
',', $chunk) .
')';
984 $expectedWhere =
'(' . implode(
' OR ', $whereExpr) .
')';
985 $expectedQuery =
'SELECT * FROM "tt_content" WHERE ' . $expectedWhere;
993 $listMaxExpressions = 1000;
995 $mockSpecificsOci8 = $this->
getAccessibleMock(
'TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(),
'', FALSE);
996 $mockSpecificsOci8->expects($this->any())->method(
'getSpecific')->will($this->returnValue($listMaxExpressions));
998 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'uid IN (0,1,2,3,4,5,6,7,8,9,10)');
1000 $expectedQuery =
'SELECT * FROM "tt_content" WHERE "uid" IN (0,1,2,3,4,5,6,7,8,9,10)';
1008 $listMaxExpressions = 1000;
1010 $mockSpecificsOci8 = $this->
getAccessibleMock(
'TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(),
'', FALSE);
1011 $mockSpecificsOci8->expects($this->any())->method(
'getSpecific')->will($this->returnValue($listMaxExpressions));
1013 $items = range(0, 1250);
1014 $where =
'uid = 1981 AND uid IN(' . implode(
',', $items) .
') OR uid = 42';
1015 $result = $this->subject->SELECTquery(
'uid, pid',
'tt_content', $where);
1017 $chunks = array_chunk($items, $listMaxExpressions);
1018 $whereExpr = array();
1019 foreach ($chunks as $chunk) {
1020 $whereExpr[] =
'"uid" IN (' . implode(
',', $chunk) .
')';
1030 $expectedWhere =
'"uid" = 1981 AND (' . implode(
' OR ', $whereExpr) .
') OR "uid" = 42';
1031 $expectedQuery =
'SELECT "uid", "pid" FROM "tt_content" WHERE ' . $expectedWhere;
1039 $listMaxExpressions = 1000;
1041 $mockSpecificsOci8 = $this->
getAccessibleMock(
'TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(),
'', FALSE);
1042 $mockSpecificsOci8->expects($this->any())->method(
'getSpecific')->will($this->returnValue($listMaxExpressions));
1044 $INitems = range(0, 1250);
1045 $NOTINItems = range(0, 1001);
1046 $where =
'uid = 1981 AND uid IN(' . implode(
',', $INitems) .
') OR uid = 42 AND uid NOT IN(' . implode(
',', $NOTINItems) .
')';
1047 $result = $this->subject->SELECTquery(
'uid, pid',
'tt_content', $where);
1049 $chunks = array_chunk($INitems, $listMaxExpressions);
1050 $INItemsWhereExpr = array();
1051 foreach ($chunks as $chunk) {
1052 $INItemsWhereExpr[] =
'"uid" IN (' . implode(
',', $chunk) .
')';
1055 $chunks = array_chunk($NOTINItems, $listMaxExpressions);
1056 $NOTINItemsWhereExpr = array();
1057 foreach ($chunks as $chunk) {
1058 $NOTINItemsWhereExpr[] =
'"uid" NOT IN (' . implode(
',', $chunk) .
')';
1071 $expectedWhere =
'"uid" = 1981 AND (' . implode(
' OR ', $INItemsWhereExpr) .
') OR "uid" = 42 AND (' . implode(
' AND ', $NOTINItemsWhereExpr) .
')';
1072 $expectedQuery =
'SELECT "uid", "pid" FROM "tt_content" WHERE ' . $expectedWhere;
tablesAndFieldsAreRemappedInMultipleJoins()
concatAfterLikeOperatorIsProperlyQuoted()
caseStatementWithExternalTableIsProperlyRemapped()
expressionListBracesAreSetCorrectly()
locateStatementWithPositionIsProperlyQuoted()
concatAfterLikeOperatorIsRemapped()
truncateQueryIsProperlyQuoted()
likeIsRemappedAccordingToFieldTypeWithInteger()
notLikeIsRemappedAccordingToFieldTypeWithString()
tableAndFieldWithinSqlFunctionIsRemapped()
aliasRemappingSupportsNestedSubqueries()
runningADOdbDriverReturnsTrueWithOci8ForOci8DefaultDriverConfiguration()
multipleExpressiosInWhereClauseAreBracedCorrectly()
expressionListWithNotInIsConcatenatedWithAnd()
calculatedFieldsAreProperlyQuoted()
likeBinaryOperatorIsRemoved()
expressionListWithInIsConcatenatedWithOr()
cachingFrameworkQueryIsRemapped()
caseStatementIsProperlyRemapped()
stringsWithinInClauseAreProperlyQuoted()
aliasRemappingWithExistsSubqueryDoesNotAffectMainQuery()
fieldFromAliasIsRemappedWithoutBeingTricked()
canCompileInsertWithFields()
groupConditionsAreProperlyTransformed()
caseStatementIsProperlyQuoted()
remappingDoesNotMixUpAliasesInSubquery()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
likeIsRemappedAccordingToFieldTypeWithString()
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
fieldFromAliasIsRemapped()
defaultValueIsProperlyQuotedInCreateTable()
IfNullIsProperlyRemapped()
distinctFieldIsProperlyQuoted()
existsWhereClauseIsProperlyQuoted()
aliasRemappingWithInSubqueryDoesNotAffectMainQuery()
listQueryIsProperlyRemapped()
numericColumnsAreNotQuoted()
sqlForInsertWithMultipleRowsIsValid()
locateStatementIsProperlyQuoted()
findInSetIsProperlyRemapped()
canCompileExtendedInsert()
fieldIsMappedOnRightSideOfAJoinCondition()
cachingFrameworkQueryIsProperlyQuoted()
fieldFromAliasInJoinIsRemapped()
findInSetFieldIsProperlyRemapped()
selectQueryIsProperlyQuoted()
notNullableColumnsWithDefaultEmptyStringAreCreatedAsNullable()
subqueryIsRemappedForExistsWhereClause()
cachingFrameworkQueryIsSupported()
tablesAreUnmappedInAdminGetTables()
multipleInnerJoinsAreProperlyQuoted()
notLikeIsRemappedAccordingToFieldTypeWithInteger()
inWhereClauseWithSubqueryIsProperlyQuoted()
subqueryIsRemappedForInWhereClause()
expressionListIsUnchanged()
fieldWithinSqlFunctionIsRemapped()
instrIsUsedForCEOnPages()