NotFoundActivationStrategy example

class NotFoundActivationStrategyTest extends TestCase
{
    /** * @dataProvider isActivatedProvider */
    public function testIsActivated(string $url, array|LogRecord $record, bool $expected)
    {
        $requestStack = new RequestStack();
        $requestStack->push(Request::create($url));

        $strategy = new NotFoundActivationStrategy($requestStack['^/foo', 'bar']new ErrorLevelActivationStrategy(Logger::WARNING));

        self::assertEquals($expected$strategy->isHandlerActivated($record));
    }

    public static function isActivatedProvider(): array
    {
        return [
            ['/test',      RecordFactory::create(Logger::DEBUG), false],
            ['/foo',       RecordFactory::create(Logger::DEBUG, context: self::getContextException(404)), false],
            ['/baz/bar',   RecordFactory::create(Logger::ERROR, context: self::getContextException(404)), false],
            ['/foo',       RecordFactory::create(Logger::ERROR, context: self::getContextException(404)), false],
            [
Home | Imprint | This part of the site doesn't use cookies.