1010
1111use PHPUnit \Framework \TestCase ;
1212use Gomoob \Pushwoosh \Model \Request \CreateMessageRequest ;
13+ use Gomoob \Pushwoosh \Model \Request \CreateTargetedMessageRequest ;
1314
1415/**
1516 * Test case used to test the `PushwooshMock` class.
@@ -32,7 +33,8 @@ public function testCreateMessage()
3233 $ this ->assertCount (0 , $ pushwooshMock ->getPushwooshRequests ());
3334
3435 // Test call
35- $ createMessageResponse = $ pushwooshMock ->createMessage (CreateMessageRequest::create ());
36+ $ createMessageRequest = CreateMessageRequest::create ();
37+ $ createMessageResponse = $ pushwooshMock ->createMessage ($ createMessageRequest );
3638
3739 $ this ->assertNotNull ($ createMessageResponse );
3840 $ this ->assertSame (200 , $ createMessageResponse ->getStatusCode ());
@@ -42,5 +44,33 @@ public function testCreateMessage()
4244 $ createMessageResponseResponse = $ createMessageResponse ->getResponse ();
4345 $ this ->assertNotNull ($ createMessageResponseResponse );
4446 $ this ->assertCount (0 , $ createMessageResponseResponse ->getMessages ());
47+
48+ // One more requests has been send
49+ $ this ->assertCount (1 , $ pushwooshMock ->getPushwooshRequests ());
50+ $ this ->assertSame ($ createMessageRequest , $ pushwooshMock ->getPushwooshRequests ()[0 ]);
51+ }
52+
53+ /**
54+ * Test method for the `createTargetedMessage(CreateTargetedMessageRequest $createTargetedMessageRequest)` function.
55+ *
56+ * @group PushwooshTest.createTargetedMessage
57+ */
58+ public function testCreateTargetedMessage ()
59+ {
60+ $ pushwooshMock = new PushwooshMock ();
61+
62+ // At the beginning no pushwoosh requests have been sent
63+ $ this ->assertCount (0 , $ pushwooshMock ->getPushwooshRequests ());
64+
65+ // Test call
66+ $ createTargetedMessageResponse = $ pushwooshMock ->createTargetedMessage (CreateTargetedMessageRequest::create ());
67+
68+ $ this ->assertNotNull ($ createTargetedMessageResponse );
69+ $ this ->assertSame (200 , $ createTargetedMessageResponse ->getStatusCode ());
70+ $ this ->assertSame ('OK ' , $ createTargetedMessageResponse ->getStatusMessage ());
71+ $ this ->assertTrue ($ createTargetedMessageResponse ->isOk ());
72+
73+ $ createTargetedMessageResponseResponse = $ createTargetedMessageResponse ->getResponse ();
74+ $ this ->assertNotNull ($ createTargetedMessageResponseResponse );
4575 }
4676}
0 commit comments