Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rel=me test to use current PHPUnit namespace #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 21 additions & 21 deletions tests/RelMeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace IndieWeb;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* RelMeTest
*
* @author barnabywalters
*/
class RelMeTest extends PHPUnit_Framework_TestCase {
class RelMeTest extends TestCase {
public function testUnparseUrl() {
$this->assertEquals('http://example.com/', unparseUrl(parse_url('http://example.com')));
$this->assertEquals('http://example.com/?thing&more', unparseUrl(parse_url('http://example.com?thing&more')));
}

public function testNormaliseUrl() {
$this->assertEquals('http://example.com/', normaliseUrl('http://example.com'));
$this->assertEquals('http://example.com/?thing=1', normaliseUrl('http://example.com?thing=1'));
}

public function testHttpParseHeaders() {
$test = <<<EOT
content-type: text/html; charset=UTF-8
Expand All @@ -38,31 +38,31 @@ public function testHttpParseHeaders() {
$result = http_parse_headers($test);
$this->assertEquals($expected, $result);
}

/** @group network */
/* There is already a test for this in indieweb/rel-me
/* There is already a test for this in indieweb/rel-me
public function testFollowOneRedirect() {
$this->assertEquals('https://brennannovak.com/', followOneRedirect('http://brennannovak.com'));
}*/

public function testRelMeDocumentUrlHandlesNoRedirect() {
$chain = mockFollowOneRedirect(array(null));
$meUrl = normaliseUrl('http://example.com');
list($url, $isSecure, $previous) = relMeDocumentUrl($meUrl, $chain);
$this->assertEquals($meUrl, $url);
$this->assertTrue($isSecure);
}

public function testRelMeDocumentUrlHandlesSingleSecureHttpRedirect() {
$finalUrl = normaliseUrl('http://example.org');
$chain = mockFollowOneRedirect(array($finalUrl));
$meUrl = normaliseUrl('http://example.com');
list($url, $isSecure, $previous) = relMeDocumentUrl($meUrl, $chain);
$this->assertEquals($finalUrl, $url);
$this->assertTrue($isSecure);
$this->assertTrue($isSecure);
$this->assertContains($finalUrl, $previous);
}

public function testRelMeDocumentUrlHandlesMultipleSecureHttpRedirects() {
$finalUrl = normaliseUrl('http://example.org');
$intermediateUrl = normaliseUrl('http://www.example.org');
Expand All @@ -73,17 +73,17 @@ public function testRelMeDocumentUrlHandlesMultipleSecureHttpRedirects() {
$this->assertTrue($isSecure);
$this->assertContains($intermediateUrl, $previous);
}

public function testRelMeDocumentUrlHandlesSingleSecureHttpsRedirect() {
$finalUrl = normaliseUrl('https://example.org');
$chain = mockFollowOneRedirect(array($finalUrl));
$meUrl = normaliseUrl('https://example.com');
list($url, $isSecure, $previous) = relMeDocumentUrl($meUrl, $chain);
$this->assertEquals($finalUrl, $url);
$this->assertTrue($isSecure);
$this->assertTrue($isSecure);
$this->assertContains($finalUrl, $previous);
}

public function testRelMeDocumentUrlHandlesMultipleSecureHttpsRedirects() {
$finalUrl = normaliseUrl('https://example.org');
$intermediateUrl = normaliseUrl('https://www.example.org');
Expand All @@ -94,7 +94,7 @@ public function testRelMeDocumentUrlHandlesMultipleSecureHttpsRedirects() {
$this->assertTrue($isSecure);
$this->assertContains($intermediateUrl, $previous);
}

public function testRelMeDocumentUrlReportsInsecureRedirect() {
$finalUrl = normaliseUrl('http://example.org');
$intermediateUrl = normaliseUrl('https://www.example.org');
Expand All @@ -104,7 +104,7 @@ public function testRelMeDocumentUrlReportsInsecureRedirect() {
$this->assertFalse($isSecure);
$this->assertContains($intermediateUrl, $previous);
}

public function testRelMeLinksFindsLinks() {
$relMeLinks = relMeLinks(<<<EOT
<link rel="me" href="http://example.org" />
Expand All @@ -113,17 +113,17 @@ public function testRelMeLinksFindsLinks() {
, 'http://example.com');
$this->assertEquals(array('http://example.org', 'http://twitter.com/barnabywalters'), $relMeLinks);
}

// backlinkingRelMeSuccessNoRedirect tests

public function testBacklinkingRelMeSuccessNoRedirect() {
$meUrl = $backlinkingMeUrl = 'http://example.com';
$chain = mockFollowOneRedirect(array($backlinkingMeUrl));
list($matches, $secure, $previous) = backlinkingRelMeUrlMatches($backlinkingMeUrl, $meUrl, $chain);
$this->assertTrue($matches);
$this->assertTrue($secure);
}

public function testBacklinkingRelMeSuccessOneRedirect() {
$meUrl = 'http://example.com';
$backlinkingMeUrl = 'http://example.org';
Expand All @@ -132,7 +132,7 @@ public function testBacklinkingRelMeSuccessOneRedirect() {
$this->assertTrue($matches);
$this->assertTrue($secure);
}

public function testBacklinkingRelMeNoMatchInsecureRedirect() {
$meUrl = 'http://example.com';
$backlinkingMeUrl = 'http://example.org';
Expand All @@ -141,7 +141,7 @@ public function testBacklinkingRelMeNoMatchInsecureRedirect() {
$this->assertFalse($matches);
$this->assertFalse($secure);
}

public function testBacklinkingRelMeSuccessInsecureRedirect() {
$meUrl = 'http://example.org';
$backlinkingMeUrl = 'http://example.com';
Expand All @@ -150,7 +150,7 @@ public function testBacklinkingRelMeSuccessInsecureRedirect() {
$this->assertTrue($matches);
$this->assertFalse($secure);
}

public function testBacklinkingRelMeSecureRedirectNoMatch() {
$meUrl = 'http://example.org';
$backlinkingMeUrl = 'http://example.com';
Expand Down