Вход Регистрация
Файл: symfony-2.7/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/CompatModelChoiceListTest.php
Строк: 53
<?php

namespace SymfonyBridgePropel1TestsFormChoiceList;

use 
SymfonyBridgePropel1FormChoiceListModelChoiceList;
use 
SymfonyBridgePropel1TestsFixturesItem;
use 
SymfonyBridgePropel1TestsFixturesItemQuery;
use 
SymfonyComponentFormTestsExtensionCoreChoiceListAbstractChoiceListTest;

class 
CompatModelChoiceListTest extends AbstractChoiceListTest
{
    const 
ITEM_CLASS 'SymfonyBridgePropel1TestsFixturesItem';

    
/**
     * @var PHPUnit_Framework_MockObject_MockObject|SymfonyBridgePropel1TestsFixturesItemQuery
     */
    
protected $query;

    protected 
$item1;
    protected 
$item2;
    protected 
$item3;
    protected 
$item4;

    public function 
testGetChoicesForValues()
    {
        
$this->query
            
->expects($this->once())
            ->
method('filterById')
            ->
with(array(12))
            ->
will($this->returnSelf())
        ;

        
ItemQuery::$result = array(
            
$this->item2,
            
$this->item1,
        );

        
parent::testGetChoicesForValues();
    }

    protected function 
setUp()
    {
        
$this->query $this->getMock('SymfonyBridgePropel1TestsFixturesItemQuery', array(
            
'filterById',
        ), array(), 
''truetruetruefalsetrue);

        
$this->query
            
->expects($this->any())
            ->
method('filterById')
            ->
with($this->anything())
            ->
will($this->returnSelf())
        ;

        
$this->createItems();

        
ItemQuery::$result = array(
            
$this->item1,
            
$this->item2,
            
$this->item3,
            
$this->item4,
        );

        
parent::setUp();
    }

    protected function 
createItems()
    {
        
$this->item1 = new Item(1'Foo');
        
$this->item2 = new Item(2'Bar');
        
$this->item3 = new Item(3'Baz');
        
$this->item4 = new Item(4'Cuz');
    }

    protected function 
createChoiceList()
    {
        return new 
ModelChoiceList(self::ITEM_CLASS'value'null$this->query);
    }

    protected function 
getChoices()
    {
        return array(
            
=> $this->item1,
            
=> $this->item2,
            
=> $this->item3,
            
=> $this->item4,
        );
    }

    protected function 
getLabels()
    {
        return array(
            
=> 'Foo',
            
=> 'Bar',
            
=> 'Baz',
            
=> 'Cuz',
        );
    }

    protected function 
getValues()
    {
        return array(
            
=> '1',
            
=> '2',
            
=> '3',
            
=> '4',
        );
    }

    protected function 
getIndices()
    {
        return array(
            
1,
            
2,
            
3,
            
4,
        );
    }
}
Онлайн: 1
Реклама