This repository was archived by the owner on Jun 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20220213083946 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE comment ADD state VARCHAR(255) DEFAULT \'submitted\' NOT NULL'); | ||
$this->addSql("UPDATE comment SET state='published'"); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE SCHEMA public'); | ||
$this->addSql('ALTER TABLE comment DROP state'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,8 +37,16 @@ public function load(ObjectManager $manager): void | |
$comment1->setAuthor('Fabien'); | ||
$comment1->setEmail('[email protected]'); | ||
$comment1->setText('This was a great conference.'); | ||
$comment1->setState('published'); | ||
$manager->persist($comment1); | ||
|
||
$comment2 = new Comment(); | ||
$comment2->setConference($amsterdam); | ||
$comment2->setAuthor('Lucas'); | ||
$comment2->setEmail('[email protected]'); | ||
$comment2->setText('I think this one is going to be moderated.'); | ||
$manager->persist($comment2); | ||
|
||
$admin = new Admin(); | ||
$admin->setRoles(['ROLE_ADMIN']); | ||
$admin->setUsername('admin'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
namespace App\Tests\Controller; | ||
|
||
use App\Repository\CommentRepository; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
class ConferenceControllerTest extends WebTestCase | ||
|
@@ -22,10 +24,16 @@ public function testCommentSubmission() | |
$client->submitForm('Submit', [ | ||
'comment_form[author]' => 'Fabien', | ||
'comment_form[text]' => 'Some feedback from an automated functional test', | ||
'comment_form[email]' => '[email protected]', | ||
'comment_form[email]' => $email = '[email protected]', | ||
'comment_form[photo]' => dirname(__DIR__, 2).'/public/images/under-construction.gif', | ||
]); | ||
$this->assertResponseRedirects(); | ||
|
||
// simulate comment validation | ||
$comment = self::getContainer()->get(CommentRepository::class)->findOneByEmail($email); | ||
$comment->setState('published'); | ||
self::getContainer()->get(EntityManagerInterface::class)->flush(); | ||
|
||
$client->followRedirect(); | ||
$this->assertSelectorExists('div:contains("There are 2 comments")'); | ||
} | ||
|