11<?php
22namespace AmsterdamPHP \Console ;
33
4+ use AmsterdamPHP \Console \Api \JoindInClient ;
45use AmsterdamPHP \Console \Command \CreateJoindInCommand ;
56use Crummy \Phlack \Builder \MessageBuilder ;
67use Crummy \Phlack \Message \Message ;
78use Crummy \Phlack \Phlack ;
89use DMS \Service \Meetup \AbstractMeetupClient ;
910use DMS \Service \Meetup \Response \MultiResultResponse ;
11+ use Guzzle \Http \Message \Header ;
12+ use GuzzleHttp \Message \Response ;
13+ use GuzzleHttp \Adapter \MockAdapter ;
14+ use GuzzleHttp \Event \Emitter ;
1015use Joindin \Api \Client ;
1116use Mockery \Mock ;
1217use Mockery \MockInterface ;
@@ -36,20 +41,36 @@ class CreateJoindInCommandTest extends \PHPUnit_Framework_TestCase
3641 */
3742 protected $ command ;
3843
44+ /**
45+ * @var MockAdapter
46+ */
47+ protected $ adapter ;
48+
49+ /**
50+ * @var JoindInClient
51+ */
52+ protected $ joindinClient ;
53+
3954 protected function setUp ()
4055 {
4156 parent ::setUp ();
4257 $ this ->meetup = \Mockery::mock (AbstractMeetupClient::class);
4358 $ this ->slack = \Mockery::mock (Phlack::class);
4459 $ this ->joindinEvents = \Mockery::mock (Client::class);
4560 $ this ->joindinEvents ->shouldReceive ('getService ' )->andReturnSelf ();
61+ $ this ->adapter = new MockAdapter ();
62+ $ this ->joindinClient = new JoindInClient ([
63+ 'adapter ' => $ this ->adapter ,
64+ 'emitter ' => new Emitter ()
65+ ]);
4666
47- $ this ->command = new CreateJoindInCommand ($ this ->meetup , $ this ->slack , $ this ->joindinEvents );
67+ $ this ->command = new CreateJoindInCommand ($ this ->meetup , $ this ->slack , $ this ->joindinEvents , $ this -> joindinClient );
4868 }
4969
5070 public function testCommand ()
5171 {
5272 $ meetupResponse = \Mockery::mock (MultiResultResponse::class)->shouldDeferMissing ();
73+ $ meetupResponse ->addHeader ('Content-Type ' , new Header ('Content-Type ' , 'application/json ' ));
5374 $ meetupResponse ->setData ([
5475 [
5576 'name ' => 'Monthly Meeting ' ,
@@ -61,7 +82,9 @@ public function testCommand()
6182
6283 $ this ->meetup ->shouldReceive ('getEvents ' )->andReturn ($ meetupResponse )->once ();
6384
64- $ this ->joindinEvents ->shouldReceive ('submit ' )->once ();
85+ $ this ->joindinEvents ->shouldReceive ('submit ' )
86+ ->andReturn (['url ' => 'http://some.path.to.api/v2.1/events/34 ' ])
87+ ->once ();
6588
6689 $ this ->slack ->shouldReceive ('getMessageBuilder ' )->andReturn (new MessageBuilder ())->once ();
6790 $ this ->slack ->shouldReceive ('send ' )->with (
@@ -73,6 +96,8 @@ function (Message $param) {
7396 )
7497 );
7598
99+ $ this ->adapter ->setResponse (new Response (200 ));
100+
76101 $ input = new ArrayInput ([]);
77102 $ output = new DummyOutput ();
78103
0 commit comments