Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..

Decoded Output download

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Messenger\Test\Middleware;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Messenger\Middleware\StackMiddleware;

/**
 * @author Nicolas Grekas <[email protected]>
 */
abstract class MiddlewareTestCase extends TestCase
{
    protected function getStackMock(bool $nextIsCalled = true)
    {
        if (!$nextIsCalled) {
            $stack = $this->createMock(StackInterface::class);
            $stack
                ->expects($this->never())
                ->method('next')
            ;

            return $stack;
        }

        $nextMiddleware = $this->createMock(MiddlewareInterface::class);
        $nextMiddleware
            ->expects($this->once())
            ->method('handle')
            ->willReturnCallback(fn (Envelope $envelope, StackInterface $stack): Envelope => $envelope)
        ;

        return new StackMiddleware($nextMiddleware);
    }

    protected function getThrowingStackMock(?\Throwable $throwable = null)
    {
        $nextMiddleware = $this->createMock(MiddlewareInterface::class);
        $nextMiddleware
            ->expects($this->once())
            ->method('handle')
            ->willThrowException($throwable ?? new \RuntimeException('Thrown from next middleware.'))
        ;

        return new StackMiddleware($nextMiddleware);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Messenger\Test\Middleware;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Messenger\Middleware\StackMiddleware;

/**
 * @author Nicolas Grekas <[email protected]>
 */
abstract class MiddlewareTestCase extends TestCase
{
    protected function getStackMock(bool $nextIsCalled = true)
    {
        if (!$nextIsCalled) {
            $stack = $this->createMock(StackInterface::class);
            $stack
                ->expects($this->never())
                ->method('next')
            ;

            return $stack;
        }

        $nextMiddleware = $this->createMock(MiddlewareInterface::class);
        $nextMiddleware
            ->expects($this->once())
            ->method('handle')
            ->willReturnCallback(fn (Envelope $envelope, StackInterface $stack): Envelope => $envelope)
        ;

        return new StackMiddleware($nextMiddleware);
    }

    protected function getThrowingStackMock(?\Throwable $throwable = null)
    {
        $nextMiddleware = $this->createMock(MiddlewareInterface::class);
        $nextMiddleware
            ->expects($this->once())
            ->method('handle')
            ->willThrowException($throwable ?? new \RuntimeException('Thrown from next middleware.'))
        ;

        return new StackMiddleware($nextMiddleware);
    }
}

Function Calls

None

Variables

None

Stats

MD5 1ae313720b2d916d72b32fec82fb5c4f
Eval Count 0
Decode Time 117 ms