Esempio n. 1
0
 public function getCollection()
 {
     if ($this->collection) {
         return $this->collection;
     }
     $versions = array();
     $finder = new Finder();
     $finder->name('/Version[0-9]{12}.php/');
     $finder->files();
     foreach ($this->paths as $path) {
         $finder->in($path);
     }
     foreach ($finder as $versionFile) {
         $className = $versionFile->getBasename('.php');
         require_once $versionFile->getRealPath();
         $classFqn = MigratorUtil::getClassNameFromFile($versionFile->getRealPath());
         $version = new $classFqn();
         if (!$version instanceof VersionInterface) {
             throw new MigratorException(sprintf('Version class "%s" must implement VersionInterface', $className));
         }
         $versionTimestamp = substr($versionFile->getBaseName(), 7, 12);
         $versions[$versionTimestamp] = $version;
     }
     $this->collection = new VersionCollection($versions);
     return $this->collection;
 }
 /**
  * It should return the classname of a file.
  */
 public function testGetClassName()
 {
     $className = MigratorUtil::getClassNameFromFile(__DIR__ . '/migrations/Version201511240843.php');
     $this->assertEquals('\\Sulu\\Bundle\\ContentBundle\\Version201511240843', $className);
 }