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.
croct/coding-standard
croct/plug-php
nqxcode/phpmorphy
boundwize/pyrameter
testo/facade
headercat/phpstan-extension-ide-helper
yosymfony/parser-utils
innmind/black-box
babenkoivan/elastic-migrations
babenkoivan/elastic-adapter
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle