Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Scheduler Bundle Laravel Package

caeligo/scheduler-bundle

View on GitHub
Deep Wiki
Context7

Testing

How to run the test suite and write tests for the Caeligo Scheduler Bundle.

Running Tests

Install Dependencies

composer install

Run All Tests

vendor/bin/phpunit

Run Specific Test Suites

# Unit tests only
vendor/bin/phpunit --testsuite=Unit

# Integration tests only
vendor/bin/phpunit --testsuite=Integration

# Functional tests only
vendor/bin/phpunit --testsuite=Functional

Run a Specific Test

vendor/bin/phpunit --filter=CronExpressionParserTest
vendor/bin/phpunit --filter=testIsValidExpression

Test Structure

tests/
├── Unit/
│   ├── Attribute/
│   │   └── AsSchedulableCommandTest.php
│   ├── DependencyInjection/
│   │   └── ConfigurationTest.php
│   ├── Enum/
│   │   └── TaskRunStatusTest.php
│   ├── Service/
│   │   ├── CommandDiscoveryServiceTest.php
│   │   ├── CronExpressionParserTest.php
│   │   ├── CrontabManagerTest.php
│   │   ├── StateManagerTest.php
│   │   └── TaskDispatcherTest.php
│   └── Twig/
│       └── SchedulerExtensionTest.php
├── Integration/
└── Functional/

Unit Tests

CronExpressionParserTest

Tests cron expression parsing, interval calculation, human-readable descriptions, and due-checking:

  • Valid/invalid expression detection
  • Next run date calculation
  • Interval-based scheduling
  • describe() output for common patterns
  • isTaskDue() unified checks

StateManagerTest

Tests file-based state and log storage using a temporary directory:

  • State save/load round-trip
  • Task state update merging
  • Enable/disable toggle
  • Mark running/completed/skipped
  • Log append and read (with limits)
  • Log cleanup by retention
  • Output filtering configuration
  • Command name sanitization

CommandDiscoveryServiceTest

Tests attribute-based command discovery using a real Symfony Application with test command fixtures:

  • Discovering #[AsSchedulableCommand] commands
  • Excluding non-decorated commands
  • Correct metadata extraction
  • Group listing
  • Per-request caching

CrontabManagerTest

Tests crontab line generation (mocked Process for actual crontab operations):

  • Correct crontab line format
  • Path escaping

TaskDispatcherTest

Tests the execution engine with mocked CommandDiscoveryService:

  • Task merging (discovered + state)
  • Default expression fallback
  • Overdue task filtering
  • Overlap prevention
  • Priority sorting
  • Max concurrent limiting
  • Sync discovered commands

TaskRunStatusTest

Tests the enum values, labels, and badge classes.

AsSchedulableCommandTest

Tests the attribute constructor, default values, and PHP attribute metadata.

ConfigurationTest

Tests the Symfony config tree processing with defaults and custom values.

SchedulerExtensionTest

Tests all Twig filters: describe, badge, formatDuration, timeAgo.

Writing Your Own Tests

When writing integration tests for the bundle in a host project:

use Caeligo\SchedulerBundle\Service\TaskDispatcher;

class MySchedulerTest extends KernelTestCase
{
    public function testSchedulerDiscoversMyCommands(): void
    {
        self::bootKernel();
        $dispatcher = self::getContainer()->get(TaskDispatcher::class);
        $tasks = $dispatcher->getAllTasks();

        $this->assertArrayHasKey('app:my-command', $tasks);
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky