This course is archived!
Making Fixtures Really Awesome with Alice
'Turn your fixtures from drab to fab with Alice! Experience the game-changing way to annotate your Symfony test content.'
About this course
Fixtures: those little bits of test data you load (and reload) locally so that you can test your site with some real-ish content. Until now, creating fixtures was boring. But with Alice, they're video-game-level exciting. Seriously!
Next courses in the Symfony 2: Young Jedi section of the Symfony 2 Track!
11 Comments
Hey there!
Actually, I don't think this is possible right now - that value is "locked up" in a class from "Alice" that we can't access. You can use most of the Faker functions inside your custom formatter/provider by creating your own Faker instance:
$faker = \Faker\Factory::create('en');
var_dump($faker->company);
But current() is the one formatter that's different, and we can't get to it. You also can't nest formatters (e.g. <avatar(<current()>)>, which would be kind of cool :).
Cheers!
I followed this tutorial, and nothing loads into my DB, yet no error displayed. Any idea? Can it be linked to the newer version of the HautelookAliceBundle?
Hey Martin,
Yes, it can be. What version do you use? Many concepts are the same, but they change something in the new version. What command do you run to load your fixtures? What output exactly do you have after this command?
Cheers!
Well,
Here is my composer.json
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.2.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/monolog-bundle": "^3.0.2",
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0",
"nelmio/alice": "3.0.*@beta",
"hautelook/alice-bundle": "2.0.*@beta",
"theofidry/alice-data-fixtures": "1.0.*@beta",
"doctrine/data-fixtures": "^1.2",
"doctrine/doctrine-fixtures-bundle": "^2.3"
},
I tried with creating a fixture class in php like in the tutorial and adding my .yml in it and used app/console doctrine:fixtures:load, it does ask me if I want to purge my data, I say yes, and the prompt returns without error, and no data in DB.
Then I look at the alice bundle doc, and added
# app/config/config_dev.yml
hautelook_alice:
fixtures_path: 'Resources/fixtures/orm' # Path to which to look for fixtures relative to the bundle path.
and tried using bin/console hautelook:fixtures:load and samething happens, purge data prompt, then the prompt returns without error and no DB.
Can you spot anything wrong?
I finally got it to work, following Alice-Bundle instructions!
I am having the same problem. Could you specify what you missed before and what you did to fix it?
Hey Daniëlle Suurlant ,
Till we're waiting for Martin, could you double check the docs step by step? I bet you miss an important step in their README.
Cheers!
I eventually found out it was a bug: https://github.com/hauteloo...
I was able to fix it by putting the yaml files into AppBundle/Resources/fixtures/orm instead of app/Resources/fixtures/orm.
Good catch, thank you for sharing it with other users!
Cheers!
Hey Martin,
Glad you got it working so fast! Docs FTW! :)
Cheers!
Is there any easy way to get access to current() in my custom provider?