mirror of
https://github.com/jbcr/sitemap-plugin.git
synced 2026-04-24 08:58:11 +02:00
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\SitemapPlugin\Controller;
|
|
|
|
use FilesystemIterator;
|
|
use RecursiveDirectoryIterator;
|
|
use RecursiveIteratorIterator;
|
|
|
|
trait TearDownTrait
|
|
{
|
|
public function tearDown(): void
|
|
{
|
|
if (null !== $this->client && null !== $this->client->getContainer()) {
|
|
$dir = $this->client->getContainer()->getParameter('sylius.sitemap.path');
|
|
|
|
if (!empty($dir) && \is_dir($dir)) {
|
|
$it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
|
|
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
|
|
foreach ($it as $file) {
|
|
if ($file->isDir()) {
|
|
\rmdir($file->getPathname());
|
|
|
|
continue;
|
|
}
|
|
|
|
\unlink($file->getPathname());
|
|
}
|
|
\rmdir($dir);
|
|
}
|
|
|
|
if (\method_exists($this->client->getContainer(), 'getMockedServices')) {
|
|
foreach ($this->client->getContainer()->getMockedServices() as $id => $service) {
|
|
$this->client->getContainer()->unmock($id);
|
|
}
|
|
}
|
|
}
|
|
|
|
\Mockery::close();
|
|
$this->client = null;
|
|
$this->entityManager = null;
|
|
$this->fixtureLoader = null;
|
|
}
|
|
}
|