• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / cronjob / 13433654919

20 Feb 2025 10:54AM UTC coverage: 65.424% (-2.5%) from 67.886%
13433654919

push

github

Jordi de la Mano
Fix: phpunit coverage

316 of 483 relevant lines covered (65.42%)

2.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Controllers/Job.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Daycry\CronJob\Controllers;
6

7
use Daycry\CronJob\Config\Services;
8
use CodeIgniter\Exceptions\PageNotFoundException;
9

10
class Job extends BaseCronJob
11
{
12
    /**
13
     * Displays the form the login to the site.
14
     */
15
    public function index(string $jobName)
16
    {
17
        if (! $this->checkCronJobSession()) {
×
18
            return redirect()->to('cronjob');
×
19
        }
20

21
        $scheduler = $this->initializeScheduler();
×
22

23
        $job = $this->findJobByName($scheduler, $jobName);
×
24

25
        if (! $job) {
×
26
            throw new PageNotFoundException();
×
27
        }
28

29
        $this->viewData['logs'] = $job->getLogs();
×
30

31
        return view(config('CronJob')->views['logs'], $this->viewData);
×
32
    }
33

34
    /**
35
     * Initialize the scheduler with the configuration.
36
     */
37
    private function initializeScheduler()
38
    {
39
        $config = config('CronJob');
×
40
        $scheduler = Services::scheduler();
×
41
        $config->init($scheduler);
×
42

43
        return $scheduler;
×
44
    }
45

46
    /**
47
     * Find a job by its name from the scheduler.
48
     */
49
    private function findJobByName($scheduler, string $jobName)
50
    {
51
        foreach ($scheduler->getTasks() as $job) {
×
52
            if ($job->getName() === $jobName) {
×
53
                return $job;
×
54
            }
55
        }
56

57
        return false;
×
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc