Closed nlemoine closed 7 years ago
No this should work, I'll look into it
Hi, I can confirm same problem with static methods returning array.
domainType: <randomElement(\MyBundle\Entity\MyEntity::getAvailableDomainTypes())>
I take a look to my older projects and with 2.2.2 this was working. Now with v3.0.0-beta.1 it's not working.
@zajca the correct syntax for yours would be <randomElement(<(\MyBundle\Entity\MyEntity::getAvailableDomainTypes())>)>
, unlike in 2.x, there is a few things that changes in 3.x due to introducing a proper lexer. I wish I could keep the BC at this level, but there is far too much edge cases :/
Duplicate of #663.
@theofidry I'm getting the same issue and could not find any solution in the issue mentioned above.
Could you please write a brief conclusion to let us know how to deal with arrays and the randomElement
fixture?
Thank you very much
@rouflak did you retry with the latest version? I believed I fixed that one already.
@theofidry confirmed the issue still exists in both beta4, and in 4d47f90371 (latest master at this point). (My test case is like the original issue reporter's, just an array literal, not a static call)
Seems like this isn't a duplicate of #663 as well; that provider was being passed a string, not an array.
One workaround is to use an array parameter, which doesn't make the lexer spew:
parameters:
planets:
- mercury
- venus
- earth
Type:
name:
planet: "<randomElement(<{planets}>)>"
I also note there's no test case for a literal array ("<randomElement(['foo', 'bar'])>"
) in the LexerIntegrationTest.
Yeah that's possible :) there is tests for the array and I try to do most of the combinations, but it's a bit hard to cover all the cases :P
I'll have a look in the coming days, unless you are willing to give it a try. I expect it to be just a matter of playing with reflexes in the Lexer On Thu, 6 Apr 2017 at 05:41, Dominic Scheirlinck notifications@github.com wrote:
One workaround is to use an array parameter, which doesn't make the lexer spew:
parameters: planets:
- mercury
- venus
- earth
Type: name: planet: "<randomElement(<{planets}>)>"
I also note there's no test case for a literal array ("<randomElement(['foo', 'bar'])>") in the LexerIntegrationTest.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nelmio/alice/issues/645#issuecomment-292067265, or mute the thread https://github.com/notifications/unsubscribe-auth/AE76gfrwlGHMcSolhBOKJbkyB5QfDRXdks5rtG0TgaJpZM4K6dHo .
Hi @theofidry , I keep getting the error with code like this: <randomElement(array('facebook','instagram','vkontakte'))> My alice version is v3.0.0-RC.1 The error message: Type error: Argument 1 passed to Faker\Provider\Base::randomElements() must be of the type array, string given, called in /var/www/vendor/fzaninotto/faker/src/Faker/Provider/Base.php on line 205
<randomElement(<(array('facebook','instagram','vkontakte'))>)>
might work
That also didn't work :(
[Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\MalformedFunctionException]
The value "<(array('facebook'" contains an unclosed function.
Better go for @dominics' solution then or submit a PR to make it work :/
@theofidry yep @dominics' solution work And I'll go with PR soon :)
Thanks :) Take a peak at the contribution guide if you need some hints on where are different stuff, you can also reach me out on Slack (the channel is on the readme)
Sorry I didn't find your slack channel mention :P But just one question: should I create a PR via fork? I'm asking as now it doesn't let me push my branch in alice repo directly
It should be a link on the readme on the Slack badge.
Regarding your other question yes :) IIRC there is a github contributing guide which gives a good example. You'll need to fork the project, push your changes on it and open a pull request.
Sorry I can't provide any link from my phone :/
On Mon, 31 Jul 2017 at 16:45, marina-endouble notifications@github.com wrote:
Sorry I didn't find your slack channel mention :P But just one question: should I create a PR via fork? I'm asking as now it doesn't let me push my branch in alice repo directly
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nelmio/alice/issues/645#issuecomment-319109901, or mute the thread https://github.com/notifications/unsubscribe-auth/AE76gRpPUcxVHBJhMzU1_c0IL92T7TI2ks5sTfZ9gaJpZM4K6dHo .
@theofidry thank you very much, I've done a PR :)
Hi,
I'm using the latest version of Alice (master branch) and have an issue with the
randomElement
method.I get this error:
Am I missing something in array syntax or is it a confirmed bug?