Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- nightly

matrix:
allow_failures:
- php: nightly
include:
- php: 5.3
dist: precise

before_script: composer install
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
{"name": "Jonathan H. Wage", "email": "jonwage@gmail.com"}
],
"autoload": {
"psr-0": {"Purl": "src/"}
"psr-4": {"Purl\\": "src/Purl"}
},
"autoload-dev": {
"psr-4": {"Purl\\Test\\": "tests/Purl/Test"}
},
"require": {
"php": ">=5.3.0",
"jeremykendall/php-domain-parser": "1.3.1"
"jeremykendall/php-domain-parser": "^1.3.1",
"phpunit/phpunit": "^4.8|^5.5|^6.5"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<phpunit bootstrap="./vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Purl Test Suite">
<directory suffix="Test.php">./tests/Purl/Test/</directory>
Expand Down
4 changes: 2 additions & 2 deletions tests/Purl/Test/AutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Autoloader;

class AutoloaderTest extends PHPUnit_Framework_TestCase
class AutoloaderTest extends TestCase
{
public function testRegister()
{
Expand Down
55 changes: 53 additions & 2 deletions tests/Purl/Test/FragmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Fragment;
use Purl\Path;
use Purl\Query;

class FragmentTest extends PHPUnit_Framework_TestCase
class FragmentTest extends TestCase
{
public function testConstruct()
{
Expand Down Expand Up @@ -61,4 +61,55 @@ public function testToString()
$fragment = new Fragment('test?param=value');
$this->assertEquals('test?param=value', (string) $fragment);
}

public function testIsInitialized()
{
$fragment = new Fragment('test?param=value');
$this->assertFalse($fragment->isInitialized());
}

public function testHas()
{
$fragment = new Fragment('test?param=value');
$fragment->setData(array('param' => 'value'));
$this->assertTrue($fragment->has('param'));
}

public function testRemove()
{
$fragment = new Fragment('test?param=value');
$fragment->setData(array('param' => 'value'));
$fragment->remove('param');
$this->assertFalse($fragment->has('param'));
}

public function testIsset()
{
$fragment = new Fragment('test?param=value');
$fragment->setData(array('param' => 'value'));
$fragment->remove('param');
$this->assertFalse($fragment->has('param'));
}

public function testOffsetExists()
{
$fragment = new Fragment('test?param=value');
$fragment->setData(array('param' => 'value'));
$this->assertTrue($fragment->offsetExists('param'));
}

public function testOffsetGet()
{
$fragment = new Fragment('test?param=value');
$fragment->setData(array('param' => 'value'));
$this->assertEquals('value', $fragment->offsetGet('param'));
}

public function testOffsetUnset()
{
$fragment = new Fragment('test?param=value');
$fragment->setData(array('param' => 'value'));
$fragment->offsetUnset('param');
$this->assertFalse($fragment->offsetExists('param'));
}
}
13 changes: 8 additions & 5 deletions tests/Purl/Test/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Parser;
use Pdp\PublicSuffixList;
use Pdp\PublicSuffixListManager;
use Pdp\Parser as PslParser;

class ParserTest extends PHPUnit_Framework_TestCase
class ParserTest extends TestCase
{
private $parser;

Expand Down Expand Up @@ -45,10 +45,13 @@ public function testParseUrl()
'resource' => '/about?param=value'
), $parts);
}


/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid url http:///example.com
*/
public function testParseBadUrlThrowsInvalidArgumentException()
{
$this->setExpectedException('\InvalidArgumentException', 'Invalid url http:///example.com');
$this->parser->parseUrl('http:///example.com');
$this->parser->parseUrl('http:///example.com/one/two?one=two#value');
}
}
4 changes: 2 additions & 2 deletions tests/Purl/Test/PathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Path;

class PathTest extends PHPUnit_Framework_TestCase
class PathTest extends TestCase
{
public function testConstruct()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Purl/Test/PublicSuffixListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Url;

class PublicSuffixListTest extends PHPUnit_Framework_TestCase
class PublicSuffixListTest extends TestCase
{
/**
* @dataProvider parseDataProvider
Expand Down
4 changes: 2 additions & 2 deletions tests/Purl/Test/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Query;

class QueryTest extends PHPUnit_Framework_TestCase
class QueryTest extends TestCase
{
public function testConstruct()
{
Expand Down
29 changes: 27 additions & 2 deletions tests/Purl/Test/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Purl\Test;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Purl\Fragment;
use Purl\Parser;
use Purl\ParserInterface;
use Purl\Path;
use Purl\Query;
use Purl\Url;

class UrlTest extends PHPUnit_Framework_TestCase
class UrlTest extends TestCase
{
public function testConstruct()
{
Expand Down Expand Up @@ -96,6 +96,14 @@ public function testSetPath()
$this->assertEquals('about', (string) $url->path);
}

public function testGetPath()
{
$url = new Url('http://jwage.com');
$url->path = 'about';
$this->assertInstanceOf('Purl\Path', $url->path);
$this->assertEquals('about', (string) $url->getPath());
}

public function testSetQuery()
{
$url = new Url('http://jwage.com');
Expand All @@ -105,6 +113,15 @@ public function testSetQuery()
$this->assertEquals(array('param1' => 'value1'), $url->query->getData());
}

public function testGetQuery()
{
$url = new Url('http://jwage.com');
$url->query->set('param1', 'value1');
$this->assertInstanceOf('Purl\Query', $url->query);
$this->assertEquals('param1=value1', $url->getQuery());
$this->assertEquals(array('param1' => 'value1'), $url->getQuery()->getData());
}

public function testSetFragment()
{
$url = new Url('http://jwage.com');
Expand All @@ -113,6 +130,14 @@ public function testSetFragment()
$this->assertEquals('http://jwage.com/#about?param1=value1', (string) $url);
}

public function testGetFragment()
{
$url = new Url('http://jwage.com');
$url->fragment->path = 'about';
$url->fragment->query->set('param1', 'value1');
$this->assertEquals('about?param1=value1', (string) $url->getFragment());
}

public function testGetNetloc()
{
$url = new Url('https://user:pass@jwage.com:443');
Expand Down
9 changes: 0 additions & 9 deletions tests/bootstrap.php

This file was deleted.