Skip to content

Commit

Permalink
Panther Test
Browse files Browse the repository at this point in the history
  • Loading branch information
teebbstudios committed Jul 7, 2021
1 parent 98e88e9 commit f056a70
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions tests/FunctionalTest/CommentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Tests\FunctionalTest;

use Symfony\Component\Panther\PantherTestCase;

class CommentTest extends PantherTestCase
{
public function testReplyComment(): void
{
$client = static::createPantherClient();
$crawler = $client->request('GET', '/');

$link = $crawler->selectLink('Read More →')->link();
$pageDetailCrawler = $client->click($link);

$form = $pageDetailCrawler->selectButton('Submit')->form();
$form['comment[author]'] = 'Teebblog';
$form['comment[email]'] = '[email protected]';
$form['comment[message]'] = '你好,世界!';
$client->submit($form);

// $this->assertResponseIsSuccessful();
$this->assertSelectorTextContains('.media-body', 'Teebblog');
$this->assertSelectorTextContains('.media-body', '你好,世界!');

$client->executeScript('document.querySelector(".js-reply-comment-btn").click()');
$newPageDetailCrawler = $client->waitFor('div.reply-comment-card');

$this->assertSelectorTextContains('div.reply-comment-card', '回复评论');

$replyCommentDivCrawler = $newPageDetailCrawler->filter('div.reply-comment-card');
$replyform = $replyCommentDivCrawler->selectButton('Submit')->form();
$replyform['comment[author]'] = 'Teebblog2';
$replyform['comment[email]'] = '[email protected]';
$replyform['comment[message]'] = '测试回复评论';
$client->submit($replyform);

$this->assertSelectorTextContains('.media-body', 'Teebblog2');
$this->assertSelectorTextContains('.media-body', '测试回复评论');

$client->takeScreenshot('screen.png');

}
}

0 comments on commit f056a70

Please sign in to comment.