403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.120
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/local/cwpsrv/var/services/twig/test/Twig/Tests/Profiler/Dumper/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/local/cwpsrv/var/services/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php
<?php

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends PHPUnit_Framework_TestCase
{
    protected function getProfile()
    {
        $profile = $this->getMockBuilder('Twig_Profiler_Profile')->disableOriginalConstructor()->getMock();

        $profile->expects($this->any())->method('isRoot')->will($this->returnValue(true));
        $profile->expects($this->any())->method('getName')->will($this->returnValue('main'));
        $profile->expects($this->any())->method('getDuration')->will($this->returnValue(1));
        $profile->expects($this->any())->method('getMemoryUsage')->will($this->returnValue(0));
        $profile->expects($this->any())->method('getPeakMemoryUsage')->will($this->returnValue(0));

        $subProfiles = array(
            $this->getIndexProfile(
                array(
                    $this->getEmbeddedBlockProfile(),
                    $this->getEmbeddedTemplateProfile(
                        array(
                            $this->getIncludedTemplateProfile(),
                        )
                    ),
                    $this->getMacroProfile(),
                    $this->getEmbeddedTemplateProfile(
                        array(
                            $this->getIncludedTemplateProfile(),
                        )
                    ),
                )
            ),
        );

        $profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles));
        $profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles)));

        return $profile;
    }

    private function getIndexProfile(array $subProfiles = array())
    {
        return $this->generateProfile('main', 1, true, 'template', 'index.twig', $subProfiles);
    }

    private function getEmbeddedBlockProfile(array $subProfiles = array())
    {
        return $this->generateProfile('body', 0.0001, false, 'block', 'embedded.twig', $subProfiles);
    }

    private function getEmbeddedTemplateProfile(array $subProfiles = array())
    {
        return $this->generateProfile('main', 0.0001, true, 'template', 'embedded.twig', $subProfiles);
    }

    private function getIncludedTemplateProfile(array $subProfiles = array())
    {
        return $this->generateProfile('main', 0.0001, true, 'template', 'included.twig', $subProfiles);
    }

    private function getMacroProfile(array $subProfiles = array())
    {
        return $this->generateProfile('foo', 0.0001, false, 'macro', 'index.twig', $subProfiles);
    }

    /**
     * @param string $name
     * @param float  $duration
     * @param bool   $isTemplate
     * @param string $type
     * @param string $templateName
     * @param array  $subProfiles
     *
     * @return Twig_Profiler_Profile
     */
    private function generateProfile($name, $duration, $isTemplate, $type, $templateName, array $subProfiles = array())
    {
        $profile = $this->getMockBuilder('Twig_Profiler_Profile')->disableOriginalConstructor()->getMock();

        $profile->expects($this->any())->method('isRoot')->will($this->returnValue(false));
        $profile->expects($this->any())->method('getName')->will($this->returnValue($name));
        $profile->expects($this->any())->method('getDuration')->will($this->returnValue($duration));
        $profile->expects($this->any())->method('getMemoryUsage')->will($this->returnValue(0));
        $profile->expects($this->any())->method('getPeakMemoryUsage')->will($this->returnValue(0));
        $profile->expects($this->any())->method('isTemplate')->will($this->returnValue($isTemplate));
        $profile->expects($this->any())->method('getType')->will($this->returnValue($type));
        $profile->expects($this->any())->method('getTemplate')->will($this->returnValue($templateName));
        $profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles));
        $profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles)));

        return $profile;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit