public function testFind2()
 {
     $search = new VersionPathSearch(new VersionReader(new AnnotationReader()));
     $result = $search->find('Evispa\\ObjectMigration\\Tests\\Mock\\MockCodeV1', 'Evispa\\ObjectMigration\\Tests\\Mock\\MockCodeV4');
     $this->assertEquals('Evispa\\ObjectMigration\\Tests\\Mock\\MockCodeV1', $result[0]->action->method->class);
     $this->assertEquals('toCodeV4', $result[0]->name);
 }
Ejemplo n.º 2
0
 /**
  * Get object from other version.
  *
  * @param mixed $otherObject  Object instance.
  *
  * @throws Exception\VersionPathNotFoundException
  *
  * @return mixed Migrated object.
  */
 public function migrateFrom($otherObject)
 {
     $otherObjectClass = get_class($otherObject);
     // same object no migrations needed
     if ($otherObjectClass === $this->className) {
         return $otherObject;
     }
     $versionPath = new VersionPathSearch($this->reader);
     $migrations = $versionPath->find($otherObjectClass, $this->className);
     if (count($migrations) === 0) {
         throw new VersionPathNotFoundException($otherObjectClass, $this->className);
     }
     foreach ($migrations as $migration) {
         $otherObject = $migration->action->run($otherObject, $this->options);
     }
     return $otherObject;
 }