Skip to content

Commit

Permalink
Added more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Brecht-Precht committed Jul 12, 2016
1 parent 0df2d13 commit b45dd09
Showing 1 changed file with 69 additions and 3 deletions.
72 changes: 69 additions & 3 deletions test/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,91 @@
class UrlTest extends \PHPUnit_Framework_TestCase
{

public function testInvalidArguments()
public function testInvalidArgument1()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
new QueryParameter(1, 1);
}

public function testInvalidArgument2()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
new QueryParameter('arg1', new \Exception());
}

public function testInvalidArgument3()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
new Url(array());
}

public function testInvalidArgument4()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setScheme(1.4);
}

public function testInvalidArgument5()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setHostname(0);
}

public function testInvalidArgument6()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setPort('invalid');
}

public function testInvalidArgument7()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setPath(12);
$url->setQueryParameters('asd');
}

public function testInvalidArgument9()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setQueryParameters(array('asd'));
$url->setQueryParametersFromArray('asd');
}

public function testInvalidArgument11()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setQueryParametersFromArray(array(array()));
}

public function testInvalidArgument12()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->removeQueryParameterByKey(1);
}

public function testInvalidArgument13()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setUsername(array());
}

public function testInvalidArgument14()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setPassword(array());
}

public function testInvalidArgument15()
{
$this->setExpectedException(get_class(new \InvalidArgumentException()));
$url = new Url('https://john:[email protected]:8443/path/to/resource');
$url->setFragment(array());
}

Expand Down

0 comments on commit b45dd09

Please sign in to comment.