Example #1
0
 /**
  * @dataProvider thingProvider
  * @param $patches
  */
 public function testFind($patches)
 {
     $collection = new Collection($patches);
     $patch = null;
     if (array_key_exists(0, $patches)) {
         $patch = $patches[0];
     }
     $this->assertEquals($patch, $collection->find(function () {
         return true;
     }));
 }
Example #2
0
 public function diff(Collection $patches)
 {
     if ($patches->getTable() == $this->getTable()) {
         /** @var Patch $patch */
         foreach ($patches as $patch) {
             $key = $this->matchPatch($patch);
             if (!is_null($key)) {
                 $this->remove($key);
             }
         }
     }
     $this->patches = array_values($this->patches);
 }
Example #3
0
 public function updateInstallScripts(Install $originalInstall, Collection $patched, $patchCount)
 {
     if ($patchCount >= 0) {
         $last = $patched->count() - 1;
         $patched = $patched->getIterator();
         /** @var Patch $lastPatch */
         $lastPatch = $patched->offsetGet($last);
         $table = $lastPatch->getTable();
         $postPatchInstall = $this->repository->buildInstallFromDatabase($table);
         $newInstall = $this->factory->createInstall(['table' => $table, 'patch' => $lastPatch->getPatch(), 'install' => $postPatchInstall->getInstall()]);
         $this->fileMap->updateInstall($originalInstall, $newInstall);
     }
 }