Skip to content

Commit 90359c0

Browse files
committed
Wip to remove Config class
1 parent e6a795d commit 90359c0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/CloudTasksQueue.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ public function release(CloudTasksJob $job, int $delay = 0): void
250250

251251
public function getHandler(): string
252252
{
253-
return Config::getHandler($this->config['handler']);
253+
$handler = rtrim($this->config['handler'], '/');
254+
255+
return match (true) {
256+
! str_ends_with($handler, '/handle-task') => $handler.'/handle-task',
257+
default => $handler,
258+
};
254259
}
255260

256261
public function getAudience(): ?string

tests/ConfigHandlerTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,26 @@
44

55
namespace Tests;
66

7-
use Stackkit\LaravelGoogleCloudTasksQueue\Config;
7+
use Google\Cloud\Tasks\V2\Task;
8+
use Stackkit\LaravelGoogleCloudTasksQueue\CloudTasksApi;
9+
use Tests\Support\SimpleJob;
810

9-
class ConfigHandlerTest extends \PHPUnit\Framework\TestCase
11+
class ConfigHandlerTest extends TestCase
1012
{
1113
/**
1214
* @dataProvider handlerDataProvider
1315
*/
1416
public function test_it_allows_a_handler_url_to_contain_path(string $handler, string $expectedHandler): void
1517
{
16-
self::assertSame($expectedHandler, Config::getHandler($handler));
18+
CloudTasksApi::fake();
19+
20+
$this->setConfigValue('handler', $handler);
21+
22+
$this->dispatch(new SimpleJob());
23+
24+
CloudTasksApi::assertTaskCreated(function (Task $task) use ($expectedHandler) {
25+
return $task->getHttpRequest()->getUrl() === $expectedHandler;
26+
});
1727
}
1828

1929
public static function handlerDataProvider(): array

0 commit comments

Comments
 (0)