* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\ChoiceList\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ChoiceList\LazyChoiceList; use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader; /** * @author Jules Pietri */ class CallbackChoiceLoaderTest extends TestCase { /** * @var \Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader */ private static $loader; /** * @var callable */ private static $value; /** * @var array */ private static $choices; /** * @var string[] */ private static $choiceValues; /** * @var \Symfony\Component\Form\ChoiceList\LazyChoiceList */ private static $lazyChoiceList; public static function setUpBeforeClass() { self::$loader = new CallbackChoiceLoader(function () { return self::$choices; }); self::$value = function ($choice) { return isset($choice->value) ? $choice->value : null; }; self::$choices = array( (object) array('value' => 'choice_one'), (object) array('value' => 'choice_two'), ); self::$choiceValues = array('choice_one', 'choice_two'); self::$lazyChoiceList = new LazyChoiceList(self::$loader, self::$value); } public function testLoadChoiceList() { $this->assertInstanceOf('\Symfony\Component\Form\ChoiceList\ChoiceListInterface', self::$loader->loadChoiceList(self::$value)); } public function testLoadChoiceListOnlyOnce() { $loadedChoiceList = self::$loader->loadChoiceList(self::$value); $this->assertSame($loadedChoiceList, self::$loader->loadChoiceList(self::$value)); } public function testLoadChoicesForValuesLoadsChoiceListOnFirstCall() { $this->assertSame( self::$loader->loadChoicesForValues(self::$choiceValues, self::$value), self::$lazyChoiceList->getChoicesForValues(self::$choiceValues), 'Choice list should not be reloaded.' ); } public function testLoadValuesForChoicesLoadsChoiceListOnFirstCall() { $this->assertSame( self::$loader->loadValuesForChoices(self::$choices, self::$value), self::$lazyChoiceList->getValuesForChoices(self::$choices), 'Choice list should not be reloaded.' ); } public static function tearDownAfterClass() { self::$loader = null; self::$value = null; self::$choices = array(); self::$choiceValues = array(); self::$lazyChoiceList = null; } } __halt_compiler();----SIGNATURE:----pQtQ+j3WBHhe5ENE75zWrxb2Jo43dIOyzuejk3WDQnsoZKgZdZi4z1023M8cRdPOG4MwSOM9rGwI34wp1Q0cw8WliRYUNf36n2WrMneN8BJyHDyT21W7/aKVoJaBJ0xixssr88qrSy4ZVG04012+vcMltgvFVIBK53S1RgRTdCCnfsgkCLI7wFSnJL1FfN5vd1i5fJGQaUKdsCOvo4kgbuOvptvxanYk1piUvnCktF5I+L58cST0ztJPSvTCe/dwF8XM+jf+SixkuO+g83HBEHSqxqx+BOVSSgRjc0Yxtwy7kWuhHDRpgw8OmN/vIuuJ9HRlX13Pwx3dZBQP1h3oAiMYIi6yaJ3W4diJryXLwr3vDlh5EDnz7n2uw+jgu6DnEMtH1Tj2EKD0zrTY1dPKFayvR9ckkqJGi/iS0HSnioh/m2qDv/+pnA2/Ph04sXMgK3nrig7k6bhI4WjiCd2SxLLWtH+qOA+a7corRGHMuSW/kKQvj9TDlk26Pk7SuTAbfVW9T1zjb4ml1jY8ug+C4x3Jxi4cHkXz2T7PBWgdsotiz5CdZTvzeE9o+pBAjc6NtN5JqNJyIDojsBFOBRE7kJbbmm8+cPVcHvwT1+T56FoJfOrHoSxbK3egHOB0UiaOSCzHkLbAry94bkc3id+AtH0IU/gDQGkiSyhamo7MeB8=----ATTACHMENT:----OTAwMjYwODY1ODU2MTk2NCA1MDYxOTI3OTAxMDM5NTc3IDU2NTYzNjAwNjIxNzE2ODg=