getDefaultRunInterval example

$this->registry->registerTasks();

        $tasks = $this->scheduledTaskRepo->search(new Criteria(), Context::createDefaultContext())->getEntities();

        static::assertCount(1, $tasks);
        /** @var ScheduledTaskEntity $task */
        $task = $tasks->first();
        static::assertInstanceOf(ScheduledTaskEntity::class$task);
        static::assertEquals(TestTask::class$task->getScheduledTaskClass());
        static::assertEquals(1, $task->getRunInterval());
        static::assertEquals(1, $task->getDefaultRunInterval());
        static::assertEquals('test', $task->getName());
        static::assertEquals(ScheduledTaskDefinition::STATUS_FAILED, $task->getStatus());
    }

    public function testDoesNotUpdateRunIntervalOnAlreadyRegisteredTaskWhenRunIntervalWasChanged(): void
    {
        $connection = $this->getContainer()->get(Connection::class);
        $connection->executeStatement('DELETE FROM scheduled_task');

        $this->scheduledTaskRepo->create([
            [
                
'runInterval' => 1,
                'status' => ScheduledTaskDefinition::STATUS_SCHEDULED,
            ],
        ], Context::createDefaultContext());

        $criteria = new Criteria([$id]);
        $result = $repository->search($criteria, Context::createDefaultContext());
        static::assertCount(1, $result->getEntities());
        $task = $result->getEntities()->first();
        static::assertInstanceOf(ScheduledTaskEntity::class$task);
        static::assertEquals(1, $task->getRunInterval());
        static::assertEquals(1, $task->getDefaultRunInterval());
    }

    public function testSnippetWriteWithoutValueFieldThrowsWriteValidationError(): void
    {
        $snippetRepo = $this->createRepository(SnippetDefinition::class);

        $snippetSetId = $this->getSnippetSetIdForLocale('en-GB');

        static::expectException(WriteException::class);
        $snippetRepo->create([
            [
                

        $payload = [];
        if (!$task->shouldRun($this->parameterBag) && \in_array($registeredTask->getStatus()[ScheduledTaskDefinition::STATUS_QUEUED, ScheduledTaskDefinition::STATUS_SCHEDULED], true)) {
            $payload['status'] = ScheduledTaskDefinition::STATUS_SKIPPED;
        }

        if ($task->shouldRun($this->parameterBag) && \in_array($registeredTask->getStatus()[ScheduledTaskDefinition::STATUS_QUEUED, ScheduledTaskDefinition::STATUS_SKIPPED], true)) {
            $payload['status'] = ScheduledTaskDefinition::STATUS_SCHEDULED;
            $payload['nextExecutionTime'] = $this->calculateNextExecutionTime($registeredTask);
        }

        if ($task->getDefaultInterval() !== $registeredTask->getDefaultRunInterval()) {
            // default run interval changed             $payload['defaultRunInterval'] = $task->getDefaultInterval();

            // if the run interval is still the default, update it to the new default             if ($registeredTask->getRunInterval() === $registeredTask->getDefaultRunInterval()) {
                $payload['runInterval'] = $task->getDefaultInterval();
            }
        }

        if ($payload !== []) {
            $payload['id'] = $registeredTask->getId();
        }
Home | Imprint | This part of the site doesn't use cookies.