Skip to content

Commit bb66440

Browse files
committed
🚨 we have to test the endpoints now
1 parent cb53303 commit bb66440

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎tests/SendServiceTest.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use GuzzleHttp\Client as GuzzleHttpClient;
88
use GuzzleHttp\Handler\MockHandler;
99
use GuzzleHttp\HandlerStack;
10+
use GuzzleHttp\Middleware;
1011
use GuzzleHttp\Psr7\Response;
1112
use PHPUnit\Framework\TestCase;
1213
use Postal\Client;
@@ -37,6 +38,9 @@ public function testMessage(): void
3738
]);
3839
$handlerStack = HandlerStack::create($mock);
3940

41+
$requests = [];
42+
$handlerStack->push(Middleware::history($requests));
43+
4044
$guzzle = new GuzzleHttpClient([
4145
'handler' => $handlerStack,
4246
]);
@@ -52,6 +56,11 @@ public function testMessage(): void
5256
$this->assertSame('A', $result->messages[0]->token);
5357
$this->assertSame(2, $result->messages[1]->id);
5458
$this->assertSame('B', $result->messages[1]->token);
59+
60+
$this->assertCount(1, $requests);
61+
$uri = (string) $requests[0]['request']->getUri();
62+
63+
$this->assertSame('send/message', $uri);
5564
}
5665

5766
public function testRaw(): void
@@ -76,6 +85,9 @@ public function testRaw(): void
7685
]);
7786
$handlerStack = HandlerStack::create($mock);
7887

88+
$requests = [];
89+
$handlerStack->push(Middleware::history($requests));
90+
7991
$guzzle = new GuzzleHttpClient([
8092
'handler' => $handlerStack,
8193
]);
@@ -91,5 +103,10 @@ public function testRaw(): void
91103
$this->assertSame('A', $result->messages[0]->token);
92104
$this->assertSame(2, $result->messages[1]->id);
93105
$this->assertSame('B', $result->messages[1]->token);
106+
107+
$this->assertCount(1, $requests);
108+
$uri = (string) $requests[0]['request']->getUri();
109+
110+
$this->assertSame('send/raw', $uri);
94111
}
95112
}

0 commit comments

Comments
 (0)