protected function _assertStateContent(MagentoState $state, array $modSet, $dbDump)
 {
     $state->extractDump($this->_temp)->extractMedia($this->_temp)->extractVar($this->_temp);
     foreach ($modSet as $file) {
         if (is_array($file)) {
             list($name, $content) = $file;
             $name = "{$this->_temp}/{$name}";
             $this->assertFileExists($name);
             $this->assertEquals($content, file_get_contents($name));
         } else {
             $this->assertTrue(is_dir("{$this->_temp}/{$file}"));
         }
     }
     $this->assertEquals($dbDump, file_get_contents("{$this->_temp}/dump"));
 }
예제 #2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testLoadFromIncorrectFileShouldThrowInvalidArgumentException()
 {
     $fileName = $this->_target('bad.state');
     file_put_contents($fileName, 'bueeeeeee');
     $state = new GenericState($fileName);
     $state->save();
 }
 public function restoreState($stateFileName)
 {
     $state = new MagentoState($stateFileName);
     $tempDir = $this->createTempDir();
     // restore dump
     $dumpFile = $tempDir . DIRECTORY_SEPARATOR . 'dump';
     $state->extractDump($tempDir);
     $this->getDb()->restoreDump($tempDir . DIRECTORY_SEPARATOR . 'dump');
     // restore var and media
     $params = $this->getParams();
     file_exists($params['options']['var_dir']) && $this->delete($params['options']['var_dir']);
     file_exists($params['options']['media_dir']) && $this->delete($params['options']['media_dir']);
     $state->extractVar($tempDir);
     $state->extractMedia($tempDir);
     Fso::move($tempDir . DIRECTORY_SEPARATOR . 'var', $params['options']['var_dir']);
     Fso::move($tempDir . DIRECTORY_SEPARATOR . 'media', $params['options']['media_dir']);
     $this->delete($tempDir);
 }