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'))); }
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'))); }
public function __construct(ChoiceLoaderInterface $loaderInterface, Question $question) { parent::__construct($loaderInterface); $this->question = $question; }
public function testLoadValuesForChoicesLoadsChoiceListOnFirstCall() { $this->assertSame(self::$loader->loadValuesForChoices(self::$choices, self::$value), self::$lazyChoiceList->getValuesForChoices(self::$choices), 'Choice list should not be reloaded.'); }