diff --git a/.gitignore b/.gitignore
index 6730d3983..2ac02e93b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
+composer.phar
phpunit.xml
Tests/autoload.php
-
-vendor/*
+Tests/Functional/app/Behat/nginx.conf
+Tests/Functional/web/bundles
+vendor
diff --git a/.travis.yml b/.travis.yml
index bf65d2cca..9330f48f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,19 @@ php:
- 5.4
before_script:
- - curl -s http://getcomposer.org/installer | php
- - php composer.phar install --install-suggests --quiet
+ - export DISPLAY=:99.0 && sh -e /etc/init.d/xvfb start
+ - wget --quiet -O sahi.zip http://sourceforge.net/projects/sahi/files/sahi-v35/20110719/sahi_20110719.zip/download && unzip -qq sahi.zip
+ - export SAHI_HOME=sahi && sh sahi/bin/sahi.sh > /dev/null &
+ - curl --silent http://getcomposer.org/installer | php > /dev/null && php composer.phar install --install-suggests --quiet
+ - sudo apt-get -qq install nginx > /dev/null 2>&1
+ - nginx -v && sudo nginx -c app/Behat/nginx.conf.dist -p ./Tests/Functional
+ - for file in `find /home/vagrant/.phpenv -name 'xdebug.ini'`; do echo "xdebug.max_nesting_level=200" >> $file; done;
+ - php-cgi -b 127.0.0.1:9000 &
+ - ./Tests/Functional/app/console assets:install --symlink Tests/Functional/web > /dev/null && ./Tests/Functional/app/console doctrine:database:drop --force > /dev/null && ./Tests/Functional/app/console doctrine:database:create > /dev/null && ./Tests/Functional/app/console doctrine:schema:create
+
+script: ./run_tests.sh
notifications:
email:
- friendsofsymfony-dev@googlegroups.com
- - tim+build@nagel.com.au
\ No newline at end of file
+ - tim+build@nagel.com.au
diff --git a/EventListener/ThreadPermalinkListener.php b/EventListener/ThreadPermalinkListener.php
index 3d93b9928..0b71d2fd2 100644
--- a/EventListener/ThreadPermalinkListener.php
+++ b/EventListener/ThreadPermalinkListener.php
@@ -15,8 +15,8 @@
use FOS\CommentBundle\Event\ThreadEvent;
use FOS\CommentBundle\Model\ThreadInterface;
use FOS\CommentBundle\Model\ThreadManagerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\HttpFoundation\Request;
/**
* Responsible for setting a permalink for each new Thread object.
@@ -26,18 +26,18 @@
class ThreadPermalinkListener implements EventSubscriberInterface
{
/**
- * @var Request
+ * @var ContainerInterface
*/
- protected $request;
+ protected $container;
/**
* Constructor.
*
- * @param Request $request
+ * @param ContainerInterface $container
*/
- public function __construct(Request $request)
+ public function __construct(ContainerInterface $container)
{
- $this->request = $request;
+ $this->container = $container;
}
/**
@@ -47,8 +47,12 @@ public function __construct(Request $request)
*/
public function onThreadCreate(ThreadEvent $event)
{
+ if (!$this->container->isScopeActive('request')) {
+ return;
+ }
+
$thread = $event->getThread();
- $thread->setPermalink($this->request->getUri());
+ $thread->setPermalink($this->container->get('request')->getUri());
}
static public function getSubscribedEvents()
diff --git a/Features/Context/FeatureContext.php b/Features/Context/FeatureContext.php
new file mode 100644
index 000000000..774328bbd
--- /dev/null
+++ b/Features/Context/FeatureContext.php
@@ -0,0 +1,36 @@
+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');
+ }
+}
\ No newline at end of file
diff --git a/Features/EmbedThread.feature b/Features/EmbedThread.feature
new file mode 100644
index 000000000..14236bef8
--- /dev/null
+++ b/Features/EmbedThread.feature
@@ -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
\ No newline at end of file
diff --git a/Resources/assets/js/comments.js b/Resources/assets/js/comments.js
index 14d544394..4128ffd9e 100644
--- a/Resources/assets/js/comments.js
+++ b/Resources/assets/js/comments.js
@@ -96,6 +96,7 @@
{permalink: encodeURIComponent(permalink)},
function(data) {
FOS_COMMENT.thread_container.html(data);
+ FOS_COMMENT.thread_container.attr('data-thread', identifier);
}
);
},
diff --git a/Resources/config/events.xml b/Resources/config/events.xml
index 69a543703..c97c9f721 100644
--- a/Resources/config/events.xml
+++ b/Resources/config/events.xml
@@ -24,8 +24,8 @@
-