framework/extensions/package-manager/tests/integration/RefreshComposerSetup.php
dependabot[bot] 37a882118a
chore(deps): bump glob-parent from 3.1.0 to 5.1.2 in /extensions/emoji/js (#3345)
* chore(deps): bump glob-parent in /extensions/emoji/js

Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 3.1.0 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v3.1.0...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Apply fixes from StyleCI

[ci skip] [skip ci]

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2022-03-11 18:11:20 -05:00

56 lines
1.3 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration;
use FilesystemIterator;
use Flarum\PackageManager\Composer\ComposerAdapter;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
trait RefreshComposerSetup
{
public function tearDown(): void
{
$composerSetup = new SetupComposer();
@unlink($this->tmpDir().'/composer.lock');
$this->deleteDummyExtensions();
$composerSetup->run();
$this->composer('install');
parent::tearDown();
}
private function deleteDummyExtensions(): void
{
$dir = $this->tmpDir().'/packages';
$it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file) {
if ($file->isDir()) {
rmdir($file->getRealPath());
} else {
unlink($file->getRealPath());
}
}
rmdir($dir);
}
protected function forgetComposerApp(): void
{
$this->app()->getContainer()->instance(ComposerAdapter::class, null);
}
}