SerializerTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace GuzzleHttp\Tests\Command\Guzzle;
  3. use GuzzleHttp\Command\Command;
  4. use GuzzleHttp\Command\Guzzle\Description;
  5. use GuzzleHttp\Command\Guzzle\Serializer;
  6. use GuzzleHttp\Psr7\Request;
  7. /**
  8. * @covers \GuzzleHttp\Command\Guzzle\Serializer
  9. */
  10. class SerializerTest extends \PHPUnit_Framework_TestCase
  11. {
  12. public function testAllowsUriTemplates()
  13. {
  14. $description = new Description([
  15. 'baseUri' => 'http://test.com',
  16. 'operations' => [
  17. 'test' => [
  18. 'httpMethod' => 'GET',
  19. 'uri' => '/api/{key}/foo',
  20. 'parameters' => [
  21. 'key' => [
  22. 'required' => true,
  23. 'type' => 'string',
  24. 'location' => 'uri'
  25. ],
  26. ]
  27. ]
  28. ]
  29. ]);
  30. $command = new Command('test', ['key' => 'bar']);
  31. $serializer = new Serializer($description);
  32. /** @var Request $request */
  33. $request = $serializer($command);
  34. $this->assertEquals('http://test.com/api/bar/foo', $request->getUri());
  35. }
  36. }