Skip to content

Commit 178e2b1

Browse files
Javier EguiluzJavier Eguiluz
authored andcommitted
Added a functional test
1 parent 7486dc8 commit 178e2b1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/Controller/Admin/BlogControllerTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,31 @@ public function testAdminNewPost()
105105
$this->assertSame($postContent, $post->getContent());
106106
}
107107

108+
public function testAdminNewDuplicatedPost()
109+
{
110+
$postTitle = 'Blog Post Title '.mt_rand();
111+
$postSummary = $this->generateRandomString(255);
112+
$postContent = $this->generateRandomString(1024);
113+
114+
$client = static::createClient([], [
115+
'PHP_AUTH_USER' => 'jane_admin',
116+
'PHP_AUTH_PW' => 'kitten',
117+
]);
118+
$crawler = $client->request('GET', '/en/admin/post/new');
119+
$form = $crawler->selectButton('Create post')->form([
120+
'post[title]' => $postTitle,
121+
'post[summary]' => $postSummary,
122+
'post[content]' => $postContent,
123+
]);
124+
$client->submit($form);
125+
126+
// post titles must be unique, so trying to create the same post twice should result in an error
127+
$client->submit($form);
128+
129+
$this->assertSelectorTextSame('form .form-group.has-error label', 'Title');
130+
$this->assertSelectorTextContains('form .form-group.has-error .help-block', 'This title was already used in another blog post, but they must be unique.');
131+
}
132+
108133
public function testAdminShowPost()
109134
{
110135
$client = static::createClient([], [

0 commit comments

Comments
 (0)