コード例 #1
0
 public function testGetValuesForChoicesUsesLoadedList()
 {
     $this->loader->expects($this->once())->method('loadChoiceList')->with($this->value)->will($this->returnValue($this->innerList));
     $this->loader->expects($this->never())->method('loadValuesForChoices');
     $this->innerList->expects($this->exactly(2))->method('getValuesForChoices')->with(array('a', 'b'))->will($this->returnValue('RESULT'));
     // load choice list
     $this->list->getChoices();
     $this->assertSame('RESULT', $this->list->getValuesForChoices(array('a', 'b')));
     $this->assertSame('RESULT', $this->list->getValuesForChoices(array('a', 'b')));
 }
コード例 #2
0
    public function testGetValuesForChoicesUsesLoadedList()
    {
        $this->loader->expects($this->exactly(3))
            ->method('loadChoiceList')
            ->with($this->value)
            // For BC, the same choice loaded list is returned 3 times
            // It should only twice in 4.0
            ->will($this->returnValue($this->loadedList));

        $this->loader->expects($this->never())
            ->method('loadValuesForChoices');

        $this->loadedList->expects($this->exactly(2))
            ->method('getValuesForChoices')
            ->with(array('a', 'b'))
            ->will($this->returnValue('RESULT'));

        // load choice list
        $this->list->getChoices();

        $this->assertSame('RESULT', $this->list->getValuesForChoices(array('a', 'b')));
        $this->assertSame('RESULT', $this->list->getValuesForChoices(array('a', 'b')));
    }
コード例 #3
0
 public function __construct(ChoiceLoaderInterface $loaderInterface, Question $question)
 {
     parent::__construct($loaderInterface);
     $this->question = $question;
 }
コード例 #4
0
 public function testLoadValuesForChoicesLoadsChoiceListOnFirstCall()
 {
     $this->assertSame(self::$loader->loadValuesForChoices(self::$choices, self::$value), self::$lazyChoiceList->getValuesForChoices(self::$choices), 'Choice list should not be reloaded.');
 }