2.0 RC 1 - new ConfigurationService (#3810)
* use html5 email validation * remove static cache seed, for compatibility with non default (file based) caches * added caching ConfigurationService, removed use of doctrine result cache * simplify configuration API
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Configuration\ConfigurationService;
|
||||
use App\DataFixtures\UserFixtures;
|
||||
use App\Entity\Configuration;
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\DateRangeType;
|
||||
use App\Repository\ConfigurationRepository;
|
||||
use App\Repository\UserRepository;
|
||||
use App\Tests\KernelTestTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
@@ -89,9 +89,10 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
|
||||
protected function setSystemConfiguration(string $name, $value): void
|
||||
{
|
||||
$repository = self::getContainer()->get(ConfigurationRepository::class);
|
||||
/** @var ConfigurationService $repository */
|
||||
$repository = self::getContainer()->get(ConfigurationService::class);
|
||||
|
||||
$entity = $repository->findOneBy(['name' => $name]);
|
||||
$entity = $repository->getConfiguration($name);
|
||||
if ($entity === null) {
|
||||
$entity = new Configuration();
|
||||
$entity->setName($name);
|
||||
@@ -103,9 +104,9 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
|
||||
protected function clearConfigCache()
|
||||
{
|
||||
/** @var ConfigurationRepository $repository */
|
||||
$repository = self::getContainer()->get(ConfigurationRepository::class);
|
||||
$repository->clearCache();
|
||||
/** @var ConfigurationService $service */
|
||||
$service = self::getContainer()->get(ConfigurationService::class);
|
||||
$service->clearCache();
|
||||
}
|
||||
|
||||
protected function getClientForAuthenticatedUser(string $role = User::ROLE_USER): HttpKernelBrowser
|
||||
|
||||
@@ -10,11 +10,9 @@
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Configuration;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\TimesheetMeta;
|
||||
use App\Entity\User;
|
||||
use App\Repository\ConfigurationRepository;
|
||||
use App\Repository\TagRepository;
|
||||
use App\Tests\DataFixtures\ActivityFixtures;
|
||||
use App\Tests\DataFixtures\TagFixtures;
|
||||
@@ -442,12 +440,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
|
||||
/** @var ConfigurationRepository $repository */
|
||||
$repository = $this->getEntityManager()->getRepository(Configuration::class);
|
||||
$config = new Configuration();
|
||||
$config->setName('timesheet.rules.allow_overbooking_budget');
|
||||
$config->setValue(false);
|
||||
$repository->saveConfiguration($config);
|
||||
$this->setSystemConfiguration('timesheet.rules.allow_overbooking_budget', false);
|
||||
|
||||
$this->assertHasValidationError(
|
||||
$client,
|
||||
@@ -496,12 +489,7 @@ class TimesheetControllerTest extends ControllerBaseTest
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
|
||||
/** @var ConfigurationRepository $repository */
|
||||
$repository = $this->getEntityManager()->getRepository(Configuration::class);
|
||||
$config = new Configuration();
|
||||
$config->setName('timesheet.rules.allow_zero_duration');
|
||||
$config->setValue(false);
|
||||
$repository->saveConfiguration($config);
|
||||
$this->setSystemConfiguration('timesheet.rules.allow_zero_duration', false);
|
||||
|
||||
$this->assertHasValidationError(
|
||||
$client,
|
||||
|
||||
Reference in New Issue
Block a user