public function testGetChoicesForValuesUsesLoadedList() { $this->loader->expects($this->once())->method('loadChoiceList')->with($this->value)->will($this->returnValue($this->innerList)); $this->loader->expects($this->never())->method('loadChoicesForValues'); $this->innerList->expects($this->exactly(2))->method('getChoicesForValues')->with(array('a', 'b'))->will($this->returnValue('RESULT')); // load choice list $this->list->getChoices(); $this->assertSame('RESULT', $this->list->getChoicesForValues(array('a', 'b'))); $this->assertSame('RESULT', $this->list->getChoicesForValues(array('a', 'b'))); }
public function testGetChoicesForValuesUsesLoadedList() { $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('loadChoicesForValues'); $this->loadedList->expects($this->exactly(2)) ->method('getChoicesForValues') ->with(array('a', 'b')) ->will($this->returnValue('RESULT')); // load choice list $this->list->getChoices(); $this->assertSame('RESULT', $this->list->getChoicesForValues(array('a', 'b'))); $this->assertSame('RESULT', $this->list->getChoicesForValues(array('a', 'b'))); }
public function testLoadChoicesForValuesLoadsChoiceListOnFirstCall() { $this->assertSame(self::$loader->loadChoicesForValues(self::$choiceValues, self::$value), self::$lazyChoiceList->getChoicesForValues(self::$choiceValues), 'Choice list should not be reloaded.'); }