parent
1c50a27746
commit
2b42aa4f66
@ -1 +0,0 @@
|
|||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Tests\Entity;
|
||||||
|
|
||||||
|
use App\Entity\Tags;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Entity\Post;
|
||||||
|
|
||||||
|
class TagsTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testGetId()
|
||||||
|
{
|
||||||
|
$tags = new Tags();
|
||||||
|
$this->assertNull($tags->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSetName()
|
||||||
|
{
|
||||||
|
$tags = new Tags();
|
||||||
|
$name = 'Test Tag';
|
||||||
|
$tags->setName($name);
|
||||||
|
|
||||||
|
$this->assertSame($name, $tags->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSetColor()
|
||||||
|
{
|
||||||
|
$tags = new Tags();
|
||||||
|
$color = '#FF0000';
|
||||||
|
$tags->setColor($color);
|
||||||
|
|
||||||
|
$this->assertSame($color, $tags->getColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddRemovePost()
|
||||||
|
{
|
||||||
|
$tags = new Tags();
|
||||||
|
$post = new Post();
|
||||||
|
|
||||||
|
$tags->addPost($post);
|
||||||
|
$this->assertTrue($tags->getPosts()->contains($post));
|
||||||
|
|
||||||
|
$tags->removePost($post);
|
||||||
|
$this->assertFalse($tags->getPosts()->contains($post));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Tests\Form;
|
||||||
|
|
||||||
|
use App\Form\ProfilType;
|
||||||
|
use App\Entity\Profil;
|
||||||
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
|
|
||||||
|
class ProfilTypeTest extends TypeTestCase
|
||||||
|
{
|
||||||
|
public function testSubmitValidData()
|
||||||
|
{
|
||||||
|
$formData = [
|
||||||
|
'name' => 'Test Name',
|
||||||
|
'description' => 'Lorem ipsum dolor sit amet.',
|
||||||
|
];
|
||||||
|
|
||||||
|
$objectToCompare = new Profil();
|
||||||
|
|
||||||
|
$form = $this->factory->create(ProfilType::class, $objectToCompare);
|
||||||
|
|
||||||
|
$object = new Profil();
|
||||||
|
$object->setName('Test Name');
|
||||||
|
$object->setDescription('Lorem ipsum dolor sit amet.');
|
||||||
|
|
||||||
|
$form->submit($formData);
|
||||||
|
|
||||||
|
$this->assertTrue($form->isSynchronized());
|
||||||
|
|
||||||
|
$this->assertEquals($object, $objectToCompare);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormFields()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create(ProfilType::class);
|
||||||
|
|
||||||
|
$this->assertTrue($form->has('name'));
|
||||||
|
$this->assertTrue($form->has('description'));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Tests\Form;
|
||||||
|
|
||||||
|
use App\Form\RegistrationFormType;
|
||||||
|
use App\Entity\Profil;
|
||||||
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class RegistrationFormTypeTest extends TypeTestCase
|
||||||
|
{
|
||||||
|
public function testSubmitValidData()
|
||||||
|
{
|
||||||
|
$formData = [
|
||||||
|
'name' => 'Test Name',
|
||||||
|
'agreeTerms' => true,
|
||||||
|
'plainPassword' => 'testpassword',
|
||||||
|
];
|
||||||
|
|
||||||
|
$form = $this->factory->create(RegistrationFormType::class);
|
||||||
|
|
||||||
|
$objectToCompare = new Profil();
|
||||||
|
|
||||||
|
$form->submit($formData);
|
||||||
|
|
||||||
|
$this->assertTrue($form->isSynchronized());
|
||||||
|
|
||||||
|
$this->assertEquals($formData['name'], $form->get('name')->getData());
|
||||||
|
$this->assertEquals($formData['agreeTerms'], $form->get('agreeTerms')->getData());
|
||||||
|
$this->assertEquals($formData['plainPassword'], $form->get('plainPassword')->getData());
|
||||||
|
|
||||||
|
$validator = Validation::createValidator();
|
||||||
|
$violations = $validator->validate($objectToCompare);
|
||||||
|
|
||||||
|
$this->assertCount(0, $violations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormFields()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create(RegistrationFormType::class);
|
||||||
|
|
||||||
|
$this->assertTrue($form->has('name'));
|
||||||
|
$this->assertTrue($form->has('agreeTerms'));
|
||||||
|
$this->assertTrue($form->has('plainPassword'));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Tests\Form\Type;
|
||||||
|
|
||||||
|
use App\Form\Type\PostType;
|
||||||
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
|
|
||||||
|
class PostTypeTest extends TypeTestCase
|
||||||
|
{
|
||||||
|
public function testSubmitValidData()
|
||||||
|
{
|
||||||
|
$formData = [
|
||||||
|
'title' => 'Test Title',
|
||||||
|
'text' => 'Lorem ipsum dolor sit amet.',
|
||||||
|
'dream' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$form = $this->factory->create(PostType::class);
|
||||||
|
|
||||||
|
$form->submit($formData);
|
||||||
|
|
||||||
|
$this->assertTrue($form->isSynchronized());
|
||||||
|
$this->assertEquals($formData['title'], $form->get('title')->getData());
|
||||||
|
$this->assertEquals($formData['text'], $form->get('text')->getData());
|
||||||
|
$this->assertEquals($formData['dream'], $form->get('dream')->getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormFields()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create(PostType::class);
|
||||||
|
|
||||||
|
$this->assertTrue($form->has('title'));
|
||||||
|
$this->assertTrue($form->has('text'));
|
||||||
|
$this->assertTrue($form->has('dream'));
|
||||||
|
$this->assertTrue($form->has('submit'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue