Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Missing return in loadValuesForChoices method
  • Loading branch information
yceruto committed Jul 6, 2020
commit 6075debeadef7778e9fb41ecfcff1543cf812759
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public function loadChoicesForValues(array $values, callable $value = null)
*/
public function loadValuesForChoices(array $choices, callable $value = null)
{
$this->getOption()->loadValuesForChoices($choices, $value);
return $this->getOption()->loadValuesForChoices($choices, $value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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\Factory\Cache;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\Factory\Cache\ChoiceLoader;
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
use Symfony\Component\Form\FormTypeInterface;

class ChoiceLoaderTest extends TestCase
{
public function testSameFormTypeUseCachedLoader()
{
$choices = ['f' => 'foo', 'b' => 'bar', 'z' => 'baz'];
$choiceList = new ArrayChoiceList($choices);

$type = $this->createMock(FormTypeInterface::class);
$decorated = new CallbackChoiceLoader(static function () use ($choices) {
return $choices;
});
$loader1 = new ChoiceLoader($type, $decorated);
$loader2 = new ChoiceLoader($type, $this->createMock(ChoiceLoaderInterface::class));

$this->assertEquals($choiceList, $loader1->loadChoiceList());
$this->assertEquals($choiceList, $loader2->loadChoiceList());

$this->assertSame($choices, $loader1->loadChoicesForValues($choices));
$this->assertSame($choices, $loader2->loadChoicesForValues($choices));

$this->assertSame($choices, $loader1->loadValuesForChoices($choices));
$this->assertSame($choices, $loader2->loadValuesForChoices($choices));
}
}