Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.1: SapphireTestState config forces you to prefer-source for development/testing #138

Closed
chrispenny opened this issue Jun 7, 2022 · 1 comment · Fixed by #139
Closed

Comments

@chrispenny
Copy link
Contributor

A new configuration has been added in 5.1.

  SilverStripe\Dev\State\SapphireTestState:
    properties:
      States:
        staticPublisherState: '%$SilverStripe\StaticPublishQueue\Dev\StaticPublisherState'
public function setUp(SapphireTest $test)
{
    // Prepare queued jobs related functionality for unit test run
    // Disable queue logging
    Injector::inst()->registerService(new QueuedJobsTest_Handler(), QueuedJobHandler::class);

    // Disable special actions of the queue service
    Config::modify()->set(QueuedJobService::class, 'use_shutdown_function', false);

    // It seems Injector doesn't cover all cases so we force-inject a test service which is suitable for unit tests
    Injector::inst()->registerService(new QueuedJobsTestService(), QueuedJobService::class);
    SiteTreePublishingEngine::setQueueService(QueuedJobService::singleton());
}

QueuedJobsTest_Handler is a test class from the QueuedJobs module, and QueuedJobsTestService is a test class from this module. This means they're not available unless you composer install --prefer-source.

Is this the expected behaviour?

@mfendeksilverstripe
Copy link
Collaborator

Nice find @chrispenny , we should add class_exists() check in there and bail out if these classes are not available. This feature is meant to be used only for running tests within this module so an immediate project level fix would be to simply remove it by configuration if it's causing issues in your project (note that the test state had a named key in the config so you can just set it to null).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants