‪TYPO3CMS  10.4
CleanerTaskTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
26 class ‪CleanerTaskTest extends FunctionalTestCase
27 {
28  protected ‪$coreExtensionsToLoad = ['recycler', 'scheduler'];
29 
33  public function ‪taskRemovesDeletedPages()
34  {
35  $this->importCSVDataSet(__DIR__ . '/DataSet/Fixtures/pages.csv');
36  $subject = new ‪CleanerTask();
37  $subject->setTcaTables(['pages']);
38  $result = $subject->execute();
39  $this->assertCSVDataSet('typo3/sysext/recycler/Tests/Functional/Task/Pages/DataSet/Assertion/pages_deleted.csv');
40  self::assertTrue($result);
41  }
42 
47  {
48  $this->importCSVDataSet(__DIR__ . '/DataSet/Fixtures/pages.csv');
49  $subject = new ‪CleanerTask();
50  $subject->setTcaTables(['pages']);
51 
52  // this is when the test was created. One of the fixtures (uid 4) has this date
53  $creationDate = date_create_immutable_from_format('d.m.Y', '28.09.2020')->setTime(0, 0, 0);
54  // we want to set the period in a way that older records get deleted, but not the one created today
55  $difference = $creationDate->diff(new \DateTime(), true);
56  // let's set the amount of days one higher than the reference date
57  $period = (int)$difference->format('%a') + 1;
58  $subject->setPeriod($period);
59  $result = $subject->execute();
60  $this->assertCSVDataSet('typo3/sysext/recycler/Tests/Functional/Task/Pages/DataSet/Assertion/pages_deleted_with_period.csv');
61  self::assertTrue($result);
62  }
63 
67  public function ‪taskFailsOnError()
68  {
69  $subject = new ‪CleanerTask();
70  ‪$GLOBALS['TCA']['not_existing_table']['ctrl']['delete'] = 'deleted';
71  $subject->setTcaTables(['not_existing_table']);
72  $result = $subject->execute();
73  self::assertFalse($result);
74  }
75 }
‪TYPO3\CMS\Recycler\Tests\Functional\Task\Pages\CleanerTaskTest\taskRemovesDeletedPages
‪taskRemovesDeletedPages()
Definition: CleanerTaskTest.php:33
‪TYPO3\CMS\Recycler\Tests\Functional\Task\Pages\CleanerTaskTest\taskRemovesOnlyPagesLongerDeletedThanPeriod
‪taskRemovesOnlyPagesLongerDeletedThanPeriod()
Definition: CleanerTaskTest.php:46
‪TYPO3\CMS\Recycler\Task\CleanerTask
Definition: CleanerTask.php:29
‪TYPO3\CMS\Recycler\Tests\Functional\Task\Pages\CleanerTaskTest\taskFailsOnError
‪taskFailsOnError()
Definition: CleanerTaskTest.php:67
‪TYPO3\CMS\Recycler\Tests\Functional\Task\Pages
Definition: CleanerTaskTest.php:18
‪TYPO3\CMS\Recycler\Tests\Functional\Task\Pages\CleanerTaskTest\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: CleanerTaskTest.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Recycler\Tests\Functional\Task\Pages\CleanerTaskTest
Definition: CleanerTaskTest.php:27