Skip to content
Snippets Groups Projects
Commit c0be3dac authored by Sebastien's avatar Sebastien
Browse files

Test code refactoring

parent ade9789a
No related branches found
No related tags found
1 merge request!84Tuleap 198 get rid of create zip
Pipeline #1004 passed
<?php
namespace App\Tests;
use PHPUnit\Framework\Assert;
use Symfony\Component\Filesystem\Filesystem;
class TestFileHelper
{
private const LEGACY_DIRECTORY = __DIR__ . '/../legacy';
public static function createLegacyDirectoryIfNecessary(Assert $testCase): void
{
$fileSystem = new Filesystem();
if (!$fileSystem->exists(self::LEGACY_DIRECTORY)) {
$fileSystem->mkdir(self::LEGACY_DIRECTORY, 0644);
}
$testCase->assertTrue(
$fileSystem->exists(self::LEGACY_DIRECTORY),
'The directory \'' . self::LEGACY_DIRECTORY . '\' should exists'
);
}
}
......@@ -4,6 +4,7 @@ namespace App\Tests\functional;
use App\Entity\Capsule;
use App\Entity\User;
use App\Tests\TestFileHelper;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Filesystem\Filesystem;
......@@ -16,14 +17,7 @@ class CapsuleControllerTest extends WebTestCase
protected function setUp(): void
{
$fileSystem = new Filesystem();
if (!$fileSystem->exists(self::TEST_DIR_PATH)) {
$fileSystem->mkdir(self::TEST_DIR_PATH, 0644);
}
$this->assertTrue(
$fileSystem->exists(self::TEST_DIR_PATH),
'The directory \'' . self::TEST_DIR_PATH . '\' should exists'
);
TestFileHelper::createLegacyDirectoryIfNecessary($this);
chdir(self::TEST_DIR_PATH);
self::ensureKernelShutdown();
......
......@@ -4,6 +4,7 @@ namespace App\Tests\functional;
use App\Entity\Capsule;
use App\Entity\User;
use App\Tests\TestFileHelper;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
......@@ -21,14 +22,7 @@ class ProjectControllerTest extends WebTestCase
protected function setUp(): void
{
$fileSystem = new Filesystem();
if (!$fileSystem->exists(self::TEST_DIR_PATH)) {
$fileSystem->mkdir(self::TEST_DIR_PATH, 0644);
}
$this->assertTrue(
$fileSystem->exists(self::TEST_DIR_PATH),
'The directory \'' . self::TEST_DIR_PATH . '\' should exists'
);
TestFileHelper::createLegacyDirectoryIfNecessary($this);
chdir(self::TEST_DIR_PATH);
self::ensureKernelShutdown();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment