當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。