Expand Up
@@ -18,18 +18,12 @@
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class DoctrineChoiceLoaderTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ChoiceListFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $factory;
/**
* @var ObjectManager|\PHPUnit_Framework_MockObject_MockObject
*/
Expand Down
Expand Up
@@ -98,44 +92,68 @@ protected function setUp()
public function testLoadChoiceList()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$choiceList = new ArrayChoiceList(array());
$value = function () {};
$choiceList = new ArrayChoiceList($choices, $value);
$this->repository->expects($this->once())
->method('findAll')
->willReturn($choices);
$this->factory->expects($this->once())
->method('createListFromChoices')
->with($choices, $value)
->willReturn($choiceList);
$this->assertEquals($choiceList, $loader->loadChoiceList($value));
$this->assertSame($choiceList, $loader->loadChoiceList($value));
// no further loads on subsequent calls
$this->assertEquals($choiceList, $loader->loadChoiceList($value));
}
/**
* @group legacy
*/
public function testLegacyLoadChoiceList()
{
$factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
$loader = new DoctrineChoiceLoader(
$factory,
$this->om,
$this->class,
$this->idReader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$value = function () {};
$choiceList = new ArrayChoiceList($choices, $value);
$this->repository->expects($this->once())
->method('findAll')
->willReturn($choices);
$factory->expects($this->never())
->method('createListFromChoices');
$this->assertEquals($choiceList, $loaded = $loader->loadChoiceList($value));
// no further loads on subsequent calls
$this->assertSame($choiceList , $loader->loadChoiceList($value));
$this->assertSame($loaded , $loader->loadChoiceList($value));
}
public function testLoadChoiceListUsesObjectLoaderIfAvailable()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader,
$this->objectLoader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$choiceList = new ArrayChoiceList(array() );
$choiceList = new ArrayChoiceList($choices );
$this->repository->expects($this->never())
->method('findAll');
Expand All
@@ -144,39 +162,27 @@ public function testLoadChoiceListUsesObjectLoaderIfAvailable()
->method('getEntities')
->willReturn($choices);
$this->factory->expects($this->once())
->method('createListFromChoices')
->with($choices)
->willReturn($choiceList);
$this->assertSame($choiceList, $loader->loadChoiceList());
$this->assertEquals($choiceList, $loaded = $loader->loadChoiceList());
// no further loads on subsequent calls
$this->assertSame($choiceList , $loader->loadChoiceList());
$this->assertSame($loaded , $loader->loadChoiceList());
}
public function testLoadValuesForChoices()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$choiceList = new ArrayChoiceList($choices);
$this->repository->expects($this->once())
->method('findAll')
->willReturn($choices);
$this->factory->expects($this->once())
->method('createListFromChoices')
->with($choices)
->willReturn($choiceList);
$this->assertSame(array('1', '2'), $loader->loadValuesForChoices(array($this->obj2, $this->obj3)));
// no further loads on subsequent calls
Expand All
@@ -187,7 +193,6 @@ public function testLoadValuesForChoices()
public function testLoadValuesForChoicesDoesNotLoadIfEmptyChoices()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
Expand All
@@ -196,16 +201,12 @@ public function testLoadValuesForChoicesDoesNotLoadIfEmptyChoices()
$this->repository->expects($this->never())
->method('findAll');
$this->factory->expects($this->never())
->method('createListFromChoices');
$this->assertSame(array(), $loader->loadValuesForChoices(array()));
}
public function testLoadValuesForChoicesDoesNotLoadIfSingleIntId()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
Expand All
@@ -218,9 +219,6 @@ public function testLoadValuesForChoicesDoesNotLoadIfSingleIntId()
$this->repository->expects($this->never())
->method('findAll');
$this->factory->expects($this->never())
->method('createListFromChoices');
$this->idReader->expects($this->any())
->method('getIdValue')
->with($this->obj2)
Expand All
@@ -232,15 +230,13 @@ public function testLoadValuesForChoicesDoesNotLoadIfSingleIntId()
public function testLoadValuesForChoicesLoadsIfSingleIntIdAndValueGiven()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$value = function (\stdClass $object) { return $object->name; };
$choiceList = new ArrayChoiceList($choices, $value);
$this->idReader->expects($this->any())
->method('isSingleId')
Expand All
@@ -250,11 +246,6 @@ public function testLoadValuesForChoicesLoadsIfSingleIntIdAndValueGiven()
->method('findAll')
->willReturn($choices);
$this->factory->expects($this->once())
->method('createListFromChoices')
->with($choices, $value)
->willReturn($choiceList);
$this->assertSame(array('B'), $loader->loadValuesForChoices(
array($this->obj2),
$value
Expand All
@@ -264,7 +255,6 @@ public function testLoadValuesForChoicesLoadsIfSingleIntIdAndValueGiven()
public function testLoadValuesForChoicesDoesNotLoadIfValueIsIdReader()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
Expand All
@@ -279,9 +269,6 @@ public function testLoadValuesForChoicesDoesNotLoadIfValueIsIdReader()
$this->repository->expects($this->never())
->method('findAll');
$this->factory->expects($this->never())
->method('createListFromChoices');
$this->idReader->expects($this->any())
->method('getIdValue')
->with($this->obj2)
Expand All
@@ -296,24 +283,17 @@ public function testLoadValuesForChoicesDoesNotLoadIfValueIsIdReader()
public function testLoadChoicesForValues()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$choiceList = new ArrayChoiceList($choices);
$this->repository->expects($this->once())
->method('findAll')
->willReturn($choices);
$this->factory->expects($this->once())
->method('createListFromChoices')
->with($choices)
->willReturn($choiceList);
$this->assertSame(array($this->obj2, $this->obj3), $loader->loadChoicesForValues(array('1', '2')));
// no further loads on subsequent calls
Expand All
@@ -324,7 +304,6 @@ public function testLoadChoicesForValues()
public function testLoadChoicesForValuesDoesNotLoadIfEmptyValues()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
Expand All
@@ -333,16 +312,12 @@ public function testLoadChoicesForValuesDoesNotLoadIfEmptyValues()
$this->repository->expects($this->never())
->method('findAll');
$this->factory->expects($this->never())
->method('createListFromChoices');
$this->assertSame(array(), $loader->loadChoicesForValues(array()));
}
public function testLoadChoicesForValuesLoadsOnlyChoicesIfSingleIntId()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader,
Expand All
@@ -362,9 +337,6 @@ public function testLoadChoicesForValuesLoadsOnlyChoicesIfSingleIntId()
$this->repository->expects($this->never())
->method('findAll');
$this->factory->expects($this->never())
->method('createListFromChoices');
$this->objectLoader->expects($this->once())
->method('getEntitiesByIds')
->with('idField', array(4 => '3', 7 => '2'))
Expand All
@@ -386,15 +358,13 @@ public function testLoadChoicesForValuesLoadsOnlyChoicesIfSingleIntId()
public function testLoadChoicesForValuesLoadsAllIfSingleIntIdAndValueGiven()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader
);
$choices = array($this->obj1, $this->obj2, $this->obj3);
$value = function (\stdClass $object) { return $object->name; };
$choiceList = new ArrayChoiceList($choices, $value);
$this->idReader->expects($this->any())
->method('isSingleId')
Expand All
@@ -404,11 +374,6 @@ public function testLoadChoicesForValuesLoadsAllIfSingleIntIdAndValueGiven()
->method('findAll')
->willReturn($choices);
$this->factory->expects($this->once())
->method('createListFromChoices')
->with($choices, $value)
->willReturn($choiceList);
$this->assertSame(array($this->obj2), $loader->loadChoicesForValues(
array('B'),
$value
Expand All
@@ -418,7 +383,6 @@ public function testLoadChoicesForValuesLoadsAllIfSingleIntIdAndValueGiven()
public function testLoadChoicesForValuesLoadsOnlyChoicesIfValueIsIdReader()
{
$loader = new DoctrineChoiceLoader(
$this->factory,
$this->om,
$this->class,
$this->idReader,
Expand All
@@ -439,9 +403,6 @@ public function testLoadChoicesForValuesLoadsOnlyChoicesIfValueIsIdReader()
$this->repository->expects($this->never())
->method('findAll');
$this->factory->expects($this->never())
->method('createListFromChoices');
$this->objectLoader->expects($this->once())
->method('getEntitiesByIds')
->with('idField', array('2'))
Expand Down
[Security] Expose the required roles in AccessDeniedException #18661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
[Security] Expose the required roles in AccessDeniedException #18661
Changes from 2 commits
474296261e5ddc52384cf6f056324f13a767475aa80f47712e7e9bef22f7ed719764af2c3a7cccfc578a7ccfdb4b030c248f206c8a589635bf7a5c52f8124740f4c57afed2f8e870758fb10b33414a4b488cf87e85e506092d80c9c4e440c84d31fa693a8322d03ee88868e0e9800cddbe0b8f09cbec2ca39afd0f2ee67fa4ce06304f26590691506a41f3598549e0526eca5d92a7f10fc3cb0beb8c27efce0299d17c1a981f4f6324e08e9f7669be1298ce566afa01a0b4ae771caebee949d343779ee433402eab57a83f6ede0b043f95149af416d17d59a7078e27f120b35cd36097b25d39aaa80b45d9baf51b428d0f7b84aded422399702d1dea17ec26e6e03a42eaa3bb0d3f47f7a21af88358a4ccc26347db10ca1fb15fec78304bccf40c70306f5c86dd84b7f7cc616158eb665998ff339be648476791fe633989b160185c4ed70c428a40d2f67912fba8416045ce2c8ae99aa83c47306c40bcd8cef1915764228f5428a92f7204447b2af2db1a4d568db8f906bed60ba434e7bc53cb578356d15da2757f90d42eb0eae5d2ed6267d4a0be68b6267c85128cd33ea392ab4fbcb3e770e2ef3b232404398373f86eae4976c7f777c19346b379bfe6841cd08cbe640c0c52082f1b50b3b0d57701fead6b38d11cca74076708ecc44d71cd870753fbeb2994ac9f723282d5f91072e675f41429c74d639c0ca19080962fcc188e916358d4a680910ecc03f5e86cbbfba9cc947e24dff4f193e1814b8cd2a0c19c4adad4bbc1f7733441f152e98c8280056f72e811cbd341889c581cd462f0dbf473263a808dcc835f201fa0d7cbe7eab6b9deb12ae731aefd1bd6da658c8b71dbd1ee03726aa10c147facd9e036d9f1a7243dff0e2f586a3c1a2a0a95c60c87bd4ac5e99a90be64e9994884a2eb088978ab8c2c7f361e52f46a17693608dc45b9c62e41a3525213778d4cdb005556fa53fe9802e437e0406879e9f2599e436ec08544df6a40fc2b627b5d55d98bcb91988eba1647e6ba1ea90c3414d9efb38d8d9c221908031b850282eb9ccf691fb8a2d5cd17de127cbd1915a8f3a9356c720688fdcea583a45d89bb250ad7db01b2f3a8b00f1b7ba5a03aaa84ea7a6d24c55eccbe67695549f667ad7054043a0194dcf3bd2e79598dc69e35ba47890e95a6c02933d3a57de126dfa2faaff0d119e9cbec7fa99e1d5f39175ebbf8b6bbe43cbc1e54ec3a4ed52a25bbFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.