Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Create session subscriber

  • Loading branch information...
commit c88da2906673894de2993bbfa75e66523baf558f 1 parent 4913700
@hnrysmth authored
View
6 phpunit.xml
@@ -8,5 +8,11 @@
</testsuite>
</testsuites>
+ <listeners>
+ <listener class="\Mockery\Adapter\Phpunit\TestListener"
+ file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php">
+ </listener>
+ </listeners>
+
</phpunit>
View
20 src/RedditApiClient/Client/Subscriber/Session.php
@@ -0,0 +1,20 @@
+<?php
+namespace RedditApiClient\Client\Subscriber;
+
+use Guzzle\Common\Event;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+class Session implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array(
+ 'request.before_send' => array('onRequestBeforeSend', 255),
+ );
+ }
+
+ public function onRequestBeforeSend(Event $event)
+ {
+ $curlOptions = $event['request']->getCurlOptions();
+ }
+}
View
34 tests/Client/Subscriber/SessionTest.php
@@ -0,0 +1,34 @@
+<?php
+namespace RedditApiClient\Test\Client\Subscriber;
+
+use Guzzle\Common\Event;
+use Mockery as m;
+use PHPUnit_Framework_TestCase;
+use RedditApiClient\Client\Subscriber\Session;
+
+class SessionTest extends PHPUnit_Framework_TestCase
+{
+ private $session;
+ private $event;
+ private $request;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->session = new Session;
+ $this->event = new Event;
+ $this->request = m::mock('Guzzle\Http\Message\Request');
+ $this->event['request'] = $this->request;
+ }
+
+ /**
+ * @test
+ */
+ public function onRequestBeforeSend()
+ {
+ $this->request
+ ->shouldReceive('getCurlOptions')
+ ->once();
+ $this->session->onRequestBeforeSend($this->event);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.