Вход Регистрация
Файл: symfony-2.7/src/Symfony/Component/Form/Tests/AbstractFormTest.php
Строк: 139
<?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 SymfonyComponentFormTests;

use 
SymfonyComponentFormFormBuilder;
use 
SymfonyComponentEventDispatcherEventDispatcher;
use 
SymfonyComponentEventDispatcherEventDispatcherInterface;

abstract class 
AbstractFormTest extends PHPUnit_Framework_TestCase
{
    
/**
     * @var EventDispatcherInterface
     */
    
protected $dispatcher;

    
/**
     * @var SymfonyComponentFormFormFactoryInterface
     */
    
protected $factory;

    
/**
     * @var SymfonyComponentFormFormInterface
     */
    
protected $form;

    protected function 
setUp()
    {
        
// We need an actual dispatcher to use the deprecated
        // bindRequest() method
        
$this->dispatcher = new EventDispatcher();
        
$this->factory $this->getMock('SymfonyComponentFormFormFactoryInterface');
        
$this->form $this->createForm();
    }

    protected function 
tearDown()
    {
        
$this->dispatcher null;
        
$this->factory null;
        
$this->form null;
    }

    
/**
     * @return SymfonyComponentFormFormInterface
     */
    
abstract protected function createForm();

    
/**
     * @param string                   $name
     * @param EventDispatcherInterface $dispatcher
     * @param string                   $dataClass
     * @param array                    $options
     *
     * @return FormBuilder
     */
    
protected function getBuilder($name 'name'EventDispatcherInterface $dispatcher null$dataClass null, array $options = array())
    {
        return new 
FormBuilder($name$dataClass$dispatcher ?: $this->dispatcher$this->factory$options);
    }

    
/**
     * @param string $name
     *
     * @return PHPUnit_Framework_MockObject_MockObject
     */
    
protected function getMockForm($name 'name')
    {
        
$form $this->getMock('SymfonyComponentFormTestFormInterface');
        
$config $this->getMock('SymfonyComponentFormFormConfigInterface');

        
$form->expects($this->any())
            ->
method('getName')
            ->
will($this->returnValue($name));
        
$form->expects($this->any())
            ->
method('getConfig')
            ->
will($this->returnValue($config));

        return 
$form;
    }

    
/**
     * @return PHPUnit_Framework_MockObject_MockObject
     */
    
protected function getDataMapper()
    {
        return 
$this->getMock('SymfonyComponentFormDataMapperInterface');
    }

    
/**
     * @return PHPUnit_Framework_MockObject_MockObject
     */
    
protected function getDataTransformer()
    {
        return 
$this->getMock('SymfonyComponentFormDataTransformerInterface');
    }

    
/**
     * @return PHPUnit_Framework_MockObject_MockObject
     */
    
protected function getFormValidator()
    {
        return 
$this->getMock('SymfonyComponentFormFormValidatorInterface');
    }
}
Онлайн: 2
Реклама