diff --git a/.drone.jsonnet b/.drone.jsonnet index 34be0685..d16ae35e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -19,15 +19,12 @@ local composer(phpversion, params) = { commands: [ "php -v", "composer update " + params, - if phpversion == "8.0" then "wget https://ci.joomla.org/artifacts/phpunit8_php8_match.patch", - if phpversion == "8.0" then "patch -N -p0 < phpunit8_php8_match.patch" ] }; local phpunit(phpversion) = { name: "PHPUnit", image: "joomlaprojects/docker-images:php" + phpversion, - [if phpversion == "8.0" then "failure"]: "ignore", commands: ["vendor/bin/phpunit"] }; @@ -127,13 +124,12 @@ local pipeline(name, phpversion, params) = { ] }, pipeline("5.3", "5.3", "--prefer-stable"), - pipeline("5.4", "5.4", "--prefer-stable"), - pipeline("5.5", "5.5", "--prefer-stable"), pipeline("5.6", "5.6", "--prefer-stable"), pipeline("7.0", "7.0", "--prefer-stable"), pipeline("7.1", "7.1", "--prefer-stable"), pipeline("7.2", "7.2", "--prefer-stable"), pipeline("7.3", "7.3", "--prefer-stable"), pipeline("7.4", "7.4", "--prefer-stable"), - pipeline("8.0", "8.0", "--ignore-platform-reqs --prefer-stable") + pipeline("8.0", "8.0", "--prefer-stable"), + pipeline("8.1", "8.1", "--prefer-stable") ] diff --git a/.drone.yml b/.drone.yml index 25695297..2a3f5ce0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -99,8 +99,6 @@ steps: commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache @@ -117,7 +115,7 @@ volumes: --- kind: pipeline -name: PHP 5.4 +name: PHP 5.6 platform: os: linux @@ -125,18 +123,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php5.4 + image: joomlaprojects/docker-images:php5.6 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php5.4 + image: joomlaprojects/docker-images:php5.6 commands: - vendor/bin/phpunit @@ -147,7 +143,7 @@ volumes: --- kind: pipeline -name: PHP 5.5 +name: PHP 7.0 platform: os: linux @@ -155,18 +151,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php5.5 + image: joomlaprojects/docker-images:php7.0 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php5.5 + image: joomlaprojects/docker-images:php7.0 commands: - vendor/bin/phpunit @@ -177,7 +171,7 @@ volumes: --- kind: pipeline -name: PHP 5.6 +name: PHP 7.1 platform: os: linux @@ -185,18 +179,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php5.6 + image: joomlaprojects/docker-images:php7.1 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php5.6 + image: joomlaprojects/docker-images:php7.1 commands: - vendor/bin/phpunit @@ -207,7 +199,7 @@ volumes: --- kind: pipeline -name: PHP 7.0 +name: PHP 7.2 platform: os: linux @@ -215,18 +207,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php7.0 + image: joomlaprojects/docker-images:php7.2 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php7.0 + image: joomlaprojects/docker-images:php7.2 commands: - vendor/bin/phpunit @@ -237,7 +227,7 @@ volumes: --- kind: pipeline -name: PHP 7.1 +name: PHP 7.3 platform: os: linux @@ -245,18 +235,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php7.1 + image: joomlaprojects/docker-images:php7.3 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php7.1 + image: joomlaprojects/docker-images:php7.3 commands: - vendor/bin/phpunit @@ -267,7 +255,7 @@ volumes: --- kind: pipeline -name: PHP 7.2 +name: PHP 7.4 platform: os: linux @@ -275,18 +263,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php7.2 + image: joomlaprojects/docker-images:php7.4 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php7.2 + image: joomlaprojects/docker-images:php7.4 commands: - vendor/bin/phpunit @@ -297,7 +283,7 @@ volumes: --- kind: pipeline -name: PHP 7.3 +name: PHP 8.0 platform: os: linux @@ -305,18 +291,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php7.3 + image: joomlaprojects/docker-images:php8.0 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php7.3 + image: joomlaprojects/docker-images:php8.0 commands: - vendor/bin/phpunit @@ -327,7 +311,7 @@ volumes: --- kind: pipeline -name: PHP 7.4 +name: PHP 8.1 platform: os: linux @@ -335,18 +319,16 @@ platform: steps: - name: composer - image: joomlaprojects/docker-images:php7.4 + image: joomlaprojects/docker-images:php8.1 commands: - php -v - composer update --prefer-stable - - "" - - "" volumes: - name: composer-cache path: /tmp/composer-cache - name: PHPUnit - image: joomlaprojects/docker-images:php7.4 + image: joomlaprojects/docker-images:php8.1 commands: - vendor/bin/phpunit @@ -355,39 +337,8 @@ volumes: host: path: /tmp/composer-cache ---- -kind: pipeline -name: PHP 8.0 - -platform: - os: linux - arch: amd64 - -steps: -- name: composer - image: joomlaprojects/docker-images:php8.0 - commands: - - php -v - - composer update --ignore-platform-reqs --prefer-stable - - wget https://ci.joomla.org/artifacts/phpunit8_php8_match.patch - - patch -N -p0 < phpunit8_php8_match.patch - volumes: - - name: composer-cache - path: /tmp/composer-cache - -- name: PHPUnit - image: joomlaprojects/docker-images:php8.0 - commands: - - vendor/bin/phpunit - failure: ignore - -volumes: -- name: composer-cache - host: - path: /tmp/composer-cache - --- kind: signature -hmac: d21b6b782f740c9a4fdab2c148f95508a27917023b8c7c8741719e92f362cca8 +hmac: a001e7574875aa67206e82d45858a1f9aaca2ebbd32328123000bd06c1b0ec2d ... diff --git a/Tests/UriHelperTest.php b/Tests/php53/UriHelperTest.php similarity index 98% rename from Tests/UriHelperTest.php rename to Tests/php53/UriHelperTest.php index 5da8b533..170da871 100644 --- a/Tests/UriHelperTest.php +++ b/Tests/php53/UriHelperTest.php @@ -4,7 +4,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Uri\Tests; +namespace Joomla\Uri\Tests\php53; use Joomla\Uri\UriHelper; use PHPUnit\Framework\TestCase; diff --git a/Tests/UriImmutableTest.php b/Tests/php53/UriImmutableTest.php similarity index 98% rename from Tests/UriImmutableTest.php rename to Tests/php53/UriImmutableTest.php index 2b2d9786..f04b53d3 100644 --- a/Tests/UriImmutableTest.php +++ b/Tests/php53/UriImmutableTest.php @@ -4,7 +4,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Uri\Tests; +namespace Joomla\Uri\Tests\php53; use Joomla\Uri\UriImmutable; use PHPUnit\Framework\TestCase; @@ -343,14 +343,12 @@ public function testisSsl() /** * @testdox Calling the constructor of an instantiated UriImmutable object throws an exception. * - * @since __DEPLOY_VERSION__ + * @expectedException \BadMethodCallException */ public function testReconstruction() { $uri = new UriImmutable(); - $this->expectException('BadMethodCallException'); - $uri->__construct(); } } diff --git a/Tests/UriTest.php b/Tests/php53/UriTest.php similarity index 99% rename from Tests/UriTest.php rename to Tests/php53/UriTest.php index 1cf30728..589410e9 100644 --- a/Tests/UriTest.php +++ b/Tests/php53/UriTest.php @@ -4,7 +4,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Uri\Tests; +namespace Joomla\Uri\Tests\php53; use Joomla\Uri\Uri; use Joomla\Test\TestHelper; diff --git a/Tests/php71/UriHelperTest.php b/Tests/php71/UriHelperTest.php new file mode 100644 index 00000000..98980031 --- /dev/null +++ b/Tests/php71/UriHelperTest.php @@ -0,0 +1,75 @@ +assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + + // Test all parts of query + $url = 'https://john:doe@www.google.com:80/folder/page.html#id?var=kay&var2=key&true'; + $expected = parse_url($url); + $actual = UriHelper::parse_url($url); + $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + + // Test special characters in URL + $url = 'http://joomla.org/mytestpath/È'; + $expected = parse_url($url); + + // Fix up path for UTF-8 characters + $expected['path'] = '/mytestpath/È'; + $actual = UriHelper::parse_url($url); + $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + + // Test special characters in URL + $url = 'http://mydomain.com/!*\'();:@&=+$,/?%#[]" \\'; + $expected = parse_url($url); + $actual = UriHelper::parse_url($url); + $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + + // Test url encoding in URL + $url = 'http://mydomain.com/%21%2A%27%28%29%3B%3A%40%26%3D%24%2C%2F%3F%25%23%5B%22%20%5C'; + $expected = parse_url($url); + $actual = UriHelper::parse_url($url); + $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + + // Test a mix of the above + $url = 'http://john:doe@mydomain.com:80/%È21%25È3*%('; + $expected = parse_url($url); + + // Fix up path for UTF-8 characters + $expected['path'] = '/%È21%25È3*%('; + $actual = UriHelper::parse_url($url); + $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + + // Test invalild URL + $url = 'http:///mydomain.com'; + $expected = parse_url($url); + $actual = UriHelper::parse_url($url); + $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal'); + } +} diff --git a/Tests/php71/UriImmutableTest.php b/Tests/php71/UriImmutableTest.php new file mode 100644 index 00000000..16e60b90 --- /dev/null +++ b/Tests/php71/UriImmutableTest.php @@ -0,0 +1,355 @@ +object = new UriImmutable('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'); + } + + /** + * Tests the __set method. Immutable objects will throw + * an exception when you try to change a property. + * + * @return void + * + * @since 1.2.0 + * + */ + public function test__set() + { + $this->expectException(\BadMethodCallException::class); + $this->object->uri = 'http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'; + } + + /** + * Test the __toString method. + * + * @return void + * + * @since 1.0 + */ + public function test__toString() + { + $this->assertThat( + $this->object->__toString(), + $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + } + + /** + * Test the toString method. + * + * @return void + * + * @since 1.0 + */ + public function testToString() + { + $classname = \get_class($this->object); + + // The next 2 tested functions should generate equivalent results + $this->assertThat( + $this->object->toString(), + $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + + $this->assertThat( + $this->object->toString(array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')), + $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + + $this->assertThat( + $this->object->toString(array('scheme')), + $this->equalTo('http://') + ); + + $this->assertThat( + $this->object->toString(array('host', 'port')), + $this->equalTo('www.example.com:80') + ); + + $this->assertThat( + $this->object->toString(array('path', 'query', 'fragment')), + $this->equalTo('/path/file.html?var=value#fragment') + ); + + $this->assertThat( + $this->object->toString(array('user', 'pass', 'host', 'port', 'path', 'query', 'fragment')), + $this->equalTo('someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + } + + /** + * Test the render method. + * + * @return void + * + * @since 1.2.0 + */ + public function testRender() + { + $classname = \get_class($this->object); + + $this->assertThat( + $this->object->render($classname::ALL), + $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + + $this->assertThat( + $this->object->render($classname::SCHEME), + $this->equalTo('http://') + ); + + $this->assertThat( + $this->object->render($classname::HOST | $classname::PORT), + $this->equalTo('www.example.com:80') + ); + + $this->assertThat( + $this->object->render($classname::PATH | $classname::QUERY | $classname::FRAGMENT), + $this->equalTo('/path/file.html?var=value#fragment') + ); + + $this->assertThat( + $this->object->render($classname::ALL & ~$classname::SCHEME), + $this->equalTo('someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + } + + /** + * Test the hasVar method. + * + * @return void + * + * @since 1.0 + */ + public function testHasVar() + { + $this->assertThat( + $this->object->hasVar('somevar'), + $this->equalTo(false) + ); + + $this->assertThat( + $this->object->hasVar('var'), + $this->equalTo(true) + ); + } + + /** + * Test the getVar method. + * + * @return void + * + * @since 1.0 + */ + public function testGetVar() + { + $this->assertThat( + $this->object->getVar('var'), + $this->equalTo('value') + ); + + $this->assertThat( + $this->object->getVar('var2'), + $this->equalTo('') + ); + + $this->assertThat( + $this->object->getVar('var2', 'default'), + $this->equalTo('default') + ); + } + + /** + * Test the getQuery method. + * + * @return void + * + * @since 1.0 + */ + public function testGetQuery() + { + $this->assertThat( + $this->object->getQuery(), + $this->equalTo('var=value') + ); + + $this->assertThat( + $this->object->getQuery(true), + $this->equalTo(array('var' => 'value')) + ); + } + + /** + * Test the getScheme method. + * + * @return void + * + * @since 1.0 + */ + public function testGetScheme() + { + $this->assertThat( + $this->object->getScheme(), + $this->equalTo('http') + ); + } + + /** + * Test the getUser method. + * + * @return void + * + * @since 1.0 + */ + public function testGetUser() + { + $this->assertThat( + $this->object->getUser(), + $this->equalTo('someuser') + ); + } + + /** + * Test the getPass method. + * + * @return void + * + * @since 1.0 + */ + public function testGetPass() + { + $this->assertThat( + $this->object->getPass(), + $this->equalTo('somepass') + ); + } + + /** + * Test the getHost method. + * + * @return void + * + * @since 1.0 + */ + public function testGetHost() + { + $this->assertThat( + $this->object->getHost(), + $this->equalTo('www.example.com') + ); + } + + /** + * Test the getPort method. + * + * @return void + * + * @since 1.0 + */ + public function testGetPort() + { + $this->assertThat( + $this->object->getPort(), + $this->equalTo('80') + ); + } + + /** + * Test the getPath method. + * + * @return void + * + * @since 1.0 + */ + public function testGetPath() + { + $this->assertThat( + $this->object->getPath(), + $this->equalTo('/path/file.html') + ); + } + + /** + * Test the getFragment method. + * + * @return void + * + * @since 1.0 + */ + public function testGetFragment() + { + $this->assertThat( + $this->object->getFragment(), + $this->equalTo('fragment') + ); + } + + /** + * Test the isSsl method. + * + * @return void + * + * @since 1.0 + */ + public function testisSsl() + { + $this->object = new UriImmutable('https://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'); + + $this->assertThat( + $this->object->isSsl(), + $this->equalTo(true) + ); + + $this->object = new UriImmutable('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'); + + $this->assertThat( + $this->object->isSsl(), + $this->equalTo(false) + ); + } + + /** + * @testdox Calling the constructor of an instantiated UriImmutable object throws an exception. + */ + public function testReconstruction() + { + $uri = new UriImmutable(); + + $this->expectException(\BadMethodCallException::class); + + $uri->__construct(); + } +} diff --git a/Tests/php71/UriTest.php b/Tests/php71/UriTest.php new file mode 100644 index 00000000..9d2f15cc --- /dev/null +++ b/Tests/php71/UriTest.php @@ -0,0 +1,563 @@ +object = new Uri('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'); + } + + /** + * Test the __toString method. + * + * @return void + * + * @since 1.0 + */ + public function test__toString() + { + $this->assertThat( + $this->object->__toString(), + $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + } + + /** + * Test the buildQuery method. + * + * @return void + * + * @since 1.2.0 + */ + public function testBuildQuery() + { + $this->assertThat( + TestHelper::invoke( + $this->object, + 'buildQuery', + array( + 'var' => 'value', + 'foo' => 'bar' + ) + ), + $this->equalTo('var=value&foo=bar') + ); + } + + /** + * Test the cleanPath method. + * + * @return void + * + * @since 1.2.0 + */ + public function testcleanPath() + { + $this->assertThat( + TestHelper::invoke( + $this->object, + 'cleanPath', + '/foo/bar/../boo.php' + ), + $this->equalTo('/foo/boo.php') + ); + + $this->assertThat( + TestHelper::invoke( + $this->object, + 'cleanPath', + '/foo/bar/../../boo.php' + ), + $this->equalTo('/boo.php') + ); + + $this->assertThat( + TestHelper::invoke( + $this->object, + 'cleanPath', + '/foo/bar/.././/boo.php' + ), + $this->equalTo('/foo/boo.php') + ); + } + + /** + * Test the parse method. + * + * @return void + * + * @since 1.0 + */ + public function testConstruct() + { + $object = new Uri('http://someuser:somepass@www.example.com:80/path/file.html?var=value&test=true#fragment'); + + $this->assertThat( + $object->getHost(), + $this->equalTo('www.example.com') + ); + + $this->assertThat( + $object->getPath(), + $this->equalTo('/path/file.html') + ); + + $this->assertThat( + $object->getScheme(), + $this->equalTo('http') + ); + } + + /** + * Test the toString method. + * + * @return void + * + * @since 1.0 + */ + public function testToString() + { + $this->assertThat( + $this->object->toString(), + $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment') + ); + + $this->object->setQuery('somevar=somevalue'); + $this->object->setVar('somevar2', 'somevalue2'); + $this->object->setScheme('ftp'); + $this->object->setUser('root'); + $this->object->setPass('secret'); + $this->object->setHost('www.example.org'); + $this->object->setPort('8888'); + $this->object->setFragment('someFragment'); + $this->object->setPath('/this/is/a/path/to/a/file'); + + $this->assertThat( + $this->object->toString(), + $this->equalTo('ftp://root:secret@www.example.org:8888/this/is/a/path/to/a/file?somevar=somevalue&somevar2=somevalue2#someFragment') + ); + } + + /** + * Test the setVar method. + * + * @return void + * + * @since 1.0 + */ + public function testSetVar() + { + $this->object->setVar('somevariable', 'somevalue'); + + $this->assertThat( + $this->object->getVar('somevariable'), + $this->equalTo('somevalue') + ); + } + + /** + * Test the hasVar method. + * + * @return void + * + * @since 1.0 + */ + public function testHasVar() + { + $this->assertThat( + $this->object->hasVar('somevariable'), + $this->equalTo(false) + ); + + $this->assertThat( + $this->object->hasVar('var'), + $this->equalTo(true) + ); + } + + /** + * Test the getVar method. + * + * @return void + * + * @since 1.0 + */ + public function testGetVar() + { + $this->assertThat( + $this->object->getVar('var'), + $this->equalTo('value') + ); + + $this->assertThat( + $this->object->getVar('var2'), + $this->equalTo('') + ); + + $this->assertThat( + $this->object->getVar('var2', 'default'), + $this->equalTo('default') + ); + } + + /** + * Test the delVar method. + * + * @return void + * + * @since 1.0 + */ + public function testDelVar() + { + $this->assertThat( + $this->object->getVar('var'), + $this->equalTo('value') + ); + + $this->object->delVar('var'); + + $this->assertThat( + $this->object->getVar('var'), + $this->equalTo('') + ); + } + + /** + * Test the setQuery method. + * + * @return void + * + * @since 1.0 + */ + public function testSetQuery() + { + $this->object->setQuery('somevar=somevalue'); + + $this->assertThat( + $this->object->getQuery(), + $this->equalTo('somevar=somevalue') + ); + + $this->object->setQuery('somevar=somevalue&test=true'); + + $this->assertThat( + $this->object->getQuery(), + $this->equalTo('somevar=somevalue&test=true') + ); + + $this->object->setQuery(array('somevar' => 'somevalue', 'test' => 'true')); + + $this->assertThat( + $this->object->getQuery(), + $this->equalTo('somevar=somevalue&test=true') + ); + } + + /** + * Test the getQuery method. + * + * @return void + * + * @since 1.0 + */ + public function testGetQuery() + { + $this->assertThat( + $this->object->getQuery(), + $this->equalTo('var=value') + ); + + $this->assertThat( + $this->object->getQuery(true), + $this->equalTo(array('var' => 'value')) + ); + + // Set a new query + $this->object->setQuery('somevar=somevalue'); + + // Test if query is null, to build query in getQuery call. + $this->assertThat( + $this->object->getQuery(), + $this->equalTo('somevar=somevalue') + ); + } + + /** + * Test the getScheme method. + * + * @return void + * + * @since 1.0 + */ + public function testGetScheme() + { + $this->assertThat( + $this->object->getScheme(), + $this->equalTo('http') + ); + } + + /** + * Test the setScheme method. + * + * @return void + * + * @since 1.0 + */ + public function testSetScheme() + { + $this->object->setScheme('ftp'); + + $this->assertThat( + $this->object->getScheme(), + $this->equalTo('ftp') + ); + } + + /** + * Test the getUser method. + * + * @return void + * + * @since 1.0 + */ + public function testGetUser() + { + $this->assertThat( + $this->object->getUser(), + $this->equalTo('someuser') + ); + } + + /** + * Test the setUser method. + * + * @return void + * + * @since 1.0 + */ + public function testSetUser() + { + $this->object->setUser('root'); + + $this->assertThat( + $this->object->getUser(), + $this->equalTo('root') + ); + } + + /** + * Test the getPass method. + * + * @return void + * + * @since 1.0 + */ + public function testGetPass() + { + $this->assertThat( + $this->object->getPass(), + $this->equalTo('somepass') + ); + } + + /** + * Test the setPass method. + * + * @return void + * + * @since 1.0 + */ + public function testSetPass() + { + $this->object->setPass('secret'); + + $this->assertThat( + $this->object->getPass(), + $this->equalTo('secret') + ); + } + + /** + * Test the getHost method. + * + * @return void + * + * @since 1.0 + */ + public function testGetHost() + { + $this->assertThat( + $this->object->getHost(), + $this->equalTo('www.example.com') + ); + } + + /** + * Test the setHost method. + * + * @return void + * + * @since 1.0 + */ + public function testSetHost() + { + $this->object->setHost('www.example.org'); + + $this->assertThat( + $this->object->getHost(), + $this->equalTo('www.example.org') + ); + } + + /** + * Test the getPort method. + * + * @return void + * + * @since 1.0 + */ + public function testGetPort() + { + $this->assertThat( + $this->object->getPort(), + $this->equalTo('80') + ); + } + + /** + * Test the setPort method. + * + * @return void + * + * @since 1.0 + */ + public function testSetPort() + { + $this->object->setPort('8888'); + + $this->assertThat( + $this->object->getPort(), + $this->equalTo('8888') + ); + } + + /** + * Test the getPath method. + * + * @return void + * + * @since 1.0 + */ + public function testGetPath() + { + $this->assertThat( + $this->object->getPath(), + $this->equalTo('/path/file.html') + ); + } + + /** + * Test the setPath method. + * + * @return void + * + * @since 1.0 + */ + public function testSetPath() + { + $this->object->setPath('/this/is/a/path/to/a/file.htm'); + + $this->assertThat( + $this->object->getPath(), + $this->equalTo('/this/is/a/path/to/a/file.htm') + ); + } + + /** + * Test the getFragment method. + * + * @return void + * + * @since 1.0 + */ + public function testGetFragment() + { + $this->assertThat( + $this->object->getFragment(), + $this->equalTo('fragment') + ); + } + + /** + * Test the setFragment method. + * + * @return void + * + * @since 1.0 + */ + public function testSetFragment() + { + $this->object->setFragment('someFragment'); + + $this->assertThat( + $this->object->getFragment(), + $this->equalTo('someFragment') + ); + } + + /** + * Test the isSsl method. + * + * @return void + * + * @since 1.0 + */ + public function testisSsl() + { + $object = new Uri('https://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'); + + $this->assertThat( + $object->isSsl(), + $this->equalTo(true) + ); + + $object = new Uri('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'); + + $this->assertThat( + $object->isSsl(), + $this->equalTo(false) + ); + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2278bfba..6efb61ae 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,8 @@ - Tests + Tests/php53 + Tests/php71