Пример #1
0
 public function setUp()
 {
     $this->setFs(new Filesystem());
     // generate unique working path for future use in commands
     $this->setWorkingPath(PATH_TMP . DS . $this->getFaker()->uuid);
     $loader = new Yaml();
     $fixture = $loader->load(__DIR__ . DS . 'Resources' . DS . 'fixtures' . DS . 'application.yml');
     $this->setApplication(current($fixture));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!file_exists($input->getArgument('wp-config'))) {
         throw new \InvalidArgumentException($input->getArgument('wp-config') . 'could not be loaded');
     }
     require $input->getArgument('wp-config');
     $loader = new Yaml('de_DE', array(new WordpressProvider()), 1024);
     $objects = $loader->load($input->getArgument('faker-file'));
     $this->persister->persist($objects);
     $output->writeln(sprintf('<info>%d</info> Posts successfully created', count($objects)));
 }
 /**
  * Перебирает все файлы, генерирует из содержимого сущности, и возвращает массив с наборами сущностей.
  *
  * @return array
  */
 private function compileListOfEntitiesFromFiles()
 {
     $entitiesList = [];
     $finder = (new Finder())->files()->name('*.' . FixturesLoader::DEFAULT_FILE_EXTENSION)->in($this->dirWithFixtures);
     foreach ($finder as $file) {
         /** @var SplFileInfo $file */
         $entities = self::$nelmioLoader->load($file->getRealPath());
         $arrayKeys = array_keys($entities);
         $className = get_class($entities[$arrayKeys[0]]);
         if (!isset($entitiesList[$className])) {
             $entitiesList[$className] = [];
         }
         $entitiesList[$className] = array_merge($entitiesList[$className], $entities);
     }
     return $entitiesList;
 }
 public function testRun()
 {
     (new FixturesFromDBGenerator())->generateFixtures($this->em, self::$dir, self::$fullClassNames, 10, 2);
     /** @var  $loader */
     $loader = new Yaml();
     $this->assertEquals(2, (new Finder())->files()->name("Author_*.yml")->in(self::$dir)->count());
     $this->assertEquals(5, (new Finder())->files()->name("Book_*.yml")->in(self::$dir)->count());
     $finder = (new Finder())->files()->name('*.yml')->in(self::$dir);
     foreach ($finder as $file) {
         /** @var SplFileInfo $file */
         $objects = $loader->load($file->getPathname());
         if (count($objects) > 0) {
             $className = get_class($objects[array_keys($objects)[0]]);
             $this->assertTrue(in_array($className, self::$fullClassNames));
             foreach ($objects as $obj) {
                 $id = EntityHelper::getPrimaryKey($this->em, $obj);
                 $this->assertNotNull($this->em->getRepository($className)->find($id));
             }
         }
     }
 }
Пример #5
0
 protected function createInstance($class, $name, array &$data)
 {
     $instance = parent::createInstance($class, $name, $data);
     $this->cache[] = [$data, $instance];
     return $instance;
 }
Пример #6
0
 public function __construct($locale, ProviderResolver $providers)
 {
     parent::__construct($locale, $providers->all());
 }