Вход Регистрация
Файл: symfony-2.7/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php
Строк: 77
<?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 SymfonyBundleWebProfilerBundleTestsCommand;

use 
SymfonyBundleWebProfilerBundleCommandExportCommand;
use 
SymfonyComponentConsoleTesterCommandTester;
use 
SymfonyComponentHttpKernelProfilerProfile;

class 
ExportCommandTest extends PHPUnit_Framework_TestCase
{
    
/**
     * @expectedException LogicException
     */
    
public function testExecuteWithUnknownToken()
    {
        
$profiler $this
            
->getMockBuilder('SymfonyComponentHttpKernelProfilerProfiler')
            ->
disableOriginalConstructor()
            ->
getMock()
        ;

        
$command = new ExportCommand($profiler);
        
$commandTester = new CommandTester($command);
        
$commandTester->execute(array('token' => 'TOKEN'));
    }

    public function 
testExecuteWithToken()
    {
        
$profiler $this
            
->getMockBuilder('SymfonyComponentHttpKernelProfilerProfiler')
            ->
disableOriginalConstructor()
            ->
getMock()
        ;

        
$profile = new Profile('TOKEN');
        
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));

        
$command = new ExportCommand($profiler);
        
$commandTester = new CommandTester($command);
        
$commandTester->execute(array('token' => 'TOKEN'));
        
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());
    }
}
Онлайн: 2
Реклама