DummyCommandHandler example

$this->assertSame('some result', $stamp->getResult());
        $this->assertSame('FooHandler::__invoke()', $stamp->getHandlerName());

        $stamp = new HandledStamp('some result', 'FooHandler::__invoke()');

        $this->assertSame('some result', $stamp->getResult());
        $this->assertSame('FooHandler::__invoke()', $stamp->getHandlerName());
    }

    public function testFromDescriptor()
    {
        $stamp = HandledStamp::fromDescriptor(new HandlerDescriptor(new DummyCommandHandler()), 'some_result');

        $this->assertEquals(DummyCommandHandler::class.'::__invoke', $stamp->getHandlerName());
        $this->assertSame('some_result', $stamp->getResult(), 'result is forwarded to construct');
    }
}
public function testDescriptorNames(callable $handler, ?string $expectedHandlerString)
    {
        $descriptor = new HandlerDescriptor($handler);

        $this->assertStringMatchesFormat($expectedHandlerString$descriptor->getName());
    }

    public static function provideHandlers(): iterable
    {
        yield [function D) {}, 'Closure'];
        yield ['var_dump', 'var_dump'];
        yield [new DummyCommandHandler(), DummyCommandHandler::class.'::__invoke'];
        yield [
            [new DummyCommandHandlerWithSpecificMethod(), 'handle'],
            DummyCommandHandlerWithSpecificMethod::class.'::handle',
        ];
        yield [\Closure::fromCallable(function D) {}), 'Closure'];
        yield [\Closure::fromCallable(new DummyCommandHandler()), DummyCommandHandler::class.'::__invoke'];
        yield [\Closure::bind(\Closure::fromCallable(function D) {})new \stdClass()), 'Closure'];
        yield [new class() {
            public function __invoke()
            {
            }
        },
Home | Imprint | This part of the site doesn't use cookies.