Skip to content

Commit

Permalink
🚨 we have to test the endpoints now
Browse files Browse the repository at this point in the history
  • Loading branch information
willpower232 committed Oct 1, 2024
1 parent cb53303 commit bb66440
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/SendServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use GuzzleHttp\Client as GuzzleHttpClient;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
use Postal\Client;
Expand Down Expand Up @@ -37,6 +38,9 @@ public function testMessage(): void
]);
$handlerStack = HandlerStack::create($mock);

$requests = [];
$handlerStack->push(Middleware::history($requests));

$guzzle = new GuzzleHttpClient([
'handler' => $handlerStack,
]);
Expand All @@ -52,6 +56,11 @@ public function testMessage(): void
$this->assertSame('A', $result->messages[0]->token);
$this->assertSame(2, $result->messages[1]->id);
$this->assertSame('B', $result->messages[1]->token);

$this->assertCount(1, $requests);
$uri = (string) $requests[0]['request']->getUri();

$this->assertSame('send/message', $uri);
}

public function testRaw(): void
Expand All @@ -76,6 +85,9 @@ public function testRaw(): void
]);
$handlerStack = HandlerStack::create($mock);

$requests = [];
$handlerStack->push(Middleware::history($requests));

$guzzle = new GuzzleHttpClient([
'handler' => $handlerStack,
]);
Expand All @@ -91,5 +103,10 @@ public function testRaw(): void
$this->assertSame('A', $result->messages[0]->token);
$this->assertSame(2, $result->messages[1]->id);
$this->assertSame('B', $result->messages[1]->token);

$this->assertCount(1, $requests);
$uri = (string) $requests[0]['request']->getUri();

$this->assertSame('send/raw', $uri);
}
}

0 comments on commit bb66440

Please sign in to comment.