diff --git a/.travis.yml b/.travis.yml index 2392297..5bba298 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,24 +29,29 @@ script: - mkdir -p build/logs && ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml # League/Uri isolated factory test - - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros + - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros ringcentral/psr7 - composer req --dev --prefer-dist league/uri:^5.0 - ./vendor/bin/phpunit tests/UriFactoryTest.php # Zend Diactoros isolated ffactory test - - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros + - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros ringcentral/psr7 - composer req --dev --prefer-dist zendframework/zend-diactoros - ./vendor/bin/phpunit tests/UriFactoryTest.php # Guzzle PSR-7 isolated ffactory test - - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros + - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros ringcentral/psr7 - composer req --dev --prefer-dist guzzlehttp/psr7 - ./vendor/bin/phpunit tests/UriFactoryTest.php # Nyholm PSR-7 isolated ffactory test - - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros + - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros ringcentral/psr7 - composer req --dev --prefer-dist nyholm/psr7 - ./vendor/bin/phpunit tests/UriFactoryTest.php + # Nyholm PSR-7 isolated ffactory test + - composer rem --dev league/uri nyholm/psr7 guzzlehttp/psr7 zendframework/zend-diactoros ringcentral/psr7 + - composer req --dev --prefer-dist ringcentral/psr7 + - ./vendor/bin/phpunit tests/UriFactoryTest.php + after_script: - php vendor/bin/php-coveralls -v diff --git a/README.md b/README.md index 766fa4f..d183461 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Supported libraries so far: * `zendframework/zend-diactoros` * `league/uri` * `nyholm/psr7` +* `ringcentral/psr7` ## Usage @@ -53,7 +54,7 @@ $uri = current_location(ZendDiactorosAdapter::factory()); ## Canonicalizer -This library ships with an URL canonicalizer. +This library ships with an URL canonicalizer. It is not a perfect one since your PSR-7 library may behave differently regarding special chars, but it should work most of the time. diff --git a/composer.json b/composer.json index 72119cc..c0d05dc 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "nyholm/psr7": "^1.1", "php-coveralls/php-coveralls": "^2.1", "phpunit/phpunit": "~6.0|~7.0", + "ringcentral/psr7": "^1.3", "squizlabs/php_codesniffer": "@stable", "symfony/var-dumper": "^3.3", "zendframework/zend-diactoros": "^1.6" @@ -47,7 +48,8 @@ "league/uri": "URI manipulation Library", "zendframework/zend-diactoros": "PSR-7 HTTP Message implementation", "guzzlehttp/psr7": "PSR-7 HTTP message library", - "nyholm/psr7": "PSR-7 HTTP message library" + "nyholm/psr7": "PSR-7 HTTP message library", + "ringcentral/psr7": "PSR-7 HTTP message library" }, "config": { "sort-packages": true diff --git a/src/Adapter/RingCentralAdapter.php b/src/Adapter/RingCentralAdapter.php new file mode 100644 index 0000000..863b9ec --- /dev/null +++ b/src/Adapter/RingCentralAdapter.php @@ -0,0 +1,38 @@ +assertEquals(class_exists('RingCentral\Psr7\Uri'), RingCentralAdapter::isInstalled()); + } + + public function testFactory() + { + $factory = RingCentralAdapter::factory(); + $this->assertInstanceOf(RingCentralAdapter::class, $factory); + } + + public function testUri() + { + $factory = RingCentralAdapter::factory(); + $uri = $factory->createUri('http://www.example.net'); + $this->assertInstanceOf(UriInterface::class, $uri); + } + + public function testInFactory() + { + $_SERVER['HTTP_HOST'] = 'localhost'; + $_SERVER['REQUEST_URI'] = '/foo/bar?foo=bar&baz=bat'; + $uri = current_location(RingCentralAdapter::factory()); + $this->assertInstanceOf('RingCentral\Psr7\Uri', $uri); + unset($_SERVER['REQUEST_URI'], $_SERVER['HTTP_HOST']); + } +}