* * 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; use PHPUnit\Framework\TestCase; /** * @author Bernhard Schussek */ abstract class AbstractChoiceListTest extends TestCase { /** * @var \Symfony\Component\Form\ChoiceList\ChoiceListInterface */ protected $list; /** * @var array */ protected $choices; /** * @var array */ protected $values; /** * @var array */ protected $structuredValues; /** * @var array */ protected $keys; /** * @var mixed */ protected $choice1; /** * @var mixed */ protected $choice2; /** * @var mixed */ protected $choice3; /** * @var mixed */ protected $choice4; /** * @var string */ protected $value1; /** * @var string */ protected $value2; /** * @var string */ protected $value3; /** * @var string */ protected $value4; /** * @var string */ protected $key1; /** * @var string */ protected $key2; /** * @var string */ protected $key3; /** * @var string */ protected $key4; protected function setUp() { parent::setUp(); $this->list = $this->createChoiceList(); $choices = $this->getChoices(); $this->values = $this->getValues(); $this->structuredValues = array_combine(array_keys($choices), $this->values); $this->choices = array_combine($this->values, $choices); $this->keys = array_combine($this->values, array_keys($choices)); // allow access to the individual entries without relying on their indices reset($this->choices); reset($this->values); reset($this->keys); for ($i = 1; $i <= 4; ++$i) { $this->{'choice'.$i} = current($this->choices); $this->{'value'.$i} = current($this->values); $this->{'key'.$i} = current($this->keys); next($this->choices); next($this->values); next($this->keys); } } public function testGetChoices() { $this->assertSame($this->choices, $this->list->getChoices()); } public function testGetValues() { $this->assertSame($this->values, $this->list->getValues()); } public function testGetStructuredValues() { $this->assertSame($this->values, $this->list->getStructuredValues()); } public function testGetOriginalKeys() { $this->assertSame($this->keys, $this->list->getOriginalKeys()); } public function testGetChoicesForValues() { $values = array($this->value1, $this->value2); $this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values)); } public function testGetChoicesForValuesPreservesKeys() { $values = array(5 => $this->value1, 8 => $this->value2); $this->assertSame(array(5 => $this->choice1, 8 => $this->choice2), $this->list->getChoicesForValues($values)); } public function testGetChoicesForValuesPreservesOrder() { $values = array($this->value2, $this->value1); $this->assertSame(array($this->choice2, $this->choice1), $this->list->getChoicesForValues($values)); } public function testGetChoicesForValuesIgnoresNonExistingValues() { $values = array($this->value1, $this->value2, 'foobar'); $this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values)); } // https://github.com/symfony/symfony/issues/3446 public function testGetChoicesForValuesEmpty() { $this->assertSame(array(), $this->list->getChoicesForValues(array())); } public function testGetValuesForChoices() { $choices = array($this->choice1, $this->choice2); $this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices)); } public function testGetValuesForChoicesPreservesKeys() { $choices = array(5 => $this->choice1, 8 => $this->choice2); $this->assertSame(array(5 => $this->value1, 8 => $this->value2), $this->list->getValuesForChoices($choices)); } public function testGetValuesForChoicesPreservesOrder() { $choices = array($this->choice2, $this->choice1); $this->assertSame(array($this->value2, $this->value1), $this->list->getValuesForChoices($choices)); } public function testGetValuesForChoicesIgnoresNonExistingChoices() { $choices = array($this->choice1, $this->choice2, 'foobar'); $this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices)); } public function testGetValuesForChoicesEmpty() { $this->assertSame(array(), $this->list->getValuesForChoices(array())); } public function testGetChoicesForValuesWithNull() { $values = $this->list->getValuesForChoices(array(null)); $this->assertNotEmpty($this->list->getChoicesForValues($values)); } /** * @return \Symfony\Component\Form\ChoiceList\ChoiceListInterface */ abstract protected function createChoiceList(); abstract protected function getChoices(); abstract protected function getValues(); } __halt_compiler();----SIGNATURE:----tAVDdfJ7AIUtD+dpNbaXEOLE1LBI75zLw1qGbpsjzEh9tPFhzSqU8x5ENgA6SIKZOzGidycd6CFZWGzhPQXhEofWaS/p2R6s3Tp/lZAzUrS1uIg4EaLY5gs+6sp9st6Vg1Qj5AEKKNQ6ZdR7bTpJ6yFzcaU0jdth0g/sHAtUT3eZ5O0dJiD+VZM2H4+7RUDh8g3dQMeUp4dwCMRYTGBX0KqA5R1/34qvgC5SWyZ/5U2bprRObDSepREjLjpKBRv48P0kzolu/cxfCNR//ogRXTkaf8ntXl9RsK121+eOttiaXq2cvSLN1vVyb7T77Xv8GAiKMWZAMnupXnlRscsXSHhbsj85bcshZzLjh5Asb4zvnmIguCYk2XPyUf6PqNgfCDgJpVBI8oyulvjvTI36bOjF8GUsB1nSP5TmozOfeQO7qiSUxsnteC+hQjlui/Rz/S3MCow7pUxolJNK9WBmDmDSwYz5YnyR229KtREqkXr4ya2E4W+E8JVpCLhglxDF1usx3/aUwcjQcvQp8M0GVRN6gcCUeO1LKN7VZPu5nQJiHnTa1nSRRCaJJN4KiFH612moPldEWXWhqIEMYZxKLh3Rem+fWKeN/gWcsUpALZe1frtuEiLmZocdHNoEtEbQ1CAwCmkbsK+fAs2vcJMltOIy4XAcFYBdDbPk0Arfotc=----ATTACHMENT:----NTkwMjc5OTM5MTMzMDIwNiA1MTU5MzMwMDcwMzMyNTU0IDczOTg4ODczNjU4NzI5MDI=