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 /* (c) Anton Medvedev <[email protected]> * * For the full copyright and license infor..

Decoded Output download

<?php
/* (c) Anton Medvedev <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Task;

use PHPUnit\Framework\TestCase;

class ScriptManagerTest extends TestCase
{
    public function testGetTasks()
    {
        $notify = new Task('notify');
        $info = new GroupTask('info', ['notify']);
        $deploy = new GroupTask('deploy', ['deploy:setup', 'deploy:release']);
        $deploy->addBefore($info);
        $setup = new Task('deploy:setup');
        $release = new Task('deploy:release');

        $taskCollection = new TaskCollection();
        $taskCollection->set($notify->getName(), $notify);
        $taskCollection->set($info->getName(), $info);
        $taskCollection->set($deploy->getName(), $deploy);
        $taskCollection->set($setup->getName(), $setup);
        $taskCollection->set($release->getName(), $release);

        $scriptManager = new ScriptManager($taskCollection);
        self::assertEquals([$notify, $setup, $release], $scriptManager->getTasks('deploy'));
    }

    public function testOnce()
    {
        $a = new Task('a');
        $b = new Task('b');
        $b->once();
        $group = new GroupTask('group', ['a', 'b']);

        $taskCollection = new TaskCollection();
        $taskCollection->add($a);
        $taskCollection->add($b);
        $taskCollection->add($group);

        $scriptManager = new ScriptManager($taskCollection);
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertFalse($a->isOnce());
        self::assertTrue($b->isOnce());

        $group->once();
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertTrue($a->isOnce());
        self::assertTrue($b->isOnce());
    }

    public function testSelectsCombine()
    {
        $a = new Task('a');
        $b = new Task('b');
        $b->select('stage=beta');
        $group = new GroupTask('group', ['a', 'b']);

        $taskCollection = new TaskCollection();
        $taskCollection->add($a);
        $taskCollection->add($b);
        $taskCollection->add($group);

        $scriptManager = new ScriptManager($taskCollection);
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertNull($a->getSelector());
        self::assertEquals([[['=', 'stage', 'beta']]], $b->getSelector());

        $group->select('role=prod');
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertEquals([[['=', 'role', 'prod']]], $a->getSelector());
        self::assertEquals([[['=', 'stage', 'beta']],[['=', 'role', 'prod']]], $b->getSelector());
    }

    public function testThrowsExceptionIfTaskCollectionEmpty()
    {
        self::expectException(\InvalidArgumentException::class);

        $scriptManager = new ScriptManager(new TaskCollection());
        $scriptManager->getTasks('');
    }

    public function testThrowsExceptionIfTaskDontExists()
    {
        self::expectException(\InvalidArgumentException::class);

        $taskCollection = new TaskCollection();
        $taskCollection->set('testTask', new Task('testTask'));

        $scriptManager = new ScriptManager($taskCollection);
        $scriptManager->getTasks('testTask2');
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php
/* (c) Anton Medvedev <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Task;

use PHPUnit\Framework\TestCase;

class ScriptManagerTest extends TestCase
{
    public function testGetTasks()
    {
        $notify = new Task('notify');
        $info = new GroupTask('info', ['notify']);
        $deploy = new GroupTask('deploy', ['deploy:setup', 'deploy:release']);
        $deploy->addBefore($info);
        $setup = new Task('deploy:setup');
        $release = new Task('deploy:release');

        $taskCollection = new TaskCollection();
        $taskCollection->set($notify->getName(), $notify);
        $taskCollection->set($info->getName(), $info);
        $taskCollection->set($deploy->getName(), $deploy);
        $taskCollection->set($setup->getName(), $setup);
        $taskCollection->set($release->getName(), $release);

        $scriptManager = new ScriptManager($taskCollection);
        self::assertEquals([$notify, $setup, $release], $scriptManager->getTasks('deploy'));
    }

    public function testOnce()
    {
        $a = new Task('a');
        $b = new Task('b');
        $b->once();
        $group = new GroupTask('group', ['a', 'b']);

        $taskCollection = new TaskCollection();
        $taskCollection->add($a);
        $taskCollection->add($b);
        $taskCollection->add($group);

        $scriptManager = new ScriptManager($taskCollection);
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertFalse($a->isOnce());
        self::assertTrue($b->isOnce());

        $group->once();
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertTrue($a->isOnce());
        self::assertTrue($b->isOnce());
    }

    public function testSelectsCombine()
    {
        $a = new Task('a');
        $b = new Task('b');
        $b->select('stage=beta');
        $group = new GroupTask('group', ['a', 'b']);

        $taskCollection = new TaskCollection();
        $taskCollection->add($a);
        $taskCollection->add($b);
        $taskCollection->add($group);

        $scriptManager = new ScriptManager($taskCollection);
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertNull($a->getSelector());
        self::assertEquals([[['=', 'stage', 'beta']]], $b->getSelector());

        $group->select('role=prod');
        self::assertEquals([$a, $b], $scriptManager->getTasks('group'));
        self::assertEquals([[['=', 'role', 'prod']]], $a->getSelector());
        self::assertEquals([[['=', 'stage', 'beta']],[['=', 'role', 'prod']]], $b->getSelector());
    }

    public function testThrowsExceptionIfTaskCollectionEmpty()
    {
        self::expectException(\InvalidArgumentException::class);

        $scriptManager = new ScriptManager(new TaskCollection());
        $scriptManager->getTasks('');
    }

    public function testThrowsExceptionIfTaskDontExists()
    {
        self::expectException(\InvalidArgumentException::class);

        $taskCollection = new TaskCollection();
        $taskCollection->set('testTask', new Task('testTask'));

        $scriptManager = new ScriptManager($taskCollection);
        $scriptManager->getTasks('testTask2');
    }
}

Function Calls

None

Variables

None

Stats

MD5 d18d72dbd1600b3763d04c6011e49e24
Eval Count 0
Decode Time 106 ms