forked from FriendsOfSymfony/FOSCommentBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request FriendsOfSymfony#174 from merk/more_testing
More testing
- Loading branch information
Showing
28 changed files
with
410 additions
and
93 deletions.
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
composer.phar | ||
phpunit.xml | ||
Tests/autoload.php | ||
|
||
vendor/* | ||
Tests/Functional/app/Behat/nginx.conf | ||
Tests/Functional/web/bundles | ||
vendor |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace FOS\CommentBundle\Features\Context; | ||
|
||
use Behat\BehatBundle\Context\MinkContext; | ||
use Behat\Behat\Exception\PendingException; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
|
||
/** | ||
* Feature context. | ||
*/ | ||
class FeatureContext extends MinkContext | ||
{ | ||
/** | ||
* @Given /^I have a thread identified by "([^"]*)" with a link of "([^"]*)"$/ | ||
*/ | ||
public function iHaveAThreadIdentifiedBy($id, $link) | ||
{ | ||
$thread = $this->getThreadManager()->findThreadById($id); | ||
if (!$thread) { | ||
$thread = $this->getThreadManager()->createThread($id); | ||
} | ||
|
||
$thread->setPermalink($link); | ||
|
||
$this->getThreadManager()->saveThread($thread); | ||
} | ||
|
||
/** | ||
* @return \FOS\CommentBundle\Model\ThreadManagerInterface | ||
*/ | ||
private function getThreadManager() | ||
{ | ||
return $this->getContainer()->get('fos_comment.manager.thread'); | ||
} | ||
} |
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,20 @@ | ||
Feature: Embed a thread on a page | ||
|
||
Background: | ||
Given I have a thread identified by "test" with a link of "test" | ||
|
||
Scenario: Embed a thread inline | ||
When I go to "inline/test" | ||
Then I should see a "#fos_comment_thread[data-thread=test]" element | ||
|
||
@javascript | ||
Scenario: Embed a thread async | ||
When I go to "async/test" | ||
Then I should see a "#fos_comment_thread[data-thread=test]" element | ||
|
||
@javascript | ||
Scenario: Reply to a thread | ||
When I go to "async/test" | ||
And I fill in "fos_comment_comment_body" with "I am replying to a comment" | ||
And I press "fos_comment_comment_new_submit" | ||
Then I should see "I am replying to a comment" in the ".fos_comment_comment_body" element |
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
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
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
1 change: 1 addition & 0 deletions
1
Tests/Functional/Bundle/CommentBundle/Resources/views/Comment/async.html.twig
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{% extends "::base.html.twig"%} | ||
|
||
{% block body %} | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | ||
{% include 'FOSCommentBundle:Thread:async.html.twig' with { 'id': id } %} | ||
{% endblock body %} |
8 changes: 3 additions & 5 deletions
8
Tests/Functional/Bundle/CommentBundle/Resources/views/Comment/inline.html.twig
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 |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
namespace FOS\CommentBundle\Tests\Functional; | ||
|
||
use Behat\Mink\Driver\GoutteDriver; | ||
use Symfony\Component\BrowserKit\Client; | ||
|
||
/* | ||
* This file has been duplicated from Behat, a private $client | ||
* does not allow us to overwrite the "new $class()" call because | ||
* our kernel has different parameters to the normal Kernel. | ||
*/ | ||
|
||
/** | ||
* Symfony2 Mink driver. | ||
* | ||
* @author Konstantin Kudryashov <ever.zet@gmail.com> | ||
*/ | ||
class SymfonyDriver extends GoutteDriver | ||
{ | ||
/** | ||
* Initializes Goutte driver. | ||
* | ||
* @param Symfony\Component\BrowserKit\Client $client BrowserKit client instance | ||
*/ | ||
public function __construct(Client $client = null) | ||
{ | ||
// create new kernel, that could be easily rebooted | ||
$class = get_class($client->getKernel()); | ||
$kernel = new $class('Behat', 'config.yml', $client->getKernel()->getEnvironment(), $client->getKernel()->isDebug()); | ||
$kernel->boot(); | ||
|
||
parent::__construct($kernel->getContainer()->get('test.client')); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* removes "*.php/" from urls and then passes it to GoutteDriver::visit(). | ||
*/ | ||
public function visit($url) | ||
{ | ||
$url = preg_replace('/^(https?\:\/\/[^\/]+)(\/[^\/]+\.php)?/', '$1', $url); | ||
parent::visit($url); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function reset() | ||
{ | ||
parent::reset(); | ||
|
||
$this->getClient()->getKernel()->shutdown(); | ||
$this->getClient()->getKernel()->boot(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setBasicAuth($user, $password) | ||
{ | ||
$this->getClient()->setServerParameter('PHP_AUTH_USER', $user); | ||
$this->getClient()->setServerParameter('PHP_AUTH_PW', $password); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setRequestHeader($name, $value) | ||
{ | ||
switch (strtolower($name)) { | ||
case 'accept': | ||
$name = 'HTTP_ACCEPT'; | ||
break; | ||
case 'accept-charset': | ||
$name = 'HTTP_ACCEPT_CHARSET'; | ||
break; | ||
case 'accept-encoding': | ||
$name = 'HTTP_ACCEPT_ENCODING'; | ||
break; | ||
case 'accept-language': | ||
$name = 'HTTP_ACCEPT_LANGUAGE'; | ||
break; | ||
case 'connection': | ||
$name = 'HTTP_CONNECTION'; | ||
break; | ||
case 'host': | ||
$name = 'HTTP_HOST'; | ||
break; | ||
case 'user-agent': | ||
$name = 'HTTP_USER_AGENT'; | ||
break; | ||
case 'authorization': | ||
$name = 'PHP_AUTH_DIGEST'; | ||
break; | ||
} | ||
|
||
$this->getClient()->setServerParameter($name, $value); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getResponseHeaders() | ||
{ | ||
$headers = array(); | ||
$responseHeaders = trim($this->getClient()->getResponse()->headers->__toString()); | ||
|
||
foreach (explode("\r\n", $responseHeaders) as $header) { | ||
list($name, $value) = array_map('trim', explode(':', $header, 2)); | ||
|
||
if (isset($headers[$name])) { | ||
$headers[$name] = array($headers[$name]); | ||
$headers[$name][] = $value; | ||
} else { | ||
$headers[$name] = $value; | ||
} | ||
} | ||
|
||
return $headers; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getStatusCode() | ||
{ | ||
return $this->getClient()->getResponse()->getStatusCode(); | ||
} | ||
} |
Oops, something went wrong.