Skip to content

Commit

Permalink
Improve UrlTests
Browse files Browse the repository at this point in the history
  • Loading branch information
spekulatius committed Nov 10, 2022
1 parent b3b576d commit 2fd6e1a
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions tests/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@ public function validateUriTest()
$web->go('https://test-pages.phpscraper.de/content/lists.html');

// Ensure the URL is set correctly.
$this->assertSame('https://test-pages.phpscraper.de/content/lists.html', $web->currentUrl);
$this->assertSame(
'https://test-pages.phpscraper.de/content/lists.html',
$web->currentUrl
);

// Ensure the host is parsed correctly.
$this->assertSame('test-pages.phpscraper.de', $web->currentHost);
$this->assertSame(
'test-pages.phpscraper.de',
$web->currentHost
);

// Ensure the host with protocol is parsed correctly.
$this->assertSame('https://test-pages.phpscraper.de', $web->currentBaseHost);
$this->assertSame(
'https://test-pages.phpscraper.de',
$web->currentBaseHost
);
}

/**
Expand All @@ -43,6 +52,26 @@ public function testNullPassingThrough()
/**
* @test
*/
public function testCurrentBaseHostWithBase()
{
$web = new \spekulatius\phpscraper;

// Navigate to the test page.
// Contains: <base href="https://test-pages-with-base-href.phpscraper.de/">
$web->go('https://test-pages.phpscraper.de/meta/image/absolute-path-with-base-href.html');

// Check the base href being passed through the current base host.
$this->assertSame(
'https://test-pages-with-base-href.phpscraper.de',
$web->currentBaseHost
);
}

/**
* Basic processing of the URLs.
*
* @test
*/
public function testMakeUrlAbsolute()
{
$web = new \spekulatius\phpscraper;
Expand Down Expand Up @@ -83,6 +112,8 @@ public function testMakeUrlAbsolute()
}

/**
* Test if passed in hosts are considered.
*
* @test
*/
public function testMakeUrlAbsoluteWithBaseHost()
Expand Down

0 comments on commit 2fd6e1a

Please sign in to comment.