public function onSiteInstalled()
 {
     $this->lazyFilesystemCleaner->register($this->masterPath);
     $this->filesystem->mirror($this->drupal->getSitePath(), $this->masterPath, null, ['override' => true, 'delete' => true]);
     // Take a copy of the database.
     $this->processRunner->run(ProcessBuilder::create()->setPrefix($this->binary)->add('sql-dump')->add('--result-file=' . $this->masterPath . '/db.sql')->add('--uri=' . $this->drupal->getUri())->add('--yes')->setWorkingDirectory($this->drupal->getPath())->setTimeout(null)->getProcess());
 }
 /**
  * @test
  */
 public function itUsesACopyOfAnInstalledSite()
 {
     $dispatcher = $this->prophesize('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $root = vfsStream::setup('foo');
     $root->addChild($sites = vfsStream::newDirectory('sites'));
     $sites->addChild($site = vfsStream::newDirectory('localhost'));
     $site->addChild($file = vfsStream::newFile('bar.tmp'));
     $sites->addChild($site = vfsStream::newDirectory('localhost.master'));
     $site->addChild($file = vfsStream::newFile('foo.tmp'));
     $site->addChild($file = vfsStream::newFile('db.sql'));
     $drupal = new Drupal('vfs://foo/', 'http://localhost/', 'standard');
     $processRunner = $this->prophesize('eLife\\IsolatedDrupalBehatExtension\\Process\\ProcessRunner');
     $cleaner = $this->prophesize('eLife\\IsolatedDrupalBehatExtension\\Filesystem\\FilesystemCleaner');
     $lazyCleaner = $this->prophesize('eLife\\IsolatedDrupalBehatExtension\\Filesystem\\LazyFilesystemCleaner');
     $listener = new BypassInstallSiteListener($dispatcher->reveal(), $drupal, new Filesystem(), '/path/to/drush', $processRunner->reveal(), $cleaner->reveal(), $lazyCleaner->reveal());
     $realDispatcher = $this->getDispatcher($listener);
     $realDispatcher->dispatch(InstallingSite::NAME, $event = new InstallingSite($drupal, new ProcessBuilder()));
     $this->assertFileExists($drupal->getSitePath() . '/foo.tmp');
     $this->assertFileNotExists($drupal->getSitePath() . '/db.sql');
     $this->assertFileNotExists($drupal->getSitePath() . '/bar.tmp');
     $processRunner->run(Argument::type('Symfony\\Component\\Process\\Process'))->shouldBeCalledTimes(2)->should(new CallbackPrediction(function (array $calls) use($drupal) {
         /** @var Call[] $calls */
         /** @var Process $process0 */
         $process0 = $calls[0]->getArguments()[0];
         /** @var Process $process1 */
         $process1 = $calls[1]->getArguments()[0];
         Assert::assertSame("'/path/to/drush' 'sql-drop' '--uri=http://localhost/' '--yes'", $process0->getCommandLine());
         Assert::assertSame($drupal->getPath(), $process0->getWorkingDirectory());
         Assert::assertSame("'/path/to/drush' 'sql-query' '--file=vfs://foo/sites/localhost/db.sql' '--uri=http://localhost/' '--yes'", $process1->getCommandLine());
         Assert::assertSame($drupal->getPath(), $process1->getWorkingDirectory());
     }));
     $dispatcher->dispatch(SiteCloned::NAME, Argument::type('eLife\\IsolatedDrupalBehatExtension\\Event\\SiteCloned'))->shouldHaveBeenCalled();
     $this->assertTrue($event->isPropagationStopped());
 }
 public function eventProvider()
 {
     $drupal = new Drupal('vfs://foo/bar', 'http://localhost/', 'standard');
     return [[InstallingSite::NAME, new InstallingSite($drupal, new ProcessBuilder()), [$drupal->getSitePath() => 1]], [SiteInstalled::NAME, new SiteInstalled($drupal), [$drupal->getSitePath() => 1]], [SiteCloned::NAME, new SiteCloned($drupal), [$drupal->getSitePath() => 1]]];
 }