public function testLoadFromEntity()
 {
     // Get choices From Entity, count($this->identifier) > 1
     $fooA = new Foo();
     $fooA->setBar(1);
     $fooB = new Foo();
     $fooB->setBar(2);
     $result = array($fooA, $fooB);
     $this->modelManager->expects($this->once())->method('findBy')->will($this->returnValue($result));
     $modelChoice = new ModelChoiceList($this->modelManager, 'Sonata\\AdminBundle\\Tests\\Fixtures\\Entity\\Foo', 'bar');
     $this->assertSame(array_keys($result), $modelChoice->getChoices());
 }
 public function testLoadFromEntityWithSamePropertyValues()
 {
     $fooA = new Foo();
     $fooA->setBar(1);
     $fooA->setBaz('baz');
     $fooB = new Foo();
     $fooB->setBar(2);
     $fooB->setBaz('baz');
     $this->modelManager->expects($this->once())->method('findBy')->will($this->returnValue(array($fooA, $fooB)));
     $this->modelManager->expects($this->any())->method('getIdentifierValues')->will($this->returnCallback(function (Foo $foo) {
         return array($foo->getBar());
     }));
     $modelChoiceLoader = new ModelChoiceLoader($this->modelManager, 'Sonata\\AdminBundle\\Tests\\Fixtures\\Entity\\Foo', 'baz');
     $expectedChoices = array(1 => 'baz (id: 1)', 2 => 'baz (id: 2)');
     $this->assertSame($expectedChoices, $modelChoiceLoader->loadChoiceList()->getOriginalKeys());
 }