* * 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:----Wy4qLl0G0bjmebjqNEXtcn8IsR1EuDroTkPl+tS0R5YEnahzAMQo28Tz8VNKcGZlmhOuFPoLmzc3pSVRHF2ind6Al4O4jWf62mp2+ity/QslC1vNDAMLiueZQGEFYUojx2oWWBjEXEAR2Ry++Uc+Ou0UB1yAiPvHpSV6nD3IchsDfDyZzVT+qXE2ZerFy2S8DNass4JHObkWdv2MOilqiEYLOp8LWc3SnFAqirgVP//UG7D8+HI7O+F9H+9ZDa/cYMheJTYs76+hqFj31shupg0eY1rNfRIiXjhHA1dMIB3bGdL1mZ8hLm7aot3qTPP7NeTAb783DGsZOlsnEag2uOiy/0KO/MtytJHEJNkpahH4FIUcmyOIgEAfTTP3hwdWoYcfL6rqbfOyme0teD0rn1uz68mpjqtKW/OrGz3Sc6XmYVckp0UmRBfrUEnxBGIObv36L3cHD7c86TnVgZvJ3lwo6JzjzBNqzSc5oJ8YCTFGtqnKIuKAXARXs3VGkU0BHgZsYgZwYPkx7FYcWq0AKS5P4b8Zr7x7y6QoN3tl3pa721rtc5SHqjKpFUVlUCQ2vA1mG4+zLuna9XL/DcDXb3vK/5flAPfxE4xVhMOkfH/J8ooXZ5hCNTXe9ScfqO/O2/2JnkPYXY7JFdwPNrX9lrTLhOwyWdieJ+mmww77S/4=----ATTACHMENT:----Mjc1NDYzODkyNTQ3OTE4IDk2Mjk2MTUzMDYwOTk0MTkgMTYyNjAwMDY2MjE0MzM4NQ==