3666b9c685b6460b26262e12a3d2cc5b6b20d2dd
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Cache / Backend / Typo3DatabaseBackendTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 *
20 */
21 class Typo3DatabaseBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
22 {
23 /**
24 * Helper method to inject a mock frontend to backend instance
25 *
26 * @param \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend $backend Current backend instance
27 * @return \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface Mock frontend
28 */
29 protected function setUpMockFrontendOfBackend(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend $backend)
30 {
31 $mockCache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend::class, array(), array(), '', false);
32 $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('Testing'));
33 $backend->setCache($mockCache);
34 return $mockCache;
35 }
36
37 /**
38 * @test
39 */
40 public function setCacheCalculatesCacheTableName()
41 {
42 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
43 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
44 $this->setUpMockFrontendOfBackend($backend);
45 $this->assertEquals('cf_Testing', $backend->getCacheTable());
46 }
47
48 /**
49 * @test
50 */
51 public function setCacheCalculatesTagsTableName()
52 {
53 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
54 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
55 $this->setUpMockFrontendOfBackend($backend);
56 $this->assertEquals('cf_Testing_tags', $backend->getTagsTable());
57 }
58
59 /**
60 * @test
61 * @expectedException \TYPO3\CMS\Core\Cache\Exception
62 */
63 public function setThrowsExceptionIfFrontendWasNotSet()
64 {
65 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
66 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
67 $backend->set('identifier', 'data');
68 }
69
70 /**
71 * @test
72 * @expectedException \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
73 */
74 public function setThrowsExceptionIfDataIsNotAString()
75 {
76 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
77 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
78 $this->setUpMockFrontendOfBackend($backend);
79 $data = array('Some data');
80 $entryIdentifier = 'BackendDbTest';
81 $backend->set($entryIdentifier, $data);
82 }
83
84 /**
85 * @test
86 */
87 public function setInsertsEntryInTable()
88 {
89 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
90 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
91 $this->setUpMockFrontendOfBackend($backend);
92 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
93 $GLOBALS['TYPO3_DB']
94 ->expects($this->once())
95 ->method('exec_INSERTquery')
96 ->with('cf_Testing', $this->callback(function (array $data) {
97 if ($data['content'] !== 'someData') {
98 return false;
99 }
100 if ($data['identifier'] !== 'anIdentifier') {
101 return false;
102 }
103 return true;
104 }));
105 $backend->set('anIdentifier', 'someData');
106 }
107
108 /**
109 * @test
110 */
111 public function setRemovesAnAlreadyExistingCacheEntryForTheSameIdentifier()
112 {
113 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
114 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('remove'), array('Testing'));
115 $this->setUpMockFrontendOfBackend($backend);
116 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
117
118 $backend->expects($this->once())->method('remove');
119 $data = $this->getUniqueId('someData');
120 $entryIdentifier = 'anIdentifier';
121 $backend->set($entryIdentifier, $data, array(), 500);
122 }
123
124 /**
125 * @test
126 */
127 public function setReallySavesSpecifiedTags()
128 {
129 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
130 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
131 $this->setUpMockFrontendOfBackend($backend);
132 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
133 $GLOBALS['TYPO3_DB']
134 ->expects($this->once())
135 ->method('exec_INSERTmultipleRows')
136 ->with(
137 'cf_Testing_tags',
138 $this->callback(function (array $data) {
139 if ($data[0] === 'identifier' && $data[1] === 'tag') {
140 return true;
141 }
142 return false;
143 }),
144 $this->callback(function (array $data) {
145 if ($data[0][0] !== 'anIdentifier' || $data[0][1] !== 'UnitTestTag%tag1') {
146 return false;
147 }
148 if ($data[1][0] !== 'anIdentifier' || $data[1][1] !== 'UnitTestTag%tag2') {
149 return false;
150 }
151 return true;
152 })
153 );
154 $backend->set('anIdentifier', 'someData', array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
155 }
156
157 /**
158 * @test
159 */
160 public function setSavesCompressedDataWithEnabledCompression()
161 {
162 $backendOptions = array(
163 'compression' => true
164 );
165 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
166 $backend = $this->getMock(
167 \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class,
168 array('dummy'),
169 array('Testing', $backendOptions)
170 );
171 $this->setUpMockFrontendOfBackend($backend);
172
173 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
174 $GLOBALS['TYPO3_DB']
175 ->expects($this->once())
176 ->method('exec_INSERTquery')
177 ->with(
178 'cf_Testing',
179 $this->callback(function (array $data) {
180 if (@gzuncompress($data['content']) === 'someData') {
181 return true;
182 }
183 return false;
184 }
185 ));
186
187 $backend->set('anIdentifier', 'someData');
188 }
189
190 /**
191 * @test
192 */
193 public function setWithUnlimitedLifetimeWritesCorrectEntry()
194 {
195 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
196 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
197 $this->setUpMockFrontendOfBackend($backend);
198
199 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
200 $GLOBALS['TYPO3_DB']
201 ->expects($this->once())
202 ->method('exec_INSERTquery')
203 ->with(
204 'cf_Testing',
205 $this->callback(function (array $data) {
206 $lifetime = $data['expires'];
207 if ($lifetime > 2000000000) {
208 return true;
209 }
210 return false;
211 }
212 ));
213
214 $backend->set('aIdentifier', 'someData', array(), 0);
215 }
216
217 /**
218 * @test
219 * @expectedException \TYPO3\CMS\Core\Cache\Exception
220 */
221 public function getThrowsExceptionIfFrontendWasNotSet()
222 {
223 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
224 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
225 $backend->get('identifier');
226 }
227
228 /**
229 * @test
230 */
231 public function getReturnsContentOfTheCorrectCacheEntry()
232 {
233 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
234 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
235 $this->setUpMockFrontendOfBackend($backend);
236
237 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
238 $GLOBALS['TYPO3_DB']
239 ->expects($this->once())
240 ->method('exec_SELECTgetSingleRow')
241 ->with('content', 'cf_Testing', $this->anything())
242 ->will($this->returnValue(array('content' => 'someData')));
243
244 $loadedData = $backend->get('aIdentifier');
245 $this->assertEquals('someData', $loadedData);
246 }
247
248 /**
249 * @test
250 */
251 public function getSetsExceededLifetimeQueryPart()
252 {
253 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
254 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
255 $this->setUpMockFrontendOfBackend($backend);
256
257 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
258 $GLOBALS['TYPO3_DB']
259 ->expects($this->once())
260 ->method('exec_SELECTgetSingleRow')
261 ->with(
262 'content',
263 'cf_Testing',
264 $this->stringContains('identifier = AND cf_Testing.expires >=')
265 );
266
267 $backend->get('aIdentifier');
268 }
269
270 /**
271 * @test
272 * @expectedException \TYPO3\CMS\Core\Cache\Exception
273 */
274 public function hasThrowsExceptionIfFrontendWasNotSet()
275 {
276 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
277 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
278 $backend->has('identifier');
279 }
280
281 /**
282 * @test
283 */
284 public function hasReturnsTrueForExistingEntry()
285 {
286 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
287 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
288 $this->setUpMockFrontendOfBackend($backend);
289
290 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
291 $GLOBALS['TYPO3_DB']
292 ->expects($this->once())
293 ->method('exec_SELECTcountRows')
294 ->with('*', 'cf_Testing', $this->anything())
295 ->will($this->returnValue(1));
296
297 $this->assertTrue($backend->has('aIdentifier'));
298 }
299
300 /**
301 * @test
302 */
303 public function hasSetsExceededLifetimeQueryPart()
304 {
305 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
306 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
307 $this->setUpMockFrontendOfBackend($backend);
308
309 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
310 $GLOBALS['TYPO3_DB']
311 ->expects($this->once())
312 ->method('exec_SELECTcountRows')
313 ->with(
314 '*',
315 'cf_Testing',
316 $this->stringContains('identifier = AND cf_Testing.expires >='))
317 ->will($this->returnValue(1));
318
319 $this->assertTrue($backend->has('aIdentifier'));
320 }
321
322 /**
323 * @test
324 * @expectedException \TYPO3\CMS\Core\Cache\Exception
325 */
326 public function removeThrowsExceptionIfFrontendWasNotSet()
327 {
328 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
329 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
330 $backend->remove('identifier');
331 }
332
333 /**
334 * @test
335 */
336 public function removeReallyRemovesACacheEntry()
337 {
338 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
339 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
340 $this->setUpMockFrontendOfBackend($backend);
341
342 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
343 $GLOBALS['TYPO3_DB']
344 ->expects($this->at(0))
345 ->method('fullQuoteStr')
346 ->will($this->returnValue('aIdentifier'));
347 $GLOBALS['TYPO3_DB']
348 ->expects($this->at(1))
349 ->method('exec_DELETEquery')
350 ->with('cf_Testing', "identifier = aIdentifier");
351 $GLOBALS['TYPO3_DB']
352 ->expects($this->at(2))
353 ->method('fullQuoteStr')
354 ->will($this->returnValue('aIdentifier'));
355 $GLOBALS['TYPO3_DB']
356 ->expects($this->at(3))
357 ->method('exec_DELETEquery')
358 ->with('cf_Testing_tags', "identifier = aIdentifier");
359
360 $backend->remove('aIdentifier');
361 }
362
363 /**
364 * @test
365 * @expectedException \TYPO3\CMS\Core\Cache\Exception
366 */
367 public function collectGarbageThrowsExceptionIfFrontendWasNotSet()
368 {
369 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
370 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
371 $backend->collectGarbage();
372 }
373
374 /**
375 * @test
376 */
377 public function collectGarbageDeletesTagsFromExpiredEntries()
378 {
379 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
380 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
381 $this->setUpMockFrontendOfBackend($backend);
382
383 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
384 $GLOBALS['TYPO3_DB']
385 ->expects($this->at(1))
386 ->method('sql_fetch_assoc')
387 ->will($this->returnValue(array('identifier' => 'aIdentifier')));
388 $GLOBALS['TYPO3_DB']
389 ->expects($this->at(2))
390 ->method('fullQuoteStr')
391 ->will($this->returnValue('aIdentifier'));
392 $GLOBALS['TYPO3_DB']
393 ->expects($this->at(3))
394 ->method('sql_fetch_assoc')
395 ->will($this->returnValue(false));
396 $GLOBALS['TYPO3_DB']
397 ->expects($this->at(5))
398 ->method('exec_DELETEquery')
399 ->with('cf_Testing_tags', 'identifier IN (aIdentifier)');
400
401 $backend->collectGarbage();
402 }
403
404 /**
405 * @test
406 */
407 public function collectGarbageDeletesExpiredEntry()
408 {
409 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
410 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
411 $this->setUpMockFrontendOfBackend($backend);
412
413 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
414 $GLOBALS['TYPO3_DB']
415 ->expects($this->at(1))
416 ->method('sql_fetch_assoc')
417 ->will($this->returnValue(false));
418 $GLOBALS['TYPO3_DB']
419 ->expects($this->at(3))
420 ->method('exec_DELETEquery')
421 ->with('cf_Testing', $this->stringContains('cf_Testing.expires < '));
422
423 $backend->collectGarbage();
424 }
425
426 /**
427 * @test
428 * @expectedException \TYPO3\CMS\Core\Cache\Exception
429 */
430 public function findIdentifiersByTagThrowsExceptionIfFrontendWasNotSet()
431 {
432 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
433 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
434 $backend->findIdentifiersByTag('identifier');
435 }
436
437 /**
438 * @test
439 */
440 public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag()
441 {
442 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
443 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
444 $this->setUpMockFrontendOfBackend($backend);
445
446 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
447 $GLOBALS['TYPO3_DB']
448 ->expects($this->at(0))
449 ->method('fullQuoteStr')
450 ->will($this->returnValue('cf_Testing_tags'));
451 $GLOBALS['TYPO3_DB']
452 ->expects($this->at(1))
453 ->method('exec_SELECTgetRows')
454 ->with(
455 'cf_Testing.identifier',
456 'cf_Testing, cf_Testing_tags',
457 $this->stringContains('cf_Testing_tags.tag = cf_Testing_tags AND cf_Testing.identifier = cf_Testing_tags.identifier AND cf_Testing.expires >= '),
458 'cf_Testing.identifier'
459 )
460 ->will($this->returnValue(array(array('identifier' => 'aIdentifier'))));
461 $this->assertSame(array('aIdentifier' => 'aIdentifier'), $backend->findIdentifiersByTag('aTag'));
462 }
463
464 /**
465 * @test
466 * @expectedException \TYPO3\CMS\Core\Cache\Exception
467 */
468 public function flushThrowsExceptionIfFrontendWasNotSet()
469 {
470 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
471 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
472 $backend->flush();
473 }
474
475 /**
476 * @test
477 */
478 public function flushRemovesAllCacheEntries()
479 {
480 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
481 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
482 $this->setUpMockFrontendOfBackend($backend);
483
484 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
485 $GLOBALS['TYPO3_DB']
486 ->expects($this->at(0))
487 ->method('exec_TRUNCATEquery')
488 ->with('cf_Testing');
489 $GLOBALS['TYPO3_DB']
490 ->expects($this->at(1))
491 ->method('exec_TRUNCATEquery')
492 ->with('cf_Testing_tags');
493
494 $backend->flush();
495 }
496
497 /**
498 * @test
499 * @expectedException \TYPO3\CMS\Core\Cache\Exception
500 */
501 public function flushByTagThrowsExceptionIfFrontendWasNotSet()
502 {
503 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
504 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
505 $backend->flushByTag(array());
506 }
507
508 /**
509 * @test
510 */
511 public function flushByTagRemovesCacheEntriesWithSpecifiedTag()
512 {
513 /** @var \TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend|\PHPUnit_Framework_MockObject_MockObject $backend */
514 $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
515 $this->setUpMockFrontendOfBackend($backend);
516
517 $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
518 $GLOBALS['TYPO3_DB']
519 ->expects($this->at(0))
520 ->method('fullQuoteStr')
521 ->will($this->returnValue('UnitTestTag%special'));
522 $GLOBALS['TYPO3_DB']
523 ->expects($this->at(1))
524 ->method('exec_SELECTquery')
525 ->with(
526 'DISTINCT identifier',
527 'cf_Testing_tags',
528 'cf_Testing_tags.tag = UnitTestTag%special'
529 );
530 $GLOBALS['TYPO3_DB']
531 ->expects($this->at(2))
532 ->method('sql_fetch_assoc')
533 ->will($this->returnValue(array('identifier' => 'BackendDbTest1')));
534 $GLOBALS['TYPO3_DB']
535 ->expects($this->at(3))
536 ->method('fullQuoteStr')
537 ->with('BackendDbTest1', 'cf_Testing')
538 ->will($this->returnValue('BackendDbTest1'));
539 $GLOBALS['TYPO3_DB']
540 ->expects($this->at(4))
541 ->method('sql_fetch_assoc')
542 ->will($this->returnValue(array('identifier' => 'BackendDbTest2')));
543 $GLOBALS['TYPO3_DB']
544 ->expects($this->at(5))
545 ->method('fullQuoteStr')
546 ->with('BackendDbTest2', 'cf_Testing')
547 ->will($this->returnValue('BackendDbTest2'));
548 $GLOBALS['TYPO3_DB']
549 ->expects($this->at(6))
550 ->method('sql_fetch_assoc')
551 ->will($this->returnValue(false));
552 $GLOBALS['TYPO3_DB']
553 ->expects($this->at(7))
554 ->method('sql_free_result')
555 ->will($this->returnValue(true));
556 $GLOBALS['TYPO3_DB']
557 ->expects($this->at(8))
558 ->method('exec_DELETEquery')
559 ->with('cf_Testing', 'identifier IN (BackendDbTest1, BackendDbTest2)');
560 $GLOBALS['TYPO3_DB']
561 ->expects($this->at(9))
562 ->method('exec_DELETEquery')
563 ->with('cf_Testing_tags', 'identifier IN (BackendDbTest1, BackendDbTest2)');
564
565 $backend->flushByTag('UnitTestTag%special');
566 }
567 }