public function testPatchTablePatchAll() { $repo = $this->createRepository(); $query = $this->createQuery(); $handle = $this->createFileHandle(); $fileMap = $this->createMap(); $dbMap = $this->createMap(); $filterFactory = $this->createFilterFactory(); $installRepository = $this->createInstallRepository(); $installer = $this->createInstaller(); $install = $this->createInstall(); $table = 'someTable'; $queryString = 'someQuery'; $error = ['something 0', 'something 1', null]; $dbCollection = $this->createCollection(); $fileCollection = $this->createCollection(); $handle->expects($this->once())->method('getAllFilesInDir')->will($this->returnValue([$table])); $repo->expects($this->exactly(2))->method('buildPatchesFromDatabase')->with($this->equalTo($table))->will($this->returnValue($dbCollection)); $repo->expects($this->once())->method('buildPatchesFromFile')->with($this->equalTo($table))->will($this->returnValue($fileCollection)); $installRepository->expects($this->once())->method('buildInstallFromFile')->with($this->equalTo($table))->will($this->returnValue($install)); $findUnmatched = $this->createCallable(); $filterFactory->expects($this->once())->method('findUnmatched')->with($this->equalTo($dbCollection))->will($this->returnValue($findUnmatched)); $findAfterInstall = $this->createCallable(); $filterFactory->expects($this->once())->method('findAfterInstall')->with($this->equalTo($install))->will($this->returnValue($findAfterInstall)); $unmatched = $this->createCollection(); $fileCollection->expects($this->once())->method('findAll')->with($this->equalTo($findUnmatched))->will($this->returnValue($unmatched)); $unmatchedAfterInstall = $this->createCollection(); $unmatched->expects($this->once())->method('findAll')->with($this->equalTo($findAfterInstall))->will($this->returnValue($unmatchedAfterInstall)); $patch = $this->createPatch(); $patch->expects($this->once())->method('getQuery')->will($this->returnValue($queryString)); $query->expects($this->once())->method('patch')->with($this->equalTo($queryString))->will($this->returnValue($error)); $unmatchedAfterInstall->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$patch]))); $dbMap->expects($this->once())->method('applyPatch')->with($this->equalTo($patch)); $fileMap->expects($this->once())->method('applyPatch')->with($this->equalTo($patch)); $installer->expects($this->once())->method('updateInstallScripts')->with($this->equalTo($install), $this->equalTo($dbCollection)); $controller = new Patcher($repo, $filterFactory, $query, $handle, $dbMap, $fileMap, $installRepository, $installer); $controller->patchAll(); }