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 declare(strict_types=1); namespace Barryvdh\LaravelIdeHelper\Tests; use Illuminat..

Decoded Output download

<?php

declare(strict_types=1);

namespace Barryvdh\LaravelIdeHelper\Tests;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Mockery;
use Orchestra\Testbench\TestCase as BaseTestCase;
use Spatie\Snapshots\MatchesSnapshots;
use Symfony\Component\Console\Tester\CommandTester;

abstract class TestCase extends BaseTestCase
{
    use MatchesSnapshots;

    protected $mockFilesystemOutput;

    /**
     * The `CommandTester` is directly returned, use methods like
     * `->getDisplay()` or `->getStatusCode()` on it.
     *
     * @param Command $command
     * @param array $arguments The command line arguments, array of key=>value
     *   Examples:
     *   - named  arguments: ['model' => 'Post']
     *   - boolean flags: ['--all' => true]
     *   - arguments with values: ['--arg' => 'value']
     * @param array $interactiveInput Interactive responses to the command
     *   I.e. anything the command `->ask()` or `->confirm()`, etc.
     * @return CommandTester
     */
    protected function runCommand(Command $command, array $arguments = [], array $interactiveInput = []): CommandTester
    {
        $this->withoutMockingConsoleOutput();

        $command->setLaravel($this->app);

        $tester = new CommandTester($command);
        $tester->setInputs($interactiveInput);

        $tester->execute($arguments);

        return $tester;
    }

    protected function assertMatchesPhpSnapshot(?string $actualContent)
    {
        $this->assertMatchesSnapshot($actualContent, new SnapshotPhpDriver());
    }

    protected function assertMatchesTxtSnapshot(?string $actualContent)
    {
        $this->assertMatchesSnapshot($actualContent, new SnapshotTxtDriver());
    }

    protected function mockFilesystem()
    {
        $mockFilesystem = Mockery::mock(Filesystem::class);

        $mockFilesystem
            ->shouldReceive('get')
            ->andReturnUsing(function ($file) {
                return file_get_contents($file);
            });

        $mockFilesystem
            ->shouldReceive('put')
            ->with(
                Mockery::any(),
                Mockery::any()
            )
            ->andReturnUsing(function ($path, $contents) {
                $this->mockFilesystemOutput .= $contents;

                return strlen($contents);
            });

        $this->instance(Filesystem::class, $mockFilesystem);
        $this->instance('files', $mockFilesystem);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace Barryvdh\LaravelIdeHelper\Tests;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Mockery;
use Orchestra\Testbench\TestCase as BaseTestCase;
use Spatie\Snapshots\MatchesSnapshots;
use Symfony\Component\Console\Tester\CommandTester;

abstract class TestCase extends BaseTestCase
{
    use MatchesSnapshots;

    protected $mockFilesystemOutput;

    /**
     * The `CommandTester` is directly returned, use methods like
     * `->getDisplay()` or `->getStatusCode()` on it.
     *
     * @param Command $command
     * @param array $arguments The command line arguments, array of key=>value
     *   Examples:
     *   - named  arguments: ['model' => 'Post']
     *   - boolean flags: ['--all' => true]
     *   - arguments with values: ['--arg' => 'value']
     * @param array $interactiveInput Interactive responses to the command
     *   I.e. anything the command `->ask()` or `->confirm()`, etc.
     * @return CommandTester
     */
    protected function runCommand(Command $command, array $arguments = [], array $interactiveInput = []): CommandTester
    {
        $this->withoutMockingConsoleOutput();

        $command->setLaravel($this->app);

        $tester = new CommandTester($command);
        $tester->setInputs($interactiveInput);

        $tester->execute($arguments);

        return $tester;
    }

    protected function assertMatchesPhpSnapshot(?string $actualContent)
    {
        $this->assertMatchesSnapshot($actualContent, new SnapshotPhpDriver());
    }

    protected function assertMatchesTxtSnapshot(?string $actualContent)
    {
        $this->assertMatchesSnapshot($actualContent, new SnapshotTxtDriver());
    }

    protected function mockFilesystem()
    {
        $mockFilesystem = Mockery::mock(Filesystem::class);

        $mockFilesystem
            ->shouldReceive('get')
            ->andReturnUsing(function ($file) {
                return file_get_contents($file);
            });

        $mockFilesystem
            ->shouldReceive('put')
            ->with(
                Mockery::any(),
                Mockery::any()
            )
            ->andReturnUsing(function ($path, $contents) {
                $this->mockFilesystemOutput .= $contents;

                return strlen($contents);
            });

        $this->instance(Filesystem::class, $mockFilesystem);
        $this->instance('files', $mockFilesystem);
    }
}

Function Calls

None

Variables

None

Stats

MD5 698e2c7580dcc2201063d5036ef24a48
Eval Count 0
Decode Time 88 ms