当前位置: 首页>>代码示例>>PHP>>正文


PHP Loader::addFixture方法代码示例

本文整理汇总了PHP中Doctrine\Common\DataFixtures\Loader::addFixture方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::addFixture方法的具体用法?PHP Loader::addFixture怎么用?PHP Loader::addFixture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\DataFixtures\Loader的用法示例。


在下文中一共展示了Loader::addFixture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     Artisan::call('doctrine:schema:create');
     $this->em = App::make('Doctrine\\ORM\\EntityManagerInterface');
     $this->repository = new PostDoctrineORMRepository($this->em);
     $this->executor = new ORMExecutor($this->em, new ORMPurger());
     $this->loader = new Loader();
     $this->loader->addFixture(new PostFixtures());
 }
开发者ID:kfuchs,项目名称:cribbb,代码行数:10,代码来源:PostDoctrineORMRepository.php

示例2: testLoader

 public function testLoader()
 {
     $loader = new Loader();
     $loader->addFixture($this->getMock('Doctrine\\Common\\DataFixtures\\FixtureInterface'), array(), array(), 'Mock1');
     $loader->addFixture($this->getMock('Doctrine\\Common\\DataFixtures\\FixtureInterface', array(), array(), 'Mock2'));
     $loader->addFixture($this->getMock('Doctrine\\Common\\DataFixtures\\SharedFixtureInterface', array(), array(), 'Mock3'));
     $this->assertEquals(3, count($loader->getFixtures()));
     $loader->loadFromDirectory(__DIR__ . '/TestFixtures');
     $this->assertEquals(7, count($loader->getFixtures()));
     $this->assertTrue($loader->isTransient('TestFixtures\\NotAFixture'));
     $this->assertFalse($loader->isTransient('TestFixtures\\MyFixture1'));
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:12,代码来源:LoaderTest.php

示例3: testLoader

    public function testLoader()
    {
        $loader = new Loader();
        $loader->addFixture($this->getMock('Doctrine\Common\DataFixtures\FixtureInterface'));
        $loader->addFixture($this->getMock('Doctrine\Common\DataFixtures\FixtureInterface'));

        $this->assertEquals(2, count($loader->getFixtures()));

        $loader->loadFromDirectory(__DIR__.'/TestFixtures');
        $this->assertEquals(4, count($loader->getFixtures()));
        $this->assertTrue($loader->isTransient('TestFixtures\NotAFixture'));
        $this->assertFalse($loader->isTransient('TestFixtures\MyFixture1'));
    }
开发者ID:roverwolf,项目名称:data-fixtures,代码行数:13,代码来源:LoaderTest.php

示例4: testFixtureOrder

 public function testFixtureOrder()
 {
     $loader = new Loader();
     $loader->addFixture(new OrderedFixture1());
     $loader->addFixture(new OrderedFixture2());
     $loader->addFixture(new OrderedFixture3());
     $loader->addFixture(new BaseFixture1());
     $orderedFixtures = $loader->getFixtures();
     $this->assertCount(4, $orderedFixtures);
     $this->assertInstanceOf(__NAMESPACE__ . '\\BaseFixture1', $orderedFixtures[0]);
     $this->assertInstanceOf(__NAMESPACE__ . '\\OrderedFixture2', $orderedFixtures[1]);
     $this->assertInstanceOf(__NAMESPACE__ . '\\OrderedFixture1', $orderedFixtures[2]);
     $this->assertInstanceOf(__NAMESPACE__ . '\\OrderedFixture3', $orderedFixtures[3]);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:14,代码来源:OrderedFixtureTest.php

示例5: testFixtureOrder

 public function testFixtureOrder()
 {
     $loader = new Loader();
     $loader->addFixture(new OrderedFixture1());
     $loader->addFixture(new OrderedFixture2());
     $loader->addFixture(new OrderedFixture3());
     $loader->addFixture(new BaseFixture1());
     $orderedFixtures = $loader->getFixtures();
     $this->assertEquals(4, count($orderedFixtures));
     $this->assertTrue($orderedFixtures[0] instanceof BaseFixture1);
     $this->assertTrue($orderedFixtures[1] instanceof OrderedFixture2);
     $this->assertTrue($orderedFixtures[2] instanceof OrderedFixture1);
     $this->assertTrue($orderedFixtures[3] instanceof OrderedFixture3);
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:14,代码来源:OrderedFixtureTest.php

示例6: beforeScenario

 /**
  * @BeforeScenario
  */
 public function beforeScenario()
 {
     $loader = new Loader();
     $loader->addFixture(new \Stfalcon\Bundle\EventBundle\DataFixtures\ORM\LoadEventData());
     $loader->addFixture(new \Stfalcon\Bundle\EventBundle\DataFixtures\ORM\LoadNewsData());
     $loader->addFixture(new \Application\Bundle\UserBundle\DataFixtures\ORM\LoadUserData());
     $this->em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->em->getConnection()->executeUpdate("SET foreign_key_checks = 0;");
     $purger = new ORMPurger();
     $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->purge();
     $executor->execute($loader->getFixtures(), true);
     $this->em->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
 }
开发者ID:bolotyuh,项目名称:fwdays,代码行数:18,代码来源:FeatureContext.php

示例7: setUp

 public function setUp()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $this->application = new Application(static::$kernel);
     // drop the database
     $command = new DropDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(['command' => 'doctrine:database:drop', '--force' => true]);
     $command->run($input, new NullOutput());
     // we have to close the connection after dropping the database so we don't get "No database selected" error
     $connection = $this->application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     // create the database
     $command = new CreateDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(['command' => 'doctrine:database:create']);
     $command->run($input, new NullOutput());
     // create schema
     $command = new CreateSchemaDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(['command' => 'doctrine:schema:create']);
     $command->run($input, new NullOutput());
     // get the Entity Manager
     $this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
     // load fixtures
     // not work
     //        $client = static::createClient();
     //        $loader = new ContainerAwareLoader($client->getContainer());
     //        $loader->loadFromDirectory(static::$kernel->locateResource('@Art\JobtestBundle\DataFixtures\ORM'));
     //
     //        $purger = new ORMPurger($this->em);
     //        $executor = new ORMExecutor($this->em, $purger);
     //        $executor->execute($loader->getFixtures());
     $loader = new Loader();
     $loader->addFixture(new LoadCategoryData());
     $loader->addFixture(new LoadJobData());
     $loader->addFixture(new LoadAffiliateData());
     $userFixture = new LoadUserData();
     $userFixture->setContainer(static::$kernel->getContainer());
     $loader->addFixture($userFixture);
     $purger = new ORMPurger($this->em);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->execute($loader->getFixtures());
     parent::setUp();
 }
开发者ID:arossokha,项目名称:symfonytest,代码行数:48,代码来源:WebTestCase.php

示例8: testLoadFromFile

 public function testLoadFromFile()
 {
     $loader = new Loader();
     $loader->addFixture($this->getMockBuilder(FixtureInterface::class)->setMockClassName('Mock1')->getMock());
     $loader->addFixture($this->getMockBuilder(FixtureInterface::class)->setMockClassName('Mock2')->getMock());
     $loader->addFixture($this->getMockBuilder(SharedFixtureInterface::class)->setMockClassName('Mock3')->getMock());
     $this->assertCount(3, $loader->getFixtures());
     $loader->loadFromFile(__DIR__ . '/TestFixtures/MyFixture1.php');
     $this->assertCount(4, $loader->getFixtures());
     $loader->loadFromFile(__DIR__ . '/TestFixtures/NotAFixture.php');
     $this->assertCount(4, $loader->getFixtures());
     $loader->loadFromFile(__DIR__ . '/TestFixtures/MyFixture2.php');
     $this->assertCount(5, $loader->getFixtures());
     $this->assertTrue($loader->isTransient('TestFixtures\\NotAFixture'));
     $this->assertFalse($loader->isTransient('TestFixtures\\MyFixture1'));
 }
开发者ID:doctrine,项目名称:data-fixtures,代码行数:16,代码来源:LoaderTest.php

示例9: addFixture

 /**
  * {@inheritdoc}
  */
 public function addFixture(FixtureInterface $fixture)
 {
     if ($fixture instanceof ContainerAwareInterface) {
         $fixture->setContainer($this->container);
     }
     parent::addFixture($fixture);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:10,代码来源:ContainerAwareLoader.php

示例10: addFixture

 public function addFixture(FixtureInterface $fixture)
 {
     if ($fixture instanceof ApplicationInterface) {
         $fixture->setApp($this->app);
     }
     parent::addFixture($fixture);
 }
开发者ID:argentinaluiz,项目名称:js-silex-fixtures,代码行数:7,代码来源:ApplicationLoader.php

示例11: testLoadFromFile

 public function testLoadFromFile()
 {
     $loader = new Loader();
     $loader->addFixture($this->getMock('Doctrine\\Common\\DataFixtures\\FixtureInterface'), array(), array(), 'Mock1');
     $loader->addFixture($this->getMock('Doctrine\\Common\\DataFixtures\\FixtureInterface', array(), array(), 'Mock2'));
     $loader->addFixture($this->getMock('Doctrine\\Common\\DataFixtures\\SharedFixtureInterface', array(), array(), 'Mock3'));
     $this->assertCount(3, $loader->getFixtures());
     $loader->loadFromFile(__DIR__ . '/TestFixtures/MyFixture1.php');
     $this->assertCount(4, $loader->getFixtures());
     $loader->loadFromFile(__DIR__ . '/TestFixtures/NotAFixture.php');
     $this->assertCount(4, $loader->getFixtures());
     $loader->loadFromFile(__DIR__ . '/TestFixtures/MyFixture2.php');
     $this->assertCount(5, $loader->getFixtures());
     $this->assertTrue($loader->isTransient('TestFixtures\\NotAFixture'));
     $this->assertFalse($loader->isTransient('TestFixtures\\MyFixture1'));
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:16,代码来源:LoaderTest.php

示例12: execute

 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  *
  * @throws LogicException When this abstract method is not implemented
  *
  * @see setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (empty($this->fixtures)) {
         $output->writeln('No fixtures found.');
         return -1;
     }
     $loader = new Loader();
     foreach ($this->fixtures as $fixture) {
         $loader->addFixture($fixture);
     }
     $purger = new ORMPurger($this->em);
     $executor = new ORMExecutor($this->em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     /** @var QuestionHelper $questionHelper */
     $questionHelper = $this->getHelper('question');
     $question = new ConfirmationQuestion('WARNING! Database will be purged before loading initialization data. Do you want to continue?', false);
     if (!$questionHelper->ask($input, $output, $question)) {
         $output->writeln('CMS initialization has been CANCELED!');
         return;
     }
     try {
         $executor->execute($loader->getFixtures());
         $output->writeln('Basic CMS data has been SUCCESSFULLY loaded!');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn("That's bad. An Error occurred: <error>{$e->getMessage()}</error>");
         return -1;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:48,代码来源:LoadBasicDataCommand.php

示例13: addFixture

 /**
  * Add a fixture object instance to the loader.
  *
  * @param FixtureInterface $fixture
  */
 public function addFixture(FixtureInterface $fixture)
 {
     if ($fixture instanceof ServiceLocatorAwareInterface) {
         $fixture->setServiceLocator($this->serviceLocator);
     }
     parent::addFixture($fixture);
 }
开发者ID:jguittard,项目名称:DoctrineDataFixtureModule,代码行数:12,代码来源:ServiceLocatorAwareLoader.php

示例14: loadWholeFixtures

 private function loadWholeFixtures()
 {
     $loader = new Loader();
     $loader->addFixture(new LoadItems());
     $purger = new ORMPurger($this->getEntityManager());
     $executor = new ORMExecutor($this->getEntityManager(), $purger);
     $executor->execute($loader->getFixtures());
 }
开发者ID:lzakrzewski,项目名称:tests-with-database-examples,代码行数:8,代码来源:FixturesLoadingTest.php

示例15: loadFixture

 /**
  * Load the given fixture
  *
  * @param \Doctrine\Common\DataFixtures\FixtureInterface $fixture
  */
 protected function loadFixture(FixtureInterface $fixture)
 {
     $loader = new Loader();
     $loader->addFixture($fixture);
     $purger = new ORMPurger();
     $executor = new ORMExecutor(static::$em, $purger);
     $executor->execute($loader->getFixtures());
 }
开发者ID:leapt,项目名称:core-bundle,代码行数:13,代码来源:DoctrineORMPaginatorTest.php


注:本文中的Doctrine\Common\DataFixtures\Loader::addFixture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。