for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @copyright 2010-2015 Mike van Riel<[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor;
use PHPUnit\Framework\TestCase;
* Test case for Uri
* @coversDefaultClass \phpDocumentor\Uri
final class UriTest extends TestCase
{
* @covers ::__construct
* @covers ::__toString
* @covers ::<private>
public function testItShouldReturnTheUriAsAString()
$uri = new Uri('http://foo.bar/phpdoc.xml');
$this->assertSame('http://foo.bar/phpdoc.xml', (string) $uri);
}
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage http://foo,bar is not a valid uri
public function testItShouldDiscardAnInvalidUri()
new Uri('http://foo,bar');
public function testItShouldAddAFileSchemeWhenSchemeIsAbsent()
$uri = new Uri('foo/phpdoc.xml');
$this->assertSame('file://foo/phpdoc.xml', (string) $uri);
public function testItShouldReturnTrueIfUrisAreEqual()
$uri1 = new Uri('foo');
$uri2 = new Uri('foo');
$this->assertTrue($uri1->equals($uri2));
$uri2
object<phpDocumentor\Uri>
object<self>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
public function testItShouldReturnTrueIfUrisAreNotEqual()
$uri2 = new Uri('bar');
$this->assertFalse($uri1->equals($uri2));
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: