Skip to content

Commit

Permalink
Try removing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispenny committed Apr 3, 2023
1 parent aab36ae commit 56b3883
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions tests/php/Extension/Engine/SiteTreePublishingEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,42 +151,42 @@ protected function getJobByClassName(array $jobs, string $className): ?QueuedJob
return null;
}

protected function setUp(): void
{
// 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());

// Set up our base URL so that it's always consistent for our tests
Config::modify()->set(Director::class, 'alternate_base_url', 'http://example.com/');

parent::setUp();

$pages = [
'page1',
'page2',
'page3',
'page4',
'page5',
'page6',
];

// Publish all of our pages before we start testing with them
foreach ($pages as $pageId) {
$page = $this->objFromFixture(SiteTree::class, $pageId);
$page->publishRecursive();
}

/** @var QueuedJobsTestService $service */
$service = Injector::inst()->get(QueuedJobService::class);
// Remove any jobs that were queued as part of the publishing above
$service->flushJobs();
}
// protected function setUp(): void
// {
// // 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());
//
// // Set up our base URL so that it's always consistent for our tests
// Config::modify()->set(Director::class, 'alternate_base_url', 'http://example.com/');
//
// parent::setUp();
//
// $pages = [
// 'page1',
// 'page2',
// 'page3',
// 'page4',
// 'page5',
// 'page6',
// ];
//
// // Publish all of our pages before we start testing with them
// foreach ($pages as $pageId) {
// $page = $this->objFromFixture(SiteTree::class, $pageId);
// $page->publishRecursive();
// }
//
// /** @var QueuedJobsTestService $service */
// $service = Injector::inst()->get(QueuedJobService::class);
// // Remove any jobs that were queued as part of the publishing above
// $service->flushJobs();
// }
}

0 comments on commit 56b3883

Please sign in to comment.