mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 05:47:11 +02:00
Implemented draft for PureSourceCreateType Test and adapted classes to it
This commit is contained in:
@@ -26,8 +26,7 @@ class IdAttributTest extends TestCase
|
||||
public function testConstruct(): void
|
||||
{
|
||||
$this->assertFalse($this->id->hasId());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->id->getId();
|
||||
$this->assertNull($this->id->getId());
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
|
@@ -27,8 +27,7 @@ class SlugAttributTest extends TestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertFalse($this->slugAttribut->hasSlug());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->slugAttribut->getSlug();
|
||||
$this->assertNull($this->slugAttribut->getSlug());
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
|
@@ -22,8 +22,7 @@ class AbstractEntityTest extends TestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertEquals(0, $this->entity->getVersion());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->entity->getId();
|
||||
$this->assertNull($this->entity->getId());
|
||||
}
|
||||
|
||||
public function testVersion(): void
|
||||
|
@@ -38,7 +38,6 @@ class AbstractSourceTest extends TestCase
|
||||
|
||||
public function testSlugInit(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->source->getSlug();
|
||||
$this->assertNull($this->source->getSlug());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Unit\Form\Source;
|
||||
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
use App\Entity\Source\PureSource;
|
||||
use App\Form\Source\PureSourceCreateType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @see https://symfony.com/doc/current/form/unit_testing.html
|
||||
*/
|
||||
class PureSourceCreateTypeTest extends TypeTestCase
|
||||
{
|
||||
const SLUG = 'ABCDE';
|
||||
|
||||
public function testAttributes(): void
|
||||
{
|
||||
$formData = ['slug' => self::SLUG];
|
||||
$objectToCompare = new PureSource();
|
||||
$form = $this->factory->create(PureSourceCreateType::class, $objectToCompare);
|
||||
|
||||
$object = new PureSource();
|
||||
$object->setSlug(self::SLUG);
|
||||
$object->setCreatorRelation($objectToCompare->getCreatorRelation());
|
||||
|
||||
// submit the data to the form directly
|
||||
$form->submit($formData);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
// check that $objectToCompare was modified as expected when the form was submitted
|
||||
//$this->assertEquals($object, $objectToCompare);
|
||||
|
||||
$view = $form->createView();
|
||||
$children = $view->children;
|
||||
|
||||
foreach (array_keys($formData) as $key) {
|
||||
$this->assertArrayHasKey($key, $children);
|
||||
}
|
||||
}
|
||||
}
|
@@ -52,8 +52,7 @@ class UserSourceRepositoryTest extends KernelTestCase
|
||||
$this->assertGreaterThan(0, $insertSource->getId());
|
||||
$this->entityManager->remove($insertSource);
|
||||
$this->entityManager->flush();
|
||||
$this->expectException(\TypeError::class);
|
||||
$insertSource->getId();
|
||||
$this->assertNull($insertSource->getId());
|
||||
}
|
||||
|
||||
public function testCreation(): void
|
||||
|
Reference in New Issue
Block a user