/** * @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()); }