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


PHP Loader::loadFromFile方法代码示例

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


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

示例1: 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

示例2: testGetFixture

 public function testGetFixture()
 {
     $loader = new Loader();
     $loader->loadFromFile(__DIR__ . '/TestFixtures/MyFixture1.php');
     $fixture = $loader->getFixture(MyFixture1::class);
     $this->assertInstanceOf(MyFixture1::class, $fixture);
 }
开发者ID:doctrine,项目名称:data-fixtures,代码行数:7,代码来源:LoaderTest.php

示例3: populateTestAction

 /**
  * Napolni podatke iz Fixtures
  */
 public function populateTestAction()
 {
     $logger = function ($message) {
         echo $message . PHP_EOL;
     };
     $em = $this->serviceLocator->get("\\Doctrine\\ORM\\EntityManager");
     $config = new Config($this->serviceLocator->get('config'));
     $loader = new Loader();
     $fixtures = isset($config->test_fixtures) ? $config->test_fixtures : [];
     $fixturename = $this->params('fixturename');
     if (!empty($fixturename)) {
         foreach ($fixtures as $dir) {
             $loader->loadFromFile($dir . '/' . $fixturename . 'Fixture.php');
             /**
              * če je dependent naj ne izvede nobenega
              */
             if (count($loader->getFixtures()) > 1) {
                 throw new \InvalidArgumentException('Loadanih več fixtur-jev -verjetno zaradi dependencies. Kot parameter možen le fixture brez odvisnosti.');
             }
         }
     } else {
         foreach ($fixtures as $dir) {
             $loader->loadFromDirectory($dir);
         }
     }
     $executor = new ORMExecutor($em);
     $executor->setLogger($logger);
     $executor->execute($loader->getFixtures(), true);
 }
开发者ID:ifigenija,项目名称:server,代码行数:32,代码来源:InstallController.php

示例4: 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:FullSpeedInc,项目名称:data-fixtures,代码行数:16,代码来源:LoaderTest.php

示例5: tearDown

 protected function tearDown()
 {
     $loader = new Loader();
     $loader->loadFromFile('src/PadelTFG/GeneralBundle/DataFixtures/ORM/SponsorTest/SponsorTestRemove.php');
     $purger = new ORMPurger();
     $executor = new ORMExecutor($this->em, $purger);
     $executor->execute($loader->getFixtures(), true);
     $this->em->close();
 }
开发者ID:albertoml,项目名称:padelTFG,代码行数:9,代码来源:SponsorControllerAPITest.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     if ($input->isInteractive() && !$input->getOption('append')) {
         if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
             return;
         }
     }
     if ($input->getOption('shard')) {
         if (!$em->getConnection() instanceof PoolingShardConnection) {
             throw new LogicException(sprintf("Connection of EntityManager '%s' must implement shards configuration.", $input->getOption('em')));
         }
         $em->getConnection()->connect($input->getOption('shard'));
     }
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = $this->paths;
     }
     $loader = new DataFixturesLoader();
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         } elseif (is_file($path)) {
             $loader->loadFromFile($path);
         }
     }
     $fixtures = $loader->getFixtures();
     if (!$fixtures) {
         throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- " . implode("\n- ", $paths)));
     }
     $purger = new ORMPurger($em);
     $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'), $input->getOption('multiple-transactions'));
 }
开发者ID:pt24,项目名称:doctrine-fixtures,代码行数:40,代码来源:LoadDataFixturesDoctrineCommand.php


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