Fix some tests

This commit is contained in:
2023-12-14 21:18:00 +01:00
parent d5476df14c
commit 2dd1b7c943
11 changed files with 92 additions and 127 deletions

View File

@@ -18,12 +18,13 @@ use Chill\MainBundle\Form\Type\ScopePickerType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\Persistence\ManagerRegistry;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\Test\TypeTestCase;
@@ -38,7 +39,7 @@ final class ScopePickerTypeTest extends TypeTestCase
{
use ProphecyTrait;
public function testBuildOneScopeIsSuccessful()
public function estBuildOneScopeIsSuccessful()
{
$form = $this->factory->create(ScopePickerType::class, null, [
'center' => new Center(),
@@ -107,9 +108,14 @@ final class ScopePickerTypeTest extends TypeTestCase
);
// add the mocks for creating EntityType
$entityManager = DoctrineTestHelper::createTestEntityManager();
$em = $this->prophesize(EntityManagerInterface::class);
$em->getClassMetadata(Scope::class)->willReturn($entityManager->getClassMetadata(Scope::class));
$em->getClassMetadata(Scope::class)->will(function (array $args) {
$classMetadata = new ClassMetadataBuilder(
new ClassMetadataInfo(Scope::class)
);
return $classMetadata->getClassMetadata();
});
$em->contains(Argument::type(Scope::class))->willReturn(true);
$em->initializeObject(Argument::type(Scope::class))->will(static fn ($o) => $o);
$emRevealed = $em->reveal();