Esempio n. 1
0
 /**
  * Gets additional fields to render in the form to add/edit a task
  *
  * @param array $taskInfo Values of the fields from the add/edit task form
  * @param \TYPO3\CMS\Recycler\Task\CleanerTask $task The task object being edited. NULL when adding a task!
  * @param SchedulerModuleController $schedulerModule Reference to the scheduler backend module
  * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => ''))
  */
 public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
 {
     if ($schedulerModule->CMD === 'edit') {
         $taskInfo['RecyclerCleanerTCA'] = $task->getTcaTables();
         $taskInfo['RecyclerCleanerPeriod'] = $task->getPeriod();
     }
     $additionalFields['period'] = ['code' => '<input type="text" class="form-control" name="tx_scheduler[RecyclerCleanerPeriod]" value="' . $taskInfo['RecyclerCleanerPeriod'] . '">', 'label' => 'LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskPeriod', 'cshKey' => '', 'cshLabel' => 'task_recyclerCleaner_selectedPeriod'];
     $additionalFields['tca'] = ['code' => $this->getTcaSelectHtml($taskInfo['RecyclerCleanerTCA']), 'label' => 'LLL:EXT:recycler/Resources/Private/Language/locallang_tasks.xlf:cleanerTaskTCA', 'cshKey' => '', 'cshLabel' => 'task_recyclerCleaner_selectedTables'];
     return $additionalFields;
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function taskFailsOnError()
 {
     $GLOBALS['TCA']['pages']['ctrl']['delete'] = 'deleted';
     $GLOBALS['TCA']['pages']['ctrl']['tstamp'] = 'tstamp';
     $tables = array('pages');
     $this->subject->setTcaTables($tables);
     $period = 14;
     $this->subject->setPeriod($period);
     $dbMock = $this->getMock(DatabaseConnection::class);
     $dbMock->expects($this->once())->method('sql_error')->willReturn(1049);
     $this->subject->setDatabaseConnection($dbMock);
     $this->assertFalse($this->subject->execute());
 }
 /**
  * @test
  */
 public function taskFailsOnError()
 {
     $GLOBALS['TCA']['pages']['ctrl']['delete'] = 'deleted';
     $GLOBALS['TCA']['pages']['ctrl']['tstamp'] = 'tstamp';
     $this->subject->setTcaTables(['pages']);
     /** @var Connection|ObjectProphecy $connection */
     $connection = $this->prophesize(Connection::class);
     $connection->getDatabasePlatform()->willReturn(new MockPlatform());
     $connection->getExpressionBuilder()->willReturn(new ExpressionBuilder($connection->reveal()));
     $connection->quoteIdentifier(Argument::cetera())->willReturnArgument(0);
     $queryBuilder = GeneralUtility::makeInstance(QueryBuilder::class, $connection->reveal(), null, new \Doctrine\DBAL\Query\QueryBuilder($connection->reveal()));
     $connectionPool = $this->prophesize(ConnectionPool::class);
     $connectionPool->getQueryBuilderForTable('pages')->willReturn($queryBuilder);
     GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
     $connection->executeUpdate(Argument::cetera())->shouldBeCalled()->willThrow(new \Doctrine\DBAL\DBALException());
     $this->assertFalse($this->subject->execute());
 }