2 namespace TYPO3\CMS\Recycler\Tests\Unit\Task;
35 $this->subject = $this->getMock(CleanerTask::class, array(
'dummy'), array(),
'',
false);
44 $this->subject->setPeriod($period);
46 $this->assertEquals($period, $this->subject->getPeriod());
54 $tables = array(
'pages',
'tt_content');
55 $this->subject->setTcaTables($tables);
57 $this->assertEquals($tables, $this->subject->getTcaTables());
63 public function taskBuildsCorrectQuery()
65 $GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'delete'] =
'deleted';
66 $GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'tstamp'] =
'tstamp';
69 $subject = $this->getMock(CleanerTask::class, array(
'getPeriodAsTimestamp'), array(),
'',
false);
71 $tables = array(
'pages');
76 $periodAsTimestamp = strtotime(
'-' . $period .
' days');
77 $subject->expects($this->once())->method(
'getPeriodAsTimestamp')->willReturn($periodAsTimestamp);
79 $dbMock = $this->getMock(DatabaseConnection::class);
80 $dbMock->expects($this->once())
81 ->method(
'exec_DELETEquery')
82 ->with($this->equalTo(
'pages'), $this->equalTo(
'deleted = 1 AND tstamp < ' . $periodAsTimestamp));
84 $dbMock->expects($this->once())
86 ->will($this->returnValue(
''));
88 $subject->setDatabaseConnection($dbMock);
90 $this->assertTrue(
$subject->execute());
98 $GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'delete'] =
'deleted';
99 $GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'tstamp'] =
'tstamp';
101 $tables = array(
'pages');
102 $this->subject->setTcaTables($tables);
105 $this->subject->setPeriod($period);
107 $dbMock = $this->getMock(DatabaseConnection::class);
108 $dbMock->expects($this->once())
109 ->method(
'sql_error')
112 $this->subject->setDatabaseConnection($dbMock);
114 $this->assertFalse($this->subject->execute());