<p dir="auto">I'm trying to test controllers using functional tests. But I can not create a test client, which would be authorized as specified user. This can be done through the form, but it is not convenient. I found a <a href="http://techblog.zabuchy.net/2012/manually-authenticate-symfony-2-user/" rel="nofollow">way</a> that allows to do this, but in version 2.1 it does not work.</p>
<p dir="auto"><a href="https://github.com/i4got10/symfony-standard/blob/test-auth/src/Acme/DemoBundle/Tests/Controller/SecuredControllerTest.php">Test code</a></p>
<p dir="auto">Is there a way to manually authorize the user or the only way to use a form or stateless basic authorization like descibed in symfony book?</p>
<p dir="auto">Something that used to work before I upgraded to 2.7 doesn't anymore: setting a NULL value in a dropdown field. I've created a test bundle demonstrating the problem:</p>
<p dir="auto"><a href="https://github.com/userfriendly/form-field-null-test-bundle">https://github.com/userfriendly/form-field-null-test-bundle</a></p>
<p dir="auto">Have a look at the README and the code, and if you're not seeing anything obvious, install the bundle in a test project using Symfony 2.7 - I'm hoping it's something I'm doing wrong, but I think the code is correct according to the documentation, and it worked in earlier Symfony versions.</p>
<p dir="auto">Add an employee with a vendor. Then add an employee without a vendor. If all works as intended (or rather, as not intended) you should get an error message for the latter, saying "This value is not valid."</p>
<p dir="auto">The idea here is that I want to be able to create an employee instance without a vendor, i.e. the form should allow setting that field to NULL.</p>
<p dir="auto">The mapping explicitly allows the entity property to be nullable, the setter accepts NULL as a parameter, and the form field is configured as 'required' =&gt; false. Is there something more needed to get this working in 2.7, or is this a bug?</p>
<p dir="auto">Tested on Symfony 2.7.0-BETA1</p>