テスト用にプロジェクトにいくつかのフィクスチャを作成したいと考えています。今はコマンド ライン スクリプトでこれを行っていますが、Doctrine から DataFixtures バンドルを見つけたので、テストしたいと思いました。次のコードがあります。
<?php
// src/Pan100/MoodLogBundle/DataFixtures/ORM/LoadUserData.php
namespace Acme\HelloBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAware;
use Pan100\MoodLogBundle\Entity\Day;
use Pan100\MoodLogBundle\Entity\Medication;
use Pan100\MoodLogBundle\Entity\Trigger;
use FOS\UserBundle\Doctrine\UserManager;
class MockDataMaker extends ContainerAware
{
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$userManager = $container->get('fos_user.user_manager');
//make some users
$user = $userManager->createUser();
$user->setUsername('John');
$user->setEmail('john.doe@example.com');
$user->setPlainPassword('passord');
$userManager->updateUser($user);
}
}
そして、私はこれを取得します:
[InvalidArgumentException]
Could not find any fixtures to load in:
- /var/www/path/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/D
ataFixtures/ORM
- /var/www/path/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Da
taFixtures/ORM
- /var/www/path/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/DataFi
xtures/ORM
- /var/www/path/vendor/symfony/monolog-bundle/Symfony/Bundle/MonologBundle/
DataFixtures/ORM
- /var/www/path/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/Swiftmaile
rBundle/DataFixtures/ORM
- /var/www/path/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/
DataFixtures/ORM
- /var/www/path/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBun
dle/DataFixtures/ORM
- /var/www/path/vendor/sensio/framework-extra-bundle/Sensio/Bundle/Framewor
kExtraBundle/DataFixtures/ORM
- /var/www/path/vendor/jms/aop-bundle/JMS/AopBundle/DataFixtures/ORM
- /var/www/path/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/DataFixtures/O
RM
- /var/www/path/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/Da
taFixtures/ORM
- /var/www/path/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DataFixt
ures/ORM
- /var/www/path/src/Pan100/MoodLogBundle/DataFixtures/ORM
- /var/www/path/vendor/sonata-project/intl-bundle/Sonata/IntlBundle/DataFix
tures/ORM
- /var/www/path/vendor/ob/highcharts-bundle/Ob/HighchartsBundle/DataFixture
s/ORM
- /var/www/path/vendor/doctrine/doctrine-fixtures-bundle/Doctrine/Bundle/Fi
xturesBundle/DataFixtures/ORM
- /var/www/path/src/Acme/DemoBundle/DataFixtures/ORM
- /var/www/path/vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle
/DataFixtures/ORM
- /var/www/path/vendor/sensio/distribution-bundle/Sensio/Bundle/Distributio
nBundle/DataFixtures/ORM
- /var/www/path/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundl
e/DataFixtures/ORM
私の質問は、FOSUserBundle を使用してフィクスチャでユーザーを作成する方法ですか?