Skip to content

Commit

Permalink
Added a functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Eguiluz authored and Javier Eguiluz committed Jan 10, 2020
1 parent 7486dc8 commit 178e2b1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Controller/Admin/BlogControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,31 @@ public function testAdminNewPost()
$this->assertSame($postContent, $post->getContent());
}

public function testAdminNewDuplicatedPost()
{
$postTitle = 'Blog Post Title '.mt_rand();
$postSummary = $this->generateRandomString(255);
$postContent = $this->generateRandomString(1024);

$client = static::createClient([], [
'PHP_AUTH_USER' => 'jane_admin',
'PHP_AUTH_PW' => 'kitten',
]);
$crawler = $client->request('GET', '/en/admin/post/new');
$form = $crawler->selectButton('Create post')->form([
'post[title]' => $postTitle,
'post[summary]' => $postSummary,
'post[content]' => $postContent,
]);
$client->submit($form);

// post titles must be unique, so trying to create the same post twice should result in an error
$client->submit($form);

$this->assertSelectorTextSame('form .form-group.has-error label', 'Title');
$this->assertSelectorTextContains('form .form-group.has-error .help-block', 'This title was already used in another blog post, but they must be unique.');
}

public function testAdminShowPost()
{
$client = static::createClient([], [
Expand Down

0 comments on commit 178e2b1

Please sign in to comment.