项目作者: bakame-php

项目描述 :
A test suite to validate PSR-7 UriInterface implementation
高级语言: PHP
项目地址: git://github.com/bakame-php/psr7-uri-interface-tests.git
创建时间: 2015-06-30T10:36:56Z
项目社区:https://github.com/bakame-php/psr7-uri-interface-tests

开源协议:MIT License

下载


Unit tests for PSR-7 UriInterface

Tested implementations

Out of the box this package can run the tests against the following implementations (order alphabetically):

System Requirements

You need:

  • The latest stable version of PHP is recommended
  • the mbstring extension
  • the intl extension

Install

Clone this repo on a composer installed box and run the following command from the project folder.

  1. $ composer install

Testing

To run the tests, run the following command from the project folder.

  1. $ composer test

You can also run different tests according to the following groups:

Group Run tests for the
uri complete URI
scheme scheme component
userinfo userinfo component
host host component
port port component
authority authority part
path path component
query query component
fragment fragment component

Or run all the test against a specific implementation

Group Run tests against
diactoros Zend\Diactoros\Uri
guzzle Guzzle\Psr7\Uri
jasny Jasny\HttpMessage\Uri
league League\Uri\Schemes\Http
phpixie PHPixie\HTTP\Messages\URI\Implementation
riimu Riimu\Kit\UrlParser\Uri
slim Slim\HTTP\Uri
spatie Spatie\Url\Url
windwalker Windwalker\Uri\PsrUri

example

  1. $ composer test -- --group port
  2. $ composer test -- --group spatie

Adding a new implementation

  • Make sure your PSR-7 UriInterface interface implementation is available on packagist first
  • Clone this repo
  • Update the composer.json file with your package
  • Add a new class in the tests directory for your implementation that extends Bakame\Psr7\UriTest\AbstractUriTestCase by providing a URI factory to bootstrap URI object creation from your library.

Here’s a example to copy/paste and edit

  1. <?php
  2. namespace Bakame\Psr7\UriTest;
  3. use My\Library\Uri;
  4. /**
  5. * @group my-library
  6. */
  7. final class MyLibraryTest extends AbstractUriTestCase
  8. {
  9. protected function createUri($uri = '')
  10. {
  11. return new Uri($uri);
  12. }
  13. }
  • run the test suite.
  • you can submit your implementation via Pull Request (don’t forget to update the README.md file with a link to your repo in the Tested implementation section).

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.